feat(corfu): add +corfu/toggle-auto-complete command

This commit is contained in:
Henrik Lissner 2024-08-28 22:26:47 -04:00
parent cea17bbea3
commit 4a4a9a1ada
No known key found for this signature in database
GPG key ID: B60957CA074D39A3

View file

@ -46,4 +46,18 @@
(let ((cape-dabbrev-check-other-buffers nil))
(cape-dabbrev t)))
;;;###autoload
(defun +corfu/toggle-auto-complete (&optional interactive)
"Toggle as-you-type completion in Corfu."
(interactive (list 'interactive))
(dolist (buf (buffer-list))
(with-current-buffer buf
(when corfu-mode
(if corfu-auto
(remove-hook 'post-command-hook #'corfu--auto-post-command 'local)
(add-hook 'post-command-hook #'corfu--auto-post-command nil 'local)))))
(when interactive
(message "Corfu auto-complete %s" (if corfu-auto "disabled" "enabled")))
(setq corfu-auto (not corfu-auto)))
;;; end of autoload.el