Remove delay when sending freshly completed input in eshell

See comment in code for more explanation.
This commit is contained in:
Daniel - 2020-11-19 19:43:28 +01:00
parent b39894e6a6
commit 4555e0f789
No known key found for this signature in database
GPG Key ID: 1C7071A75BB72D64
1 changed files with 17 additions and 0 deletions

17
init.el
View File

@ -2530,6 +2530,23 @@ With given ARG, display files in `db/important-document-path."
(lambda ()
(setq pcomplete-ignore-case nil))))
;; Sometimes, when completing path names and immediately
;; hitting RET, `completion-in-region-mode' still seems to be
;; active; this often happens when calling cd. Then,
;; `post-command-hook' still contains
;; `completion-in-region--postch', which calls some `pcomplete'
;; function to determine whether completion mode should exit.
;; However, after RET (i.e., `eshell-send-input'), we only have
;; an empty prompt, and `pcomplete' just computes all possible
;; functions for completion (doesn't show it, though). This
;; introduces a noticeable amount of delay, which is annoying.
;; Expliticly disabling `completion-in-region-mode' before
;; sending input seems to alleviate the problem.
(advice-add 'eshell-send-input
:before #'(lambda (&rest _)
"Disable completion-in-region-mode before sending input."
(when completion-in-region-mode
(completion-in-region-mode -1))))
(require 'db-eshell)))