> 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 _______________________________________________ Help-gnu-emacs mailing list Help-gnu-emacs@gnu.org http://lists.gnu.org/mailman/listinfo/help-gnu-emacs