Adrian Aichner <adrian(a)xemacs.org> writes:
>>>>> "bobchan" == bobchan
<bobchan(a)webone.com.au> writes:
bobchan> ================================================================
bobchan> Dear Bug Team!
bobchan> Try this experiment:
bobchan> echo "This is from /tmp" > /tmp/~somefile
bobchan> echo "This is from ~/" > ~/~somefile
bobchan> In (X)Emacs:
bobchan> C-x C-f /tmp/<C-q>~somefile
bobchan> Output:
bobchan> "This is from ~/"
bobchan> Now, why is that?
Hi bobchan, what you are experiencing is electricity.
Note that "electricity" is when what are normally self-insert keys
behave specially, e.g. "/" and "~" in minibuffers. But he is *not*
experiencing that because he used <C-q> explicitly.
It sounds like a (mis)feature in the read-file-name designed to deal
with electricity *not* being available, probably inherited from FSF.
Without electricity, you *have* to handle "/tmp/~/x" as "~/x",
otherwise people would have to use `C-a C-k' every time.
The culprit is `substitute-in-file-name', called by
`read-file-name-2'. Note that expand-file-name was fixed some time
ago (probably during my synch with FSF 19.34) to not mangle
"/.../~foo", but substitute-in-file-name wasn't. Therefore:
(expand-file-name "/tmp/~blah")
-> "/tmp/~blah"
(substitute-in-file-name "/tmp/~blah")
-> "~blah" ; WRONG!
FSF has the same bug.