Search code examples
emacsstartup

How to program .emacs file to end up in a specific buffer?


I have this code in my .emacs file:

(load "ielm" nil t)
(switch-to-buffer "*ielm*")
(inferior-emacs-lisp-mode)
(set-buffer-modified-p nil)

In emacs 21 and earlier, I ended up with *ielm* as the current buffer, but starting with emacs 22 I end up with *GNU Emacs* as the current buffer. What changed in emacs 22 to cause the new behavior, and what can I do to automatically end up in the *ielm* buffer?


Solution

  • The Emacs manual, node Entering Emacs tells you:

    You can also force Emacs to display a file or directory at startup by setting the variable initial-buffer-choice to a string naming that file or directory. The value of initial-buffer-choice may also be a function (of no arguments) that should return a buffer which is then displayed. If initial-buffer-choice is non-nil, then if you specify any files on the command line, Emacs still visits them, but does not display them initially.

    You can find this node in the manual by using C-h r (open the manual) followed by i startup TAB (search the index for "startup"), and choose startup screen. (Other index choices will also take you there.)