Subject: Re: bug#32274: (interactive "F") silently expands a directory to the current buffer's path

From: Noam Postavsky <[email-masked]>
Date: Wed, 25 Jul 2018 18:49:14 -0400

Andrea Cardaci <[email-masked]> writes:

> The value returned by (interactive "F") is not the one provided by the user.
>
> 1. Create a file, say /tmp/foo.el:
>
> (defun foo (path)
>   (interactive "F")
>   (message path))
>
> 2. M-x evaluate-buffer
>
> 3. M-x foo and chose /tmp/.
>
> The value presented in the echo area is /tmp/foo.el, this is undesirable and very dangerous IMHO. It happens with both Emacs 24 and 26.
>
> Is this a bug or I'm overlooking something?

"F" calls read-file-name, passing nil for all args:

    DEFAULT-FILENAME specifies the default file name to return if the
    user exits the minibuffer with the same non-empty string inserted
    by this function [...]  If DEFAULT-FILENAME is omitted or
    nil [...] if the current buffer is visiting a file,
    that file serves as the default [...]

So it seems to be on purpose.