]> git.eshelyaron.com Git - emacs.git/commit
Improve correctness of Eshell globs when using escape characters
authorJim Porter <jporterbugs@gmail.com>
Mon, 21 Oct 2024 22:41:42 +0000 (15:41 -0700)
committerEshel Yaron <me@eshelyaron.com>
Fri, 1 Nov 2024 13:21:46 +0000 (14:21 +0100)
commitcc9f6d61691ad75dce7d5e299e1d6aa6d9f45ad8
treed740a229d0c3fc9b6c59952513dff0e0d50bbd52
parentc671f3825ffbdfb4b1ca726bd325de58c52b16f9
Improve correctness of Eshell globs when using escape characters

This new implementation opts *in* to treating characters as glob
characters, rather than opting out.  This reduces the need to coordinate
with other parts of Eshell and should be harder to break (bug#74033).

* lisp/eshell/em-glob.el (eshell-parse-glob-chars): Return the
propertized globbing character directly.
(eshell--propertize-glob, eshell--glob-char-p)
(eshell--contains-glob-char-p, eshell--all-glob-chars-p): New functions.
(eshell-glob-p): Make obsolete.
(eshell-glob-regexp, eshell-glob-convert-1, eshell-glob-convert): Check
for 'eshell-glob-char' property.
(eshell-extended-glob): Remove text properties when returning no match.
(eshell--glob-anything): New constant.
(eshell-glob-entries): Propertize "*" to treat it as a glob.

* lisp/eshell/em-ls.el (eshell-ls--expand-wildcards): New function...
(eshell-ls--insert-directory): ... use it.

* test/lisp/eshell/em-glob-tests.el: Use 'eshell--propertize-glob' in
tests.
(em-glob-test/convert/literal-characters)
(em-glob-test/convert/mixed-literal-characters): New tests.

* lisp/eshell/em-glob.el (eshell-expand-glob): Rename from
'eshell-extended-glob'.  Update callers.
(eshell-extended-glob): New function to expand a GLOB that hasn't been
propertized yet, for use outside of Eshell command forms.
(eshell-parse-glob-chars): Return the propertized globbing character
directly.
(eshell-parse-glob-string, eshell--glob-char-p)
(eshell--contains-glob-char-p, eshell--all-glob-chars-p): New functions.
(eshell-glob-regexp, eshell-glob-convert-1, eshell-glob-convert): Check
for 'eshell-glob-char' property.
(eshell-glob-p): Make obsolete.
(eshell--glob-anything): New constant...
(eshell-glob-entries): ... use it.

* lisp/eshell/em-ls.el (eshell-ls--expand-wildcards): New function...
(eshell-ls--insert-directory): ... use it.

* test/lisp/eshell/em-glob-tests.el: Use 'eshell-parse-glob-string in
tests.
(em-glob-test/convert/literal-characters)
(em-glob-test/convert/mixed-literal-characters): New tests.

(cherry picked from commit 9682d385c103a9ee1afdeaf3e1711fa3d2001eee)
lisp/eshell/em-glob.el
lisp/eshell/em-ls.el
test/lisp/eshell/em-glob-tests.el