emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 28a9438169f: Fix expansion of globs that contain a ~USER referenc


From: Jim Porter
Subject: master 28a9438169f: Fix expansion of globs that contain a ~USER reference
Date: Tue, 28 Mar 2023 00:04:57 -0400 (EDT)

branch: master
commit 28a9438169f379cea6d79fb480a85fc56ad666f4
Author: Jim Porter <jporterbugs@gmail.com>
Commit: Jim Porter <jporterbugs@gmail.com>

    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".
---
 lisp/eshell/em-dirs.el | 11 ++++++++++-
 lisp/eshell/em-glob.el | 10 ----------
 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 ()



reply via email to

[Prev in Thread] Current Thread [Next in Thread]