From 41b8419997a0ef73538c0473b6989bfb8cde09fc Mon Sep 17 00:00:00 2001 From: Franck Cuny Date: Tue, 15 Nov 2022 07:46:48 -0800 Subject: fix(completion): follow the documentation for eshell integration Change-Id: Id92adf55cc75467b4ea7f98709cf8769f1ad6c2f --- emacs/custom/my-completion.el | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/emacs/custom/my-completion.el b/emacs/custom/my-completion.el index a8629c8..fb6ce66 100644 --- a/emacs/custom/my-completion.el +++ b/emacs/custom/my-completion.el @@ -25,6 +25,23 @@ (setq corfu-auto t) ;; Enable auto completion (setq corfu-max-width 80) ;; Default is 100 and is too wide +(defun corfu-send-shell (&rest _) + "Send completion candidate when inside comint/eshell." + (cond + ((and (derived-mode-p 'eshell-mode) (fboundp 'eshell-send-input)) + (eshell-send-input)) + ((and (derived-mode-p 'comint-mode) (fboundp 'comint-send-input)) + (comint-send-input)))) + +(advice-add #'corfu-insert :after #'corfu-send-shell) + +;; Silence the pcomplete capf, no errors or messages! +(advice-add 'pcomplete-completions-at-point :around #'cape-wrap-silent) + +;; Ensure that pcomplete does not write to the buffer +;; and behaves as a pure `completion-at-point-function'. +(advice-add 'pcomplete-completions-at-point :around #'cape-wrap-purify) + (vertico-mode t) ;; Enable vertico globally (marginalia-mode t) ;; Enable marginalia globally (global-corfu-mode) ;; Enable corfu globally -- cgit 1.4.1