Emacs Startup Screen

Constructing a custom startup screen

Some time ago, I decided to customize my Emacs startup screen in order to display something helpful for me. Ultimately, after much consideration, I settled on the following items I just want to see on my startup screen: 1) 3-month calendar, 2) agenda, 3) diary, 4) something just for fun.

No doubt, there are a number of packages that can assist you in making a pretty good-looking startup screen – like enlight, for instance. However, I decided to construct my own startup screen, a very simple one.

It requires having two command line utilities installed on your system: fortune to print out a random epigram, and calendar to print out some of the events that have occurred on the current date in the past. If you, like me, are using Linux or macOS – it will not be difficult to install them.

And this is what I got…

In the .emacs init file

First of all, disable the builtin startup screen.

(setq inhibit-startup-screen t)

Then add a startup hook.

(add-hook 'emacs-startup-hook
  (lambda ()
    (let* ((buffer-today (get-buffer-create "*today*"))
           (buffer-calendar "*Calendar*")
           (buffer-agenda "*Org Agenda*")
           (buffer-diary "*Fancy Diary Entries*"))
      ;; Call calendar first to obtain the current date
      ;; required to display the diary.
      (calendar)
      (diary)
      (org-agenda-list)
      ;; Fill and show the Today Events buffer.
      ;; NOTE: requires `fortune' and `calendar' command line utilities.
      (switch-to-buffer buffer-today)
      (call-process "fortune" nil buffer-today)
      (insert "\n")
      (call-process "calendar" nil buffer-today)
      (goto-char 0)
      (toggle-truncate-lines)
      ;; Maximize the Today Events window
      (delete-other-windows)
      ;; Show Agenda in the lower left quadrant.
      (split-window-vertically)
      (other-window 1)
      (switch-to-buffer (get-buffer buffer-agenda))
      (split-window-horizontally)
      ;; Try to show Diary in the lower right quadrant.
      (other-window 1)
      (if (get-buffer buffer-diary)
          ;; If Diary exists then show it ...
          (switch-to-buffer (get-buffer buffer-diary))
        ;; ... else show the scratch buffer.
        (let* ((buffer-scratch (switch-to-buffer (get-buffer "*scratch*"))))
          (goto-char (point-max))
          (insert (format-time-string "\n;; No diary entries for %A %d %b")))
        )
      ;; Go back to the Today Events buffer.
      (other-window -2)
      (split-window-horizontally)
      ;; Show Calendar in the upper left quadrant.
      (switch-to-buffer (get-buffer buffer-calendar))
      )))

The startup screen

Click or tap to view the full-size picture.

Happy emacsing!