I want to use the scratch buffer to display some status informations after starting emacs. I read I can use initial-scratch-message variable for this.

But I do not know how to set it up.

Here you see a function(?) that gives back the start-up-time as a string. And with emacs-startup-hook it is well displayed in the statusbar. But the same with initial-scratch-message it does not work. I tried `display-graphic-p' too. And how would I append informations/values to that variable instead of just overwriting it?

;; === Print start-time after start
; from https://github.com/daviwil/emacs-from-scratch/blob/master/show-notes/Emacs-Scratch-12.org
(defun efs/display-startup-time ()
  (message "Emacs loaded in %s with %d garbage collections."
       (format "%.2f seconds"
           (time-subtract after-init-time before-init-time)))
(add-hook 'emacs-startup-hook #'efs/display-startup-time)

(initial-scratch-message #'efs/display-startup-time)
; this does not work also (wront type argument stringp)
; (setq initial-scratch-message #'efs/display-startup-time)

(initial-scratch-message display-graphic-p)

; Would prefere this (Python-Lisp-Pseudo-Code)
;(initial-scratch-message 'display-graphic-p is "{}".format(display-graphic-p))
  • 1
    initial-scratch-message is a variable, not a function. So you should use setq or similar. Nov 7, 2021 at 11:52

2 Answers 2


Functions that end with 'p' are predicates, which in emacs-speak means they check for something. In this case, display-graphic-p checks to see if you're invoking emacs in a terminal or in a graphical display. "Return non-nil if DISPLAY is a graphic display." Have you looked at the Dashboard package? It may provide what you're looking for.

  • I (think I) know what the function does. But doesn't it return a value I can display?
    – buhtz
    Nov 9, 2021 at 0:00
  • No, it returns 't' if you are in a graphical display, and 'nil' if you are in a terminal. "Predicates are functions that test their arguments for some specific conditions and return nil if the condition is false, or some non-nil value if the condition is true." Nov 9, 2021 at 0:26
  • Isn't nil or t a value?
    – buhtz
    Nov 9, 2021 at 1:39

This solve a part of the problem. Keep in mind that efs/display-startup-time is a function.

(setq initial-scratch-message (efs/display-startup-time))

But display-graphic-p (which is a "compiled function") doesn't work like that.

This is how strings can added (concated) to the variable. But I am unsure if this is the usual Lisp-way.

(setq initial-scratch-message (concat initial-scratch-message "\nfoo"))
(setq initial-scratch-message (concat initial-scratch-message "bar"))

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.