feat(corfu): introduce +corfu-inhibit-auto-functions

This commit is contained in:
Henrik Lissner 2024-09-01 14:48:36 -04:00
parent 1ec4bac75e
commit 63e9b11280
No known key found for this signature in database
GPG key ID: B60957CA074D39A3

View file

@ -28,6 +28,11 @@ TAB/S-TAB.")
"If non-nil, prefer navigating org tables over cycling candidates with "If non-nil, prefer navigating org tables over cycling candidates with
TAB/S-TAB.") TAB/S-TAB.")
(defvar +corfu-inhibit-auto-functions ()
"A list of predicate functions that take no arguments.
If any return non-nil, `corfu-auto' will not invoke as-you-type completion.")
;; ;;
;;; Packages ;;; Packages
@ -79,6 +84,14 @@ See `+corfu-want-minibuffer-completion'."
(list (current-local-map)))))) (list (current-local-map))))))
(setq global-corfu-minibuffer #'+corfu-enable-in-minibuffer-p) (setq global-corfu-minibuffer #'+corfu-enable-in-minibuffer-p)
;; HACK: Augments Corfu to respect `+corfu-inhibit-auto-functions'.
(defadvice! +corfu--post-command-a (fn &rest args)
"Refresh Corfu after last command."
(let ((corfu-auto
(if corfu-auto
(not (run-hook-with-args-until-success '+corfu-inhibit-auto-functions)))))
(apply fn args)))
;; HACK: If you want to update the visual hints after completing minibuffer ;; HACK: If you want to update the visual hints after completing minibuffer
;; commands with Corfu and exiting, you have to do it manually. ;; commands with Corfu and exiting, you have to do it manually.
(defadvice! +corfu--insert-before-exit-minibuffer-a () (defadvice! +corfu--insert-before-exit-minibuffer-a ()