emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Why the odd interactive form in byte-compile-file?


From: Daniel Colascione
Subject: Why the odd interactive form in byte-compile-file?
Date: Sun, 12 Jan 2014 20:17:34 -0800
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0

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))




reply via email to

[Prev in Thread] Current Thread [Next in Thread]