From: Jim Porter Date: Tue, 28 Mar 2023 03:58:55 +0000 (-0700) Subject: Fix expansion of globs that contain a ~USER reference X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=28a9438169f379cea6d79fb480a85fc56ad666f4;p=emacs.git Fix expansion of globs that contain a ~USER reference This regressed from the fix to bug#28064, and was discovered here: . * 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". --- 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 ()