help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: compile-command customisation


From: Stefan Monnier
Subject: Re: compile-command customisation
Date: Sat, 26 Feb 2005 21:43:50 -0500
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux)

> This is what I've been using:

> (global-set-key (kbd "C-<f6>") #'(lambda ()
>                                   (interactive)
>                                   (find-file "~/.emacs.el")))

> Is this "wrong", and why?

No, it's not wrong.  while strictly speaking it's calling find-file from
elisp, it's not what I meant by "calling find-file from elisp".
The difference is that the purpose of your elisp function is to call
find-file, so of course it should do that.

> I assume something like the following is a good way to avoid find-file,
> but it seems overly elaborate:

> (defun quick-find (file)
>   "Find the file FILE."
>   (let ((buffer (find-file-noselect file)))
>     (switch-to-buffer buffer)))

> It also appears to do pretty much the same as find-file itself.

Indeed, it's no better.  Because `switch-to-buffer' should also usually be
avoided (unless it's indeed exactly what you want to do).
See C-h f switch-to-buffer RET for example (or the fact that
switch-to-buffer signals an error if you try to use it in a dedicated
window or in a minibuffer window).


        Stefan

reply via email to

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