mirror of
https://git.savannah.gnu.org/git/emacs.git
synced 2025-01-24 19:03:29 +00:00
(eshell--complete-commands-list): Fix regression in fix to bug#48995
Copyright-Paperwork-Exempt: Yes * lisp/eshell/em-cmpl.el (eshell--complete-commands-list): Fix misuse of `completion-table-dynamic` when completing a file name.
This commit is contained in:
parent
ea1bb26315
commit
9715715ac1
@ -378,31 +378,6 @@ to writing a completion function."
|
|||||||
args)
|
args)
|
||||||
posns)))
|
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 ()
|
(defun eshell--complete-commands-list ()
|
||||||
"Generate list of applicable, visible commands."
|
"Generate list of applicable, visible commands."
|
||||||
;; Building the commands list can take quite a while, especially over Tramp
|
;; Building the commands list can take quite a while, especially over Tramp
|
||||||
@ -413,11 +388,19 @@ Adds path prefix to candidates independent of `action' value."
|
|||||||
;; we complete. Adjust `pcomplete-stub' accordingly!
|
;; we complete. Adjust `pcomplete-stub' accordingly!
|
||||||
(if (and (> (length pcomplete-stub) 0)
|
(if (and (> (length pcomplete-stub) 0)
|
||||||
(eq (aref pcomplete-stub 0) eshell-explicit-command-char))
|
(eq (aref pcomplete-stub 0) eshell-explicit-command-char))
|
||||||
(setq pcomplete-stub (substring pcomplete-stub 1)))))
|
(setq pcomplete-stub (substring pcomplete-stub 1))))
|
||||||
(completion-table-dynamic
|
(filename (pcomplete-arg)))
|
||||||
(lambda (filename)
|
;; Do not use `completion-table-dynamic' when completing a command file
|
||||||
(if (file-name-directory filename)
|
;; name since it doesn't know about boundaries and would end up doing silly
|
||||||
(eshell--pcomplete-executables)
|
;; 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))
|
(let* ((paths (eshell-get-path))
|
||||||
(cwd (file-name-as-directory
|
(cwd (file-name-as-directory
|
||||||
(expand-file-name default-directory)))
|
(expand-file-name default-directory)))
|
||||||
|
Loading…
Reference in New Issue
Block a user