From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Michael Albinus Newsgroups: gmane.emacs.bugs Subject: bug#65685: 29.1; Inconsistent behavior of quoted file name "/:~" across platforms Date: Tue, 03 Oct 2023 13:22:10 +0200 Message-ID: <8734yshrx9.fsf@gmx.de> References: <156539f1-a26e-848b-16b9-8c12ea46f321@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="20707"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 65685@debbugs.gnu.org To: Jim Porter Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Oct 03 13:23:13 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qndUf-00050Q-61 for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 03 Oct 2023 13:23:13 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qndUG-0007vb-1I; Tue, 03 Oct 2023 07:22:48 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qndUD-0007v5-TH for bug-gnu-emacs@gnu.org; Tue, 03 Oct 2023 07:22:45 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qndUD-0001Ff-LR for bug-gnu-emacs@gnu.org; Tue, 03 Oct 2023 07:22:45 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qndUU-00048j-DI for bug-gnu-emacs@gnu.org; Tue, 03 Oct 2023 07:23:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Michael Albinus Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 03 Oct 2023 11:23:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 65685 X-GNU-PR-Package: emacs Original-Received: via spool by 65685-submit@debbugs.gnu.org id=B65685.169633215715870 (code B ref 65685); Tue, 03 Oct 2023 11:23:02 +0000 Original-Received: (at 65685) by debbugs.gnu.org; 3 Oct 2023 11:22:37 +0000 Original-Received: from localhost ([127.0.0.1]:38956 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qndU5-00047u-9l for submit@debbugs.gnu.org; Tue, 03 Oct 2023 07:22:37 -0400 Original-Received: from mout.gmx.net ([212.227.15.19]:44111) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qndU3-00047b-4P for 65685@debbugs.gnu.org; Tue, 03 Oct 2023 07:22:36 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1696332131; x=1696936931; i=michael.albinus@gmx.de; bh=UGXuvHblmCDpTThZCq1GVcOpAsfA5SONaXImr/va4yg=; h=X-UI-Sender-Class:From:To:Cc:Subject:In-Reply-To:References:Date; b=Y0ONCyKLE/hDTDzi5VfqQtr6HyS/QxTDeubcwZZRdhZdr9h+GTAJlgr1+lmZvChFEWlb5OHtkTP optAZO7C3pjss8YMHM6MRDjaAuS4pOUTif3H2PFdCbaeAtZM6eBW8CoB5M/pkS4DfWvmWbDox81v1 ZaugBxYng0Inwx25LmuhYq6Y1/ocZ5rVry34tI4KmXGrh+PrKBZ5JCwUxSBapQygUPM/Udyb8L36O WlZiE/F/9efkaWLkS2wQpFcfpmFBQDj53jyuRXpRQXGC4TJFPZiWMT8AiVn0st49h0rCJXlECvXVZ ni6dvEhJckoDs8OvD6KwsgmyHSois5hvZHRw== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Original-Received: from gandalf.gmx.de ([185.89.39.30]) by mail.gmx.net (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MZkpR-1r9nIC0I91-00Wo3L; Tue, 03 Oct 2023 13:22:11 +0200 In-Reply-To: <156539f1-a26e-848b-16b9-8c12ea46f321@gmail.com> (Jim Porter's message of "Fri, 1 Sep 2023 12:22:09 -0700") X-Provags-ID: V03:K1:oZZYqlhp7dhsOlT5NguxDAH4aDx5Io8xKxesirmHPvPi6eNDLdQ TXYQAtjNXDHtdZTjMD8Vm1KoQ7ttX9s06Zc0gcXHRVr8Q+ppRlhAHgPQqxZUlL/4y35ip9+ qg0hv1EdWQRsMeZC22FMHUuCOFTGHmpdCPSBpzExZATEbySpfT3a1g0qMP+9mOIueu0GVj9 7BN31F9ivsEM2ZPTqWuRg== UI-OutboundReport: notjunk:1;M01:P0:jowEwjIyQnc=;4VUP1fGzdKT+Jw1lyfJl9r5YJAV f8Z3kj+AUA0LAXrpK0H8qiDDIUu9eh4h0x0+b/t60Y7K3ZmtIVi1tgL4NbgXW87jafryBD4aj fwxF9Kh69Dal6its+cqgn+8/Zjgrxqm4TCzE8Wgk2DSM2Gefyi5fprtRL/owgc9OOuL0VNmCn tgGuHVY+kASFsME83uinBdr1VrLrnnglq//C7oDgYFUxzCyH08HsBqtNMx9ZDaeDmu5Yl/x0/ vdJenTR8oLhAFB+CebR4IkcAjTJPaBz+vo9ugHGTUfGrRFggUoQJkbbz4EXV8nlmuT+2ussbv aOGspBXFQczfI+mYpvXZfY+HtWqJLSMChndJnDjP4Vhz1R2/A0e/n+xvC1IFP+3Dpy+IzShR4 gjx441sjtjVLg/9So3P8kA8vQ0dOc9aFu9B/jChLphRhBIPRzD++8O14XXtcIEHLqxpFZ6Va3 iBLVJb2A+f/U+cjqX4y3jWFzue9QZ3/ncIJamaUNahExjUYykVqkiw/NqfCHu7Q2PmYUzC/TF iAjGUx9/Ys4ObQlyNNb+2kihVQBWK8AyHLSnaVqowIQcyQspeV4q7bUUnQK/JjsWXrqBqSypc +BSVo5XdA4dOu3RemnZoQ8Ibbp7GjB68pVkDSknNRAHqooZXZDeQxC08N1ngdq0OdaGwHTjtp CDRZxA0bXJe4t6dYigPrV3Ngzj/L2fkb7ZDH6Jk2977qh5TV/q98f/NV7kXOAr/10pqHRE2xx foSDo7htyEIN3HxcZX82imKtzI+N6BnuAW2L9CHdImT4nxlq9+TAudH0b4AgYVIENztd5Av2 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:271709 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Jim Porter 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: > >> =E2=80=98/:=E2=80=99 can also prevent =E2=80=98~=E2=80=99 from being tre= ated as a special character >> for a user=E2=80=99s 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. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment 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))) --=-=-=--