Like a lot of people I think I activated inhibit-startup-screen because it’s ugly and tedious to always have your emacs horizontally split when you open a file with half taken by an useless startup screen… But I notice I find it better/more beautifull/helpfull/useful than just an unique void scratch buffer when I open Emacs without opening a file…

So is there a way so that this startup screen shows up only when there’s nothing else to show up? as when the scratch buffer is displayed at startup? instead of it? and not to show up if I open a file or run a command like gnus or erc?

2 Answers 2


Ok, so no custom setting allow that behavior, so here a function to put in the after-init-hook as proposed by Xaldew.

(defun maybe-splash-screen ()
  "Open display-splash-screen instead of *scratch* buffer."
  (when (and (string= "*scratch*" (buffer-name)) (not (buffer-file-name)))
(add-hook 'after-init-hook 'maybe-splash-screen)

I did a bit of research on this and this snippet seems to work:

(defun my-after-init-hook ()
  (print command-line-args)
  (when (= 1 (length command-line-args))
    (setq initial-buffer-choice #'gnus)))
(add-hook 'after-init-hook 'my-after-init-hook)

I'm not too fond of the conditional in there since that might easily break when you add different command-line arguments, but I'm afraid I couldn't find any other checks that are valid when running the after-init-hook.

If you want a different initial buffer, simply change #'gnus in the above snippet.

I also found some other similar questions which may be of interest:

Customize startup screen text

How can I override initial-buffer-choice if I specify a filename at command line?

Programming of Initial-buffer-choice

  • No I meant I want the default startup screen, the one inhibited by inhibit-startup-screen, not like « I want gnus if no file opened », but « I want the default startup sceer if no-file-opened-OR-gnus/erc-ran »
    – galex-713
    Commented Mar 20, 2016 at 13:59
  • Ok, the function display-splash-screen does what I want. And temporary I can still test (equal "*scratch*" (buffer-name))… But two questions: first, why to use after-init-hook and not just put the code in the .emacs.d (is there any difference?)? and second, is there a “real” way to test if a buffer is the scratch buffer, other than if its name is *scratch* (for example that wouldn’t work if I open a file like /home/galex-713/*scratch*, and something cleaner than use (and (equal "*scratch*" (buffer-name)) (not (buffer-file-name))))?
    – galex-713
    Commented Mar 20, 2016 at 14:08
  • 1
    The main difference with using after-init-hook instead of setting it directly in .emacs has to do with the Emacs startup order. Basically, after-init-hook happens quite a few steps after loading your .emacs file, and at that time you can take advantage of Emacs having parsed and set various runtime options.
    – Xaldew
    Commented Mar 20, 2016 at 14:33
  • 1
    Regarding the *scratch*: you can still use a test such as (string= "*scratch*" (buffer-name)). When emacs starts, *scratch* is 'always' created and opening a new file named *scratch* will pass that buffer through uniquify-buffer-file-name, giving it a new, proper, and unique buffer name.
    – Xaldew
    Commented Mar 20, 2016 at 14:45
  • 2
    I think you should consider filing an enhancement request for this: M-x report-emacs-bug. You should be able, for example, to use a function like display-startup-screen as the value of initial-buffer-choice, to show the startup screen only when you do not provide a file/dir argument to emacs. Right now, if you use initial-buffer-choice to specify a buffer (and possibly other behavior, but ending with a buffer value), that buffer is just added to the list of files etc. provided on the command line. There should be a way to not use that buffer if there are such files.
    – Drew
    Commented Mar 20, 2016 at 15:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.