summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--emacs/custom/my-completion.el17
1 files changed, 17 insertions, 0 deletions
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