[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 899055eef5: Fix eshell directory and executable completion on act
From: |
Lars Ingebrigtsen |
Subject: |
master 899055eef5: Fix eshell directory and executable completion on action t |
Date: |
Mon, 19 Sep 2022 04:23:00 -0400 (EDT) |
branch: master
commit 899055eef5b212d63e352ada2ac917d13c033a59
Author: Daniel Pettersson <daniel@dpettersson.net>
Commit: Lars Ingebrigtsen <larsi@gnus.org>
Fix eshell directory and executable completion on action t
* lisp/eshell/em-cmpl.el (eshell--pcomplete-executables): New
function (bug#57905).
(eshell--complete-commands-list): Use it.
Copyright-paperwork-exempt: yes
---
lisp/eshell/em-cmpl.el | 29 ++++++++++++++++++++++++++---
1 file changed, 26 insertions(+), 3 deletions(-)
diff --git a/lisp/eshell/em-cmpl.el b/lisp/eshell/em-cmpl.el
index 822cc94149..ac82e3f225 100644
--- a/lisp/eshell/em-cmpl.el
+++ b/lisp/eshell/em-cmpl.el
@@ -378,6 +378,31 @@ to writing a completion function."
args)
posns)))
+(defun eshell--pcomplete-executables ()
+ "Complete amongst a list of directories and executables.
+
+Wrapper for `pcomplete-executables' or `pcomplete-dirs-or-entries',
+depending on the value of `eshell-force-execution'.
+
+Adds path prefix to candidates independent of `action' value."
+ ;; `pcomplete-entries' returns filenames without path on `action' to
+ ;; use current string directory as done in `completion-file-name-table'
+ ;; when `action' is nil to construct executable candidates.
+ (let ((table (if eshell-force-execution
+ (pcomplete-dirs-or-entries nil #'file-readable-p)
+ (pcomplete-executables))))
+ (lambda (string pred action)
+ (let ((cands (funcall table string pred action)))
+ (if (eq action t)
+ (let ((specdir (file-name-directory string)))
+ (mapcar
+ (lambda (cand)
+ (if (stringp cand)
+ (file-name-concat specdir cand)
+ cand))
+ cands))
+ cands)))))
+
(defun eshell--complete-commands-list ()
"Generate list of applicable, visible commands."
;; Building the commands list can take quite a while, especially over Tramp
@@ -392,9 +417,7 @@ to writing a completion function."
(completion-table-dynamic
(lambda (filename)
(if (file-name-directory filename)
- (if eshell-force-execution
- (pcomplete-dirs-or-entries nil #'file-readable-p)
- (pcomplete-executables))
+ (eshell--pcomplete-executables)
(let* ((paths (eshell-get-path))
(cwd (file-name-as-directory
(expand-file-name default-directory)))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master 899055eef5: Fix eshell directory and executable completion on action t,
Lars Ingebrigtsen <=