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

From: Lars Ingebrigtsen <[email-masked]>
Date: Mon, 14 Dec 2020 17:42:34 +0100

Dmitry Gutov <[email-masked]> writes:

> On 13.12.2020 15:12, Lars Ingebrigtsen wrote:
>> So...  this is apparently a feature?  Hitting `C-f' disables ido and
>> calls the fallback command, which is `write-region' in this case.
>                                         ^ write-file, right?

Yup.

> 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'.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no