summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Porter <jporterbugs@gmail.com>2023-03-27 20:58:55 -0700
committerJim Porter <jporterbugs@gmail.com>2023-03-27 21:04:27 -0700
commit28a9438169f379cea6d79fb480a85fc56ad666f4 (patch)
tree8b0c74c1cd4d8877163e0f21c24a4de95f7a0f89
parent66b4394461589d0db8690b7971000f687bd3ad57 (diff)
downloademacs-28a9438169f379cea6d79fb480a85fc56ad666f4.tar.gz
Fix expansion of globs that contain a ~USER reference
This regressed from the fix to bug#28064, and was discovered here: <https://lists.gnu.org/archive/html/bug-gnu-emacs/2023-03/msg01744.html>. * lisp/eshell/em-dirs.el (eshell-expand-user-reference): Let FILE be a list, and move the implementation to... (eshell-expand-user-reference-1): ... here. * lisp/eshell/em-glob.el (eshell-add-glob-modifier): Remove special handling for expanding user references; it's better to keep it in "em-dirs.el".
-rw-r--r--lisp/eshell/em-dirs.el11
-rw-r--r--lisp/eshell/em-glob.el10
2 files changed, 10 insertions, 11 deletions
diff --git a/lisp/eshell/em-dirs.el b/lisp/eshell/em-dirs.el
index 4bc6342d422..5284df9ab59 100644
--- a/lisp/eshell/em-dirs.el
+++ b/lisp/eshell/em-dirs.el
@@ -253,12 +253,21 @@ Thus, this does not include the current directory.")
(throw 'eshell-replace-command
(eshell-parse-command "cd" (flatten-tree args)))))
-(defun eshell-expand-user-reference (file)
+(defun eshell-expand-user-reference-1 (file)
"Expand a user reference in FILE to its real directory name."
(replace-regexp-in-string
(rx bos (group "~" (*? anychar)) (or "/" eos))
#'expand-file-name file))
+(defun eshell-expand-user-reference (file)
+ "Expand a user reference in FILE to its real directory name.
+FILE can be either a string or a list of strings to expand."
+ ;; If the argument was a glob pattern, then FILE is a list, so
+ ;; expand each element of the glob's resulting list.
+ (if (listp file)
+ (mapcar #'eshell-expand-user-reference-1 file)
+ (eshell-expand-user-reference-1 file)))
+
(defun eshell-parse-user-reference ()
"An argument beginning with ~ is a filename to be expanded."
(when (and (not eshell-current-argument)
diff --git a/lisp/eshell/em-glob.el b/lisp/eshell/em-glob.el
index 8a2ba13b2ad..9402df43065 100644
--- a/lisp/eshell/em-glob.el
+++ b/lisp/eshell/em-glob.el
@@ -145,16 +145,6 @@ This mimics the behavior of zsh if non-nil, but bash if nil."
(defun eshell-add-glob-modifier ()
"Add `eshell-extended-glob' to the argument modifier list."
- (when (memq 'expand-file-name eshell-current-modifiers)
- (setq eshell-current-modifiers
- (delq 'expand-file-name eshell-current-modifiers))
- ;; if this is a glob pattern than needs to be expanded, then it
- ;; will need to expand each member of the resulting glob list
- (add-to-list 'eshell-current-modifiers
- (lambda (list)
- (if (listp list)
- (mapcar 'expand-file-name list)
- (expand-file-name list)))))
(add-to-list 'eshell-current-modifiers 'eshell-extended-glob))
(defun eshell-parse-glob-chars ()