summaryrefslogtreecommitdiff
path: root/lisp/eshell
diff options
context:
space:
mode:
authorStefan Kangas <stefankangas@gmail.com>2023-02-02 06:30:28 +0100
committerStefan Kangas <stefankangas@gmail.com>2023-02-02 06:30:28 +0100
commit0571a3cc87f7c449796bb3eef38af4b2719b0bdf (patch)
tree18b41402977f6200ca563b348e98ca3a82d04203 /lisp/eshell
parentc831f55b234725a99f908656f996f3e6addc8825 (diff)
parent9715715ac163fc0b3ce6e170eb9c74b5f4ad8267 (diff)
downloademacs-0571a3cc87f7c449796bb3eef38af4b2719b0bdf.tar.gz
Merge from origin/emacs-29
9715715ac16 (eshell--complete-commands-list): Fix regression in fix t... ea1bb263153 * doc/emacs/basic.texi (Repeating): Mention describe-repe... f91bf9df892 Unbreak the MS-Windows build
Diffstat (limited to 'lisp/eshell')
-rw-r--r--lisp/eshell/em-cmpl.el43
1 files changed, 13 insertions, 30 deletions
diff --git a/lisp/eshell/em-cmpl.el b/lisp/eshell/em-cmpl.el
index acbf206a3c6..2439f1ed804 100644
--- a/lisp/eshell/em-cmpl.el
+++ b/lisp/eshell/em-cmpl.el
@@ -402,31 +402,6 @@ 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
@@ -437,11 +412,19 @@ Adds path prefix to candidates independent of `action' value."
;; we complete. Adjust `pcomplete-stub' accordingly!
(if (and (> (length pcomplete-stub) 0)
(eq (aref pcomplete-stub 0) eshell-explicit-command-char))
- (setq pcomplete-stub (substring pcomplete-stub 1)))))
- (completion-table-dynamic
- (lambda (filename)
- (if (file-name-directory filename)
- (eshell--pcomplete-executables)
+ (setq pcomplete-stub (substring pcomplete-stub 1))))
+ (filename (pcomplete-arg)))
+ ;; Do not use `completion-table-dynamic' when completing a command file
+ ;; name since it doesn't know about boundaries and would end up doing silly
+ ;; things like adding a SPC char when completing to "/usr/sbin/".
+ ;;
+ ;; If you work on this function, be careful not to reintroduce bug#48995.
+ (if (file-name-directory filename)
+ (if eshell-force-execution
+ (pcomplete-dirs-or-entries nil #'file-readable-p)
+ (pcomplete-executables))
+ (completion-table-dynamic
+ (lambda (filename)
(let* ((paths (eshell-get-path))
(cwd (file-name-as-directory
(expand-file-name default-directory)))