]> git.eshelyaron.com Git - emacs.git/commit
Avoid parsing some Eshell forms when performing completion
authorJim Porter <jporterbugs@gmail.com>
Tue, 21 Mar 2023 00:25:54 +0000 (17:25 -0700)
committerJim Porter <jporterbugs@gmail.com>
Tue, 28 Mar 2023 19:03:29 +0000 (12:03 -0700)
commitcde38f0df3fa3540ce411a48d95da1c2f1be1b60
tree7cf41e920e16da219f6a2bc26dcb803bc2538916
parentbb088885df7a8e8a32670286a8636db8c6fadcf4
Avoid parsing some Eshell forms when performing completion

During completion, we want to evaluate most Eshell forms
(e.g. variable references), but skip others (e.g. globbing,
subcommands).  For globbing, we want to pass the literal glob to
Pcomplete so it can use the glob for selecting completion candidates.
For subcommands (including Lisp forms), we especially want to avoid
evaluation, since they can produce arbitary side effects!  (Bug#50470)

* lisp/eshell/esh-cmd.el (eshell-allow-commands): New variable...
(eshell-commands-forbidden): New error...
(eshell-named-command, eshell-lisp-command): ... use them.

* lisp/eshell/em-cmpl.el (eshell-complete--eval-argument-form):
Disallow command forms and handle errors ourselves.
(eshell-complete-parse-arguments): Don't parse glob characters.

* test/lisp/eshell/em-cmpl-tests.el
(em-cmpl-test/parse-arguments/unevaluated-subcommand)
(em-cmpl-test/parse-arguments/unevaluated-lisp-form)
(em-cmpl-test/parse-arguments/unevaluated-inner-subcommand)
(em-cmpl-test/file-completion/glob, em-cmpl-test/command-completion)
(em-cmpl-test/subcommand-completion): New tests.
(em-cmpl-test/parse-arguments/pipeline): Remove superfluous
let-binding.
(em-cmpl-test/file-completion/after-list): Use a list variable rather
than a subexpression; the latter is no longer evaluated during
completion.
(em-cmpl-test/lisp-function-completion): Check "$(func)" syntax.
lisp/eshell/em-cmpl.el
lisp/eshell/esh-cmd.el
test/lisp/eshell/em-cmpl-tests.el