From eb70b20edda10023736331f948b5a47349b22315 Mon Sep 17 00:00:00 2001 From: Franck Cuny Date: Wed, 7 Jun 2023 11:20:10 -0700 Subject: send completion candidate when inside eshell Change-Id: I9f73b17723fee7a241c40d41c9b399949e26d4a9 --- init.org | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'init.org') diff --git a/init.org b/init.org index 34f81f7..958909d 100644 --- a/init.org +++ b/init.org @@ -381,6 +381,15 @@ Automatically revert buffers if the file has changed on disk. ("M-d" . corfu-info-documentation) ("M-l" . corfu-info-location) ("M-." . corfu-move-to-minibuffer)) + :preface + ;; see https://github.com/minad/corfu#completing-in-the-eshell-or-shell + (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)))) :custom ;; Works with `indent-for-tab-command'. Make sure tab doesn't indent when you ;; want to perform completion @@ -413,6 +422,14 @@ Automatically revert buffers if the file has changed on disk. ;; Other (corfu-echo-documentation nil) ; Already use corfu-popupinfo + :init + ;; see https://github.com/minad/corfu#completing-in-the-eshell-or-shell + (add-hook 'eshell-mode-hook + (lambda () + (setq-local corfu-auto nil) + (corfu-mode))) + (advice-add #'corfu-insert :after #'corfu-send-shell) + :config (global-corfu-mode)) #+end_src -- cgit v1.2.3