unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Daniel Colascione <dancol@dancol.org>
To: Emacs developers <emacs-devel@gnu.org>
Subject: Why the odd interactive form in byte-compile-file?
Date: Sun, 12 Jan 2014 20:17:34 -0800	[thread overview]
Message-ID: <52D368DE.1080303@dancol.org> (raw)

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	other threads:[~2014-01-13  4:17 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-13  4:17 Daniel Colascione [this message]
2014-01-15  0:00 ` Why the odd interactive form in byte-compile-file? Daniel Colascione
2014-01-15  4:41   ` Thien-Thi Nguyen
2014-01-15  4:43     ` Daniel Colascione
2014-01-15 14:46       ` Stefan Monnier
2014-01-15 19:10         ` Daniel Colascione
2014-01-15 23:47           ` Stefan Monnier
2014-01-15 23:49             ` Daniel Colascione

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=52D368DE.1080303@dancol.org \
    --to=dancol@dancol.org \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).