Function: corfu--setup
corfu--setup is a byte-compiled function defined in corfu.el.
Signature
(corfu--setup BEG END TABLE PRED)
Documentation
Setup Corfu completion state.
See completion-in-region for the arguments BEG, END, TABLE, PRED.
Source Code
;; Defined in ~/.emacs.d/elpa/corfu-20260813.950/corfu.el
(defun corfu--setup (beg end table pred)
"Setup Corfu completion state.
See `completion-in-region' for the arguments BEG, END, TABLE, PRED."
(let ((props completion-extra-properties))
(when (eq (car props) :corfu--state)
(dolist (s (cadr props)) (set (car s) (cdr s)))
(setq props (cddr props)))
(setq end (if (and (markerp end) (marker-insertion-type end)) end (copy-marker end t))
completion-in-region--data (list (+ 0 beg) end table pred props)))
(completion-in-region-mode)
(activate-change-group (setq corfu--change-group (prepare-change-group)))
(setcdr (assq #'completion-in-region-mode minor-mode-overriding-map-alist) corfu-map)
(add-hook 'pre-command-hook #'corfu--prepare nil 'local)
(add-hook 'window-selection-change-functions #'corfu--window-change nil 'local)
(add-hook 'window-buffer-change-functions #'corfu--window-change nil 'local)
(add-hook 'post-command-hook #'corfu--post-command)
;; Disable default post-command handling, since we have our own
;; checks in `corfu--post-command'.
(remove-hook 'post-command-hook #'completion-in-region--postch)
(let ((sym (make-symbol "corfu--teardown"))
(buf (current-buffer)))
(fset sym (lambda ()
;; Ensure that the tear-down runs in the correct buffer, if still alive.
(unless completion-in-region-mode
(remove-hook 'completion-in-region-mode-hook sym)
(corfu--teardown buf))))
(add-hook 'completion-in-region-mode-hook sym)))