]> git.eshelyaron.com Git - emacs.git/commit
Make Eshell's "which" command extensible
authorJim Porter <jporterbugs@gmail.com>
Thu, 30 May 2024 02:21:09 +0000 (19:21 -0700)
committerEshel Yaron <me@eshelyaron.com>
Thu, 30 May 2024 14:28:38 +0000 (16:28 +0200)
commit8d52bc5873e8d430a8e9f0525544f6b6de1813b4
tree0dff213f2852371d939d7a43a11b6c09041aa80b
parent16ab190fc53c3f445a6fc30dec33d6660c5af5c7
Make Eshell's "which" command extensible

Since 'eshell-named-command-hook' already makes execution of commands
extensible, "which" should be too.  This makes sure that "which" returns
the right result for quoted commands like "/:cat".

* lisp/eshell/em-alias.el (eshell-aliases-file): Allow it to be nil.
(eshell-read-aliases-list, eshell-write-aliases-list): Check if
'eshell-aliases-file' is nil.
(eshell-maybe-replace-by-alias--which): New function...
(eshell-maybe-replace-by-alias): ... use it.

* lisp/eshell/esh-cmd.el (eshell-named-command-hook): Update docstring.
(eshell/which): Make extensible.
(eshell--find-plain-lisp-command, eshell-plain-command--which): New
functions.
(eshell-plain-command): Use 'eshell--find-plain-lisp-command'.

* lisp/eshell/esh-ext.el (eshell-explicit-command--which): New
function...
(eshell-explicit-command): ... unise it.
(eshell-quoted-file-command--which): New function...
(eshell-quoted-file-command): ... use it.
(eshell-external-command--which): New function.

* test/lisp/eshell/esh-cmd-tests.el
(esh-cmd-test/which/plain/eshell-builtin)
(esh-cmd-test/which/plain/external-program)
(esh-cmd-test/which/plain/not-found, esh-cmd-test/which/alias)
(esh-cmd-test/which/explicit, esh-cmd-test/which/explicit/not-found)
(esh-cmd-test/which/quoted-file)
(esh-cmd-test/which/quoted-file/not-found): New tests.

* test/lisp/eshell/eshell-tests-helpers.el (with-temp-eshell-settings):
Don't load or save aliases.
(eshell-command-result--match,eshell-command-result--match-explainer)
(eshell-command-result-match): New functions.

(cherry picked from commit 1df3554f0766c91a9452cd40f74f469ed612eda6)
lisp/eshell/em-alias.el
lisp/eshell/esh-cmd.el
lisp/eshell/esh-ext.el
test/lisp/eshell/esh-cmd-tests.el
test/lisp/eshell/eshell-tests-helpers.el