diff options
Diffstat (limited to 'README.org')
| -rw-r--r-- | README.org | 24 |
1 files changed, 6 insertions, 18 deletions
@@ -315,19 +315,11 @@ When pressing =RET= while the Corfu popup is visible, the ~corfu-insert~ command will be invoked. This command does inserts the currently selected candidate, but it does not send the prompt input to Eshell or the Comint process. Therefore you often have to press =RET= twice which feels like an unnecessary double -confirmation. Fortunately it is easy to improve this! In my configuration I -define the advice ~corfu-send-shell~ which sends the candidate after insertion. +confirmation. Fortunately it is easy to improve this by using the command +~corfu-send~ instead. #+begin_src emacs-lisp -(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) +(keymap-set corfu-map "RET" #'corfu-send) #+end_src Shell completion uses the flexible Pcomplete mechanism internally, which allows @@ -438,19 +430,15 @@ modes. ;; Option 1: Unbind RET completely ;;; ("RET" . nil) ;; Option 2: Use RET only in shell modes - ("RET" . (menu-item "" nil :filter corfu-insert-shell-filter))) + ("RET" . (menu-item "" nil :filter corfu-send-filter))) :init (global-corfu-mode)) -(defun corfu-insert-shell-filter (&optional _) +(defun corfu-send-filter (&optional _) "Insert completion candidate and send when inside comint/eshell." (when (or (derived-mode-p 'eshell-mode) (derived-mode-p 'comint-mode)) - (lambda () - (interactive) - (corfu-insert) - ;; `corfu-send-shell' was defined above - (corfu-send-shell)))) + #'corfu-send)) #+end_src ** TAB-and-Go completion |
