From 9a1dbf89f4cc39893e10086551f1e3866ca082e9 Mon Sep 17 00:00:00 2001 From: Daniel Borchmann Date: Fri, 16 Apr 2021 14:23:32 +0200 Subject: [PATCH] Never insert terminating space when completing in eshell eshell is using pcomplete as completion meta-framework, which by default will insert the value of `pcomplete-termination-string` to each finished completion. However, when using newer versions of `ivy` for path completion, each completed directory within a path is considered a finished match, and pcomplete will insert a blank. This is annoying, and since we do not require the final blank otherwise, we can equally just disable it. --- init.el | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/init.el b/init.el index 121e75a..8a8b4ac 100644 --- a/init.el +++ b/init.el @@ -2614,6 +2614,24 @@ With given ARG, display files in `db/important-document-path’." (when completion-in-region-mode (completion-in-region-mode -1)))) + ;; After completing partial inputs, pcomplete wants to add an + ;; extra character stored in `pcomplete-termination-string', + ;; which is a space by default. When completing paths, this + ;; leads to spaces being inserted after every directory within + ;; the path, which is annoying. We thus set the value of this + ;; variable locally to an empty string, thus silencing this + ;; bug. A better way to handle this would be to correctly + ;; determine whether the completion is not done yet, by passing + ;; `exact' instead of `finished' to the handlers stored in + ;; `completion-extra-properties'. + + (defun db/set-empty-pcomplete-termination-string () + "Locally set `pcomplete-termination-string' to the empty string." + (setq-local pcomplete-termination-string "")) + + (add-hook 'eshell-mode-hook + #'db/set-empty-pcomplete-termination-string) + (require 'db-eshell))) (use-package with-editor