]> git.eshelyaron.com Git - emacs.git/commitdiff
Don't over-normalize file names starting with "~" in Eshell
authorJim Porter <jporterbugs@gmail.com>
Sun, 12 Mar 2023 07:53:34 +0000 (23:53 -0800)
committerJim Porter <jporterbugs@gmail.com>
Sun, 19 Mar 2023 02:24:15 +0000 (19:24 -0700)
Previously, this would call 'expand-file-name' on the file name, but
that normalizes the value, turning something like "~/." into
"/home/user".  As a result, Pcomplete didn't work for dotfiles after
"~/" (bug#28064).

* lisp/eshell/em-dirs.el (eshell-expand-user-reference): New
function...
(eshell-expand-user-reference): ... use it.

lisp/eshell/em-dirs.el

index eb679b80cb58429e1487aa8707ee4013d96a4914..4bc6342d42267d45531fd709074a9570940bc1f7 100644 (file)
@@ -253,11 +253,17 @@ 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)
+  "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-parse-user-reference ()
   "An argument beginning with ~ is a filename to be expanded."
   (when (and (not eshell-current-argument)
-            (eq (char-after) ?~))
-    (add-to-list 'eshell-current-modifiers 'expand-file-name)
+             (eq (char-after) ?~))
+    (add-to-list 'eshell-current-modifiers #'eshell-expand-user-reference)
     (forward-char)
     (char-to-string (char-before))))