unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: "Ryan C. Thompson" <rct@thompsonclan.org>
To: 19412@debbugs.gnu.org
Subject: bug#19412: 24.3; ido-write-file sometimes writes to a different directory than, it says it will
Date: Sun, 3 Nov 2019 14:48:15 -0800	[thread overview]
Message-ID: <abbcae10-8b42-f94f-82a9-a700547c7a84@thompsonclan.org> (raw)
In-Reply-To: <CAO9hiFVLErQ19pYmF6cO8Ef7dCAM1hPbtMi31-meB4S6XBoF9w@mail.gmail.com>

I believe I have discovered the cause of this bug. It can be reproduced 
by evaluating the following code and then hitting RET:

(read-file-name-default "Write file: " "/tmp/" "~/mumble.frotz" nil nil nil)

This will return "~/mumble.frotz" rather than "/tmp/". Ido triggers this 
issue by causing "read-file-name-default" to be called with arguments 
like the above when triggered to fall back to non-ido completion as 
described in the inital report. The crux of the issue is that the 
initial directory, "/tmp/", is treated as *not* user-entered, so 
pressing RET on it returns the default filename instead (which is 
populated from the buffer file name).

This is not trivial to fix, because ido isn't calling 
"read-file-name-default" directly. In the example given, it's 
let-binding "default-directory" to "/tmp/" and then doing:

(call-interactively 'write-file)

And then the interactive form calls:

(read-file-name "Write file: ")

which then picks up DIR and DEFAULT-FILENAME from "default-directory" 
and "buffer-file-name" respectively. So this isn't a case of just fixing 
a function call somewhere. One possible solution would be to also 
let-bind "buffer-file-name" to nil, in which case DEFAULT-FILENAME gets 
set to DIR. That would work for the case of "write-file", but I don't 
know if it would work for other functions that read file names.

Lastly, I'm guessing that the original reporter ran into this issue 
because they were using C-f RET to select "/tmp/" within ido completion, 
since RET would just select the first file or subdirectory on the list. 
They should be using C-j to do that.

I might add a hack to my ido-completing-read-plus package to fix this 
edge case, if I can figure out a reasonably clean way to fix it.






  reply	other threads:[~2019-11-03 22:48 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-19 20:21 bug#19412: 24.3; ido-write-file sometimes writes to a different directory than it says it will Don Morrison
2019-11-03 22:48 ` Ryan C. Thompson [this message]
2019-11-04 14:52   ` bug#19412: 24.3; ido-write-file sometimes writes to a different directory than, " Ryan C. Thompson
2019-11-04 15:55     ` Ryan C. Thompson
2020-03-11 16:46       ` Ryan C. Thompson
2020-08-12 16:44         ` Stefan Kangas
2021-01-10 23:12           ` Ryan C. Thompson
2021-01-11 14:14             ` Lars Ingebrigtsen
2021-01-11 14:28               ` Ryan C. Thompson
2021-01-11 18:43                 ` Lars Ingebrigtsen
2021-01-11 18:50                   ` Ryan C. Thompson

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=abbcae10-8b42-f94f-82a9-a700547c7a84@thompsonclan.org \
    --to=rct@thompsonclan.org \
    --cc=19412@debbugs.gnu.org \
    /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).