Function: cape-wrap-predicate

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

Signature

(cape-wrap-predicate CAPF PREDICATE)

Documentation

Call CAPF and add an additional candidate PREDICATE.

The PREDICATE is passed the candidate symbol or string.

Source Code

;; Defined in ~/.emacs.d/elpa/cape-20260804.2303/cape.el
;;;###autoload
(defun cape-wrap-predicate (capf predicate)
  "Call CAPF and add an additional candidate PREDICATE.
The PREDICATE is passed the candidate symbol or string."
  (pcase (funcall capf)
    (`(,beg ,end ,table . ,plist)
     `( ,beg ,end ,table
        :predicate
        ,(if-let* ((pred (plist-get plist :predicate)))
             ;; First argument is key, second is value for hash tables.
             ;; The first argument can be a cons cell for alists. Then
             ;; the candidate itself is either a string or a symbol. We
             ;; normalize the calling convention here such that PREDICATE
             ;; always receives a string or a symbol.
             (lambda (&rest args)
               (when (apply pred args)
                 (setq args (car args))
                 (funcall predicate (if (consp args) (car args) args))))
           (lambda (key &optional _val)
             (funcall predicate (if (consp key) (car key) key))))
        ,@plist))))