bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#28513: 25.1; ido insists on guessing the wrong directory


From: Dmitry Gutov
Subject: bug#28513: 25.1; ido insists on guessing the wrong directory
Date: Tue, 15 Dec 2020 04:23:29 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0

On 14.12.2020 18:42, Lars Ingebrigtsen wrote:

Okay, but why does the fallback command end up trying to overwrite the
original file, even though, in your scenario, input ends with /vc/?

In essence, it's doing this (if we say we've navigated to "/tmp/" before
`C-f'):

(let ((default-directory "/tmp/"))
   (call-interactively 'write-file))

This gives you a prompt of

Write file: /tmp/

If you then hit RET, then:



That is, hitting RET in the `write-file' dialogue gives you
buffer-file-name, and ignores whatever is in the prompt.  This seems
contrary to what the doc string says:

---
Interactively, prompt for FILENAME.
If you specify just a directory name as FILENAME, that means to write
to a file in that directory.  In this case, the base name of the file
is the same as that of the file visited in the buffer, or the buffer
name sans leading directories, if any, if the buffer is not already
visiting a file.
---

So this isn't an ido problem at all -- it's a bug in `write-file'?  Or
rather...

(let ((default-directory "/tmp/")) (read-file-name "Foo: "))

If you just hit RET there, it'll return `buffer-file-name'.

But there is a difference between having default-directory set to /tmp/ and typing /tmp/ yourself.

I think when the user calls the escape hatch command, they don't expect their current input to translate to the new default-directory value. Rather, it should be the input in the new prompt.

Might not be easy to fix, however, given that the current code in Ido tries to do that in the most generic way:

        (let ((default-directory ido-current-directory)
              (read-file-name-function nil))
          (setq this-command (or ido-fallback fallback 'find-file))
          ...
          (call-interactively this-command))

And since that this feature is an escape hatch and, say, fido-mode (which everyone will migrate to any year now) shouldn't need anything like it, maybe it's not worth the effort fixing.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]