From: Michael Albinus <michael.albinus@gmx.de>
To: Jim Porter <jporterbugs@gmail.com>
Cc: 65685@debbugs.gnu.org
Subject: bug#65685: 29.1; Inconsistent behavior of quoted file name "/:~" across platforms
Date: Tue, 03 Oct 2023 13:22:10 +0200 [thread overview]
Message-ID: <8734yshrx9.fsf@gmx.de> (raw)
In-Reply-To: <156539f1-a26e-848b-16b9-8c12ea46f321@gmail.com> (Jim Porter's message of "Fri, 1 Sep 2023 12:22:09 -0700")
[-- Attachment #1: Type: text/plain, Size: 1714 bytes --]
Jim Porter <jporterbugs@gmail.com> writes:
Hi Jim,
> To see this in action, run 'emacs -Q "/:~"' on both GNU/Linux and
> MS-Windows.[1] On GNU/Linux, this opens a dired buffer for the user's
> home directory. On MS-Windows, it opens a buffer for a new file named
> tilde.
>
> According to the Emacs manual:
>
>> ‘/:’ can also prevent ‘~’ from being treated as a special character
>> for a user’s home directory. For example, /:/tmp/~hack refers to a
>> file whose name is ~hack in directory /tmp.
> I'd interpret this to mean that the MS-Windows behavior is
> correct. However, the example doesn't specifically say what should
> happen when the tilde comes immediately after the "/:". On the very
> rare occasions you might need it, you can always spell "a file named
> tilde in the current directory" like "/:./~".
>
> This is relevant to some future Eshell changes I'm considering[2],
> where (I think) I'd like "/:~" to mean "the user's local home
> directory, even when default-directory is remote". In light of that,
> my selfish preference is that we keep the GNU/Linux behavior and
> standardize it across all systems. However, we could standardize the
> MS-Windows behavior instead; I'd then just have to call out the
> different Eshell semantics in the Eshell manual.
>
> [1] You can see this inconsistency with other commands too, like "M-x
> cd RET /:~ RET".
>
> [2] https://lists.gnu.org/archive/html/emacs-devel/2023-08/msg01244.html
I've played a little bit with file-name-non-special. The result is the
appended patch, which expands always "/:~" to the local home
directory. Could you pls check whether it works for you?
Best regards, Michael.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Type: text/x-patch, Size: 1940 bytes --]
diff --git a/lisp/files.el b/lisp/files.el
index ddae097f1d1..53314752604 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -8317,13 +8317,12 @@ file-name-non-special
;; Get a list of the indices of the args that are file names.
(file-arg-indices
(cdr (or (assq operation
- '(;; The first eight are special because they
+ '(;; The first seven are special because they
;; return a file name. We want to include
;; the /: in the return value. So just
;; avoid stripping it in the first place.
(abbreviate-file-name)
(directory-file-name)
- (expand-file-name)
(file-name-as-directory)
(file-name-directory)
(file-name-sans-versions)
@@ -8332,6 +8331,10 @@ file-name-non-special
;; `identity' means just return the first
;; arg not stripped of its quoting.
(substitute-in-file-name identity)
+ ;; `expand-file-name' shall do special case
+ ;; for the first argument starting with
+ ;; "/:~". (Bug#65685)
+ (expand-file-name expand-file-name)
;; `add' means add "/:" to the result.
(file-truename add 0)
;;`insert-file-contents' needs special handling.
@@ -8387,6 +8390,10 @@ file-name-non-special
(let ((tramp-mode (and tramp-mode (eq method 'local-copy))))
(pcase method
('identity (car arguments))
+ ('expand-file-name
+ (when (string-prefix-p "/:~" (car arguments))
+ (setcar arguments (file-name-unquote (car arguments) t)))
+ (apply operation arguments))
('add (file-name-quote (apply operation arguments) t))
('buffer-file-name
(let ((buffer-file-name (file-name-unquote buffer-file-name t)))
next prev parent reply other threads:[~2023-10-03 11:22 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-01 19:22 bug#65685: 29.1; Inconsistent behavior of quoted file name "/:~" across platforms Jim Porter
2023-10-03 11:22 ` Michael Albinus [this message]
2023-10-10 4:27 ` Jim Porter
2023-10-13 14:26 ` Michael Albinus
2023-10-14 0:31 ` Jim Porter
2023-10-14 7:42 ` Michael Albinus
2023-10-14 7:42 ` Eli Zaretskii
2023-10-14 7:48 ` Michael Albinus
2023-10-14 10:56 ` Michael Albinus
2023-10-14 11:25 ` Eli Zaretskii
2023-10-14 14:29 ` Michael Albinus
2023-10-14 16:48 ` Michael Albinus
2023-10-14 19:07 ` Eli Zaretskii
2023-10-15 7:11 ` Michael Albinus
2023-10-15 9:36 ` Eli Zaretskii
2023-10-15 9:50 ` Michael Albinus
2023-10-15 9:58 ` Eli Zaretskii
2023-10-15 10:29 ` Michael Albinus
2023-10-15 20:12 ` Mattias Engdegård
2023-10-16 7:07 ` Michael Albinus
2023-10-16 7:30 ` Mattias Engdegård
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8734yshrx9.fsf@gmx.de \
--to=michael.albinus@gmx.de \
--cc=65685@debbugs.gnu.org \
--cc=jporterbugs@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).