* bug#32274: (interactive "F") silently expands a directory to the current buffer's path
@ 2018-07-25 22:26 Andrea Cardaci
2018-07-25 22:49 ` Noam Postavsky
0 siblings, 1 reply; 5+ messages in thread
From: Andrea Cardaci @ 2018-07-25 22:26 UTC (permalink / raw)
To: 32274
[-- Attachment #1: Type: text/plain, Size: 414 bytes --]
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?
Andrea
[-- Attachment #2: Type: text/html, Size: 1311 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* bug#32274: (interactive "F") silently expands a directory to the current buffer's path
2018-07-25 22:26 bug#32274: (interactive "F") silently expands a directory to the current buffer's path Andrea Cardaci
@ 2018-07-25 22:49 ` Noam Postavsky
2018-07-25 23:39 ` Andrea Cardaci
0 siblings, 1 reply; 5+ messages in thread
From: Noam Postavsky @ 2018-07-25 22:49 UTC (permalink / raw)
To: Andrea Cardaci; +Cc: 32274
Andrea Cardaci <cyrus.and@gmail.com> 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.
^ permalink raw reply [flat|nested] 5+ messages in thread
* bug#32274: (interactive "F") silently expands a directory to the current buffer's path
2018-07-25 22:49 ` Noam Postavsky
@ 2018-07-25 23:39 ` Andrea Cardaci
2018-07-26 0:46 ` Noam Postavsky
0 siblings, 1 reply; 5+ messages in thread
From: Andrea Cardaci @ 2018-07-25 23:39 UTC (permalink / raw)
To: Noam Postavsky; +Cc: 32274
> So it seems to be on purpose.
OK, that makes sense, thank you.
I still don't think it's a wise choice though, besides being prone to
mistakes it also makes it impossible to choose /tmp/ in the above
example, while other directories can be happily selected.
^ permalink raw reply [flat|nested] 5+ messages in thread
* bug#32274: (interactive "F") silently expands a directory to the current buffer's path
2018-07-25 23:39 ` Andrea Cardaci
@ 2018-07-26 0:46 ` Noam Postavsky
2018-07-26 11:46 ` Andrea Cardaci
0 siblings, 1 reply; 5+ messages in thread
From: Noam Postavsky @ 2018-07-26 0:46 UTC (permalink / raw)
To: Andrea Cardaci; +Cc: 32274
Andrea Cardaci <cyrus.and@gmail.com> writes:
> I still don't think it's a wise choice though, besides being prone to
> mistakes it also makes it impossible to choose /tmp/ in the above
> example, while other directories can be happily selected.
You can enter "/tmp" (i.e., delete the trailing slash), but I guess
(interactive "G") is the behaviour you are looking for.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2018-07-26 11:46 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-07-25 22:26 bug#32274: (interactive "F") silently expands a directory to the current buffer's path Andrea Cardaci
2018-07-25 22:49 ` Noam Postavsky
2018-07-25 23:39 ` Andrea Cardaci
2018-07-26 0:46 ` Noam Postavsky
2018-07-26 11:46 ` Andrea Cardaci
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).