From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Eli Zaretskii <eliz@gnu.org>
Cc: tino.calancha@gmail.com, 39057@debbugs.gnu.org
Subject: bug#39057: 27.0.60; copy-file interactive VS from lisp disagreement
Date: Wed, 15 Jan 2020 15:35:37 -0500 [thread overview]
Message-ID: <jwvmuaowk51.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <83v9pj8koa.fsf@gnu.org> (Eli Zaretskii's message of "Fri, 10 Jan 2020 16:12:37 +0200")
> Answering myself: this is a problem with completion routines: when the
> user types a file name that is exactly identical to the default (or
> just presses RET, which is the same), then the completion code in
> read-file-name-internal returns a value that has the trailing slash
> stripped. And we now require a trailing slash to recognize NEWNAME as
> a directory.
The problem seems to be linked to the value "" passed as `initial` to
`read-file-name`, it doesn't show up with a nil value for `initial`.
It seems to come from the following lines at the beginning of
read-file-name-default:
(unless default-filename
(setq default-filename (if initial (expand-file-name initial dir)
buffer-file-name)))
because:
M-: (expand-file-name "" "/tmp/")
=> "/tmp"
`copy-file` uses a "" argument via the `G` interactive code:
case 'F': /* Possibly nonexistent file name. */
args[i] = read_file_name (Qnil, Qnil, Qnil, Qnil);
break;
case 'G': /* Possibly nonexistent file name,
default to directory alone. */
args[i] = read_file_name (Qnil, Qnil, empty_unibyte_string, Qnil);
break;
IOW it uses `G` since otherwise hitting just RET would return the
`buffer-file-name` rather than the `default-directory`.
I propose the patch below.
Stefan
diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el
index 4a33d61afc..e12f7b1156 100644
--- a/lisp/minibuffer.el
+++ b/lisp/minibuffer.el
@@ -3027,8 +3027,13 @@ read-file-name-default
(unless dir (setq dir (or default-directory "~/")))
(unless (file-name-absolute-p dir) (setq dir (expand-file-name dir)))
(unless default-filename
- (setq default-filename (if initial (expand-file-name initial dir)
- buffer-file-name)))
+ (setq default-filename
+ (cond
+ ((null initial) buffer-file-name)
+ ;; Special-case "" because (expand-file-name "" "/tmp/") returns
+ ;; "/tmp" rather than "/tmp/" (bug#39057).
+ ((equal "" initial) dir)
+ (t (expand-file-name initial dir)))))
;; If dir starts with user's homedir, change that to ~.
(setq dir (abbreviate-file-name dir))
;; Likewise for default-filename.
next prev parent reply other threads:[~2020-01-15 20:35 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-09 21:03 bug#39057: 27.0.60; copy-file interactive VS from lisp disagreement Tino Calancha
2020-01-10 7:54 ` Eli Zaretskii
2020-01-10 11:55 ` Tino Calancha
2020-01-10 13:48 ` Eli Zaretskii
2020-01-10 14:12 ` Eli Zaretskii
2020-01-13 18:37 ` Stefan Monnier
2020-01-15 20:35 ` Stefan Monnier [this message]
2020-01-16 14:31 ` Eli Zaretskii
2020-01-16 15:20 ` Stefan Monnier
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=jwvmuaowk51.fsf-monnier+emacs@gnu.org \
--to=monnier@iro.umontreal.ca \
--cc=39057@debbugs.gnu.org \
--cc=eliz@gnu.org \
--cc=tino.calancha@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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.