aboutsummaryrefslogtreecommitdiff
path: root/splash.el
blob: e61adbd59bc9bc79b2484f8d6703430dfc9ceef4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
;;; $DOOMDIR/splash.el -*- lexical-binding: t; -*-


(defun splash--center (str width)
  "Return STR centered in WIDTH columns."
  (let ((pad (max 0 (/ (- width (string-width str)) 2))))
    (concat (make-string pad ?\s) str)))

(defun splash-screen ()
  "Show the splash screen."
  (interactive)
  (let ((buf (get-buffer-create "*splash*")))
    (with-current-buffer buf
      (let ((inhibit-read-only t))
        (erase-buffer)
        (when (one-window-p)
          (setq mode-line-format nil))
        (setq cursor-type nil)
        (let* ((height (- (window-body-height nil) 1))
               (width  (window-body-width nil))
               (pad-top    (- (/ height 2) 1))
               (pad-bottom (- height (/ height 2) 3))
               (emacs-str  (format "GNU Emacs version %d.%d"
                                   emacs-major-version
                                   emacs-minor-version)))
          (insert (make-string pad-top ?\n))
          (insert (splash--center "www.gnu.org" width) "\n")
          (insert (splash--center emacs-str width) "\n")
          (insert (splash--center "A free/libre editor" width) "\n")
          (insert (make-string pad-bottom ?\n))
          (insert (splash--center "GNU Emacs comes with ABSOLUTELY NO WARRANTY" width) "\n")
          (insert (splash--center "Copyright (C) 2026 Free Software Foundation, Inc." width) "\n"))
        (goto-char (point-min))
        (read-only-mode 1)
        (use-local-map (make-sparse-keymap))))))

(defun splash-screen-kill ()
  "Kill the splash buffer."
  (interactive)
  (when (get-buffer "*splash*")
    (kill-buffer "*splash*")))

(if (daemonp)
    (add-hook 'server-after-make-frame-hook
              (lambda ()
                (run-with-timer 0.15 nil #'splash-screen)))
  (when (and (not (member "-no-splash"  command-line-args))
             (not (member "--file"      command-line-args))
             (not (member "--insert"    command-line-args))
             (not (member "--find-file" command-line-args)))
    (add-hook 'window-setup-hook #'splash-screen)
    (setq inhibit-startup-screen t
          inhibit-startup-message t
          inhibit-startup-echo-area-message t)))

(provide 'splash-screen)
;;; splash.el ends here