Function: corfu--capf-wrapper
corfu--capf-wrapper is a byte-compiled function defined in corfu.el.
Signature
(corfu--capf-wrapper FUN &optional PREFIX)
Documentation
Wrapper for completion-at-point FUN.
The wrapper determines if the Capf is applicable at the current position, performs sanity checking on the returned result and computes the initial completion state. PREFIX is the minimum prefix length.
Source Code
;; Defined in ~/.emacs.d/elpa/corfu-20260813.950/corfu.el
(defun corfu--capf-wrapper (fun &optional prefix)
"Wrapper for `completion-at-point' FUN.
The wrapper determines if the Capf is applicable at the current
position, performs sanity checking on the returned result and computes
the initial completion state. PREFIX is the minimum prefix length."
(pcase (funcall fun)
(`(,beg ,end ,table . ,plist)
(and (integer-or-marker-p beg) ;; Valid Capf result
(<= beg (point) end) ;; Sanity checking
;; Check minimal prefix length if given.
(or (not prefix)
(let ((len (or (plist-get plist :company-prefix-length)
(- (point) beg))))
(or (eq len t) (>= len prefix))))
(let* ((str (buffer-substring-no-properties beg end))
(pt (- (point) beg))
(pred (plist-get plist :predicate))
(state (corfu--compute (cons str pt) table pred)))
(cond ((alist-get 'corfu--candidates state)
`(,fun ,beg ,end ,table :corfu--state ,state ,@plist))
;; Stop with empty result for exclusive Capf.
((not (eq 'no (plist-get plist :exclusive)))
'(nil))))))))