Function: cape-wrap-super

cape-wrap-super is an autoloaded and byte-compiled function defined in cape.el.

Signature

(cape-wrap-super &rest CAPFS)

Documentation

Call CAPFS and return merged completion result.

The CAPFS list can contain the keyword :with to mark the Capfs afterwards as auxiliary. One of the non-auxiliary Capfs before :with must return non-nil for the super Capf to set in and return a non-nil result. Such behavior is useful when listing multiple super Capfs in the completion-at-point-functions:

  (setq completion-at-point-functions
        (list (cape-capf-super 'elisp-completion-at-point
                               :with 'tempel-complete)
              (cape-capf-super 'cape-dabbrev
                               :with 'tempel-complete)))

See the dual cape-wrap-choose if you want to try multiple Capfs in turn.

Source Code

;; Defined in ~/.emacs.d/elpa/cape-20260804.2303/cape.el
;;;###autoload
(defun cape-wrap-super (&rest capfs)
  "Call CAPFS and return merged completion result.
The CAPFS list can contain the keyword `:with' to mark the Capfs
afterwards as auxiliary.  One of the non-auxiliary Capfs before `:with'
must return non-nil for the super Capf to set in and return a non-nil
result.  Such behavior is useful when listing multiple super Capfs in
the `completion-at-point-functions':

  (setq completion-at-point-functions
        (list (cape-capf-super \\='elisp-completion-at-point
                               :with \\='tempel-complete)
              (cape-capf-super \\='cape-dabbrev
                               :with \\='tempel-complete)))

See the dual `cape-wrap-choose' if you want to try multiple Capfs in
turn."
  (when-let* ((results (cl-loop for capf in capfs until (eq capf :with)
                                for res = (funcall capf)
                                if res collect (cons t res))))
    (nconc results (cl-loop for capf in (cdr (memq :with capfs))
                            for res = (funcall capf)
                            if res collect (cons nil res)))
    (pcase-let* ((`((,_main ,beg ,end . ,_)) results)
                 (`(,tables ,exc ,plen) (cape--super-prefix beg end results))
                 (cache (cons nil nil)))
      `( ,beg ,end
         ,(lambda (str pred action)
            (pcase action
              ((or `(boundaries . ,_) 'metadata) nil)
              ('t ;; all-completions
               (cape--super-all str pred tables exc cache))
              ('nil ;; try-completion
               (let ((cands (cape--super-all str pred tables exc cache)))
                 (or (try-completion str cands pred)
                     (cape--super-complete str pred action tables))))
              (_ ;; test-completion and other actions
               (cape--super-complete str pred action tables))))
         :category cape-super
         :company-prefix-length ,plen
         :display-sort-function ,#'identity
         :cycle-sort-function ,#'identity
         ,@(and (not exc) '(:exclusive no))
         ,@(cl-loop for f in cape--super-functions
                    collect f collect (cape--super-function f cache))))))