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.
This commit is contained in:
Daniel - 2021-04-16 14:23:32 +02:00
parent 5348856628
commit 9a1dbf89f4
No known key found for this signature in database
GPG Key ID: 1C7071A75BB72D64
1 changed files with 18 additions and 0 deletions

18
init.el
View File

@ -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