byte-compile-file begins with this interactive spec:
(interactive
(let ((file buffer-file-name)
(file-name nil)
(file-dir nil))
(and file
(derived-mode-p 'emacs-lisp-mode)
(setq file-name (file-name-nondirectory file)
file-dir (file-name-directory file)))
(list (read-file-name (if current-prefix-arg
"Byte compile and load file: "
"Byte compile file: "))
current-prefix-arg)))
Why do we go to the trouble of splitting the file name when we're in an
emacs-lisp-mode buffer? If I'm editing /foo/bar/qux.el and type M-x
byte-compile-file RET, this code has the effect of compiling qux.el and
putting "qux.el" in file-name-history, not "/foo/bar/qux.el". Now, if
default-history is something else and I use C-x C-f C-r qux, I'll end up
on a bare "qux.el" instead of something I can actually use in another
context.
Is there some deeper reason we're not using code that looks like this?
(interactive
(list (read-file-name (if current-prefix-arg
"Byte compile and load file: "
"Byte compile file: "))
current-prefix-arg))