-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcold-open.el
More file actions
71 lines (64 loc) · 2.18 KB
/
Copy pathcold-open.el
File metadata and controls
71 lines (64 loc) · 2.18 KB
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
;;; cold-open.el --- A minimal splash screen -*- lexical-binding: t; -*-
;;
;; Author: M Cooper Healy
;; URL: https://github.com/isomatter-labs/cold-open
;; Version: 0.1.0
;; Package-Requires: ((emacs "27.1"))
;;
;;; Commentary:
;; Show a centered image and tagline on startup. Nothing else.
;;
;;; Code:
(defgroup cold-open nil
"A minimal splash screen."
:group 'startup)
(defcustom cold-open-image "~/.emacs.d/img/emacs.png"
"Path to the splash image."
:type 'file
:group 'cold-open)
(defcustom cold-open-tagline "A hackable text editor for the 21st Century!"
"Text displayed below the image."
:type 'string
:group 'cold-open)
(defcustom cold-open-buffer-name "*Welcome*"
"Name of the splash buffer."
:type 'string
:group 'cold-open)
;;;###autoload
(defun cold-open ()
"Show a minimal splash screen."
(interactive)
(delete-other-windows)
(with-current-buffer (get-buffer-create cold-open-buffer-name)
(setq truncate-lines t)
(display-line-numbers-mode -1)
(let* ((buffer-read-only)
(image (create-image (expand-file-name cold-open-image)))
(size (image-size image))
(height (cdr size))
(width (car size))
(top-margin (floor (/ (- (window-height) height 3) 2)))
(left-margin (floor (/ (- (window-width) width) 2))))
(erase-buffer)
(setq mode-line-format nil)
(goto-char (point-min))
(insert (make-string (max 0 top-margin) ?\n))
(insert (make-string (max 0 left-margin) ?\ ))
(insert-image image)
(insert "\n\n\n")
(insert (make-string (max 0 (floor (/ (- (window-width) (string-width cold-open-tagline)) 2))) ?\ ))
(insert cold-open-tagline))
(setq cursor-type nil)
(read-only-mode +1)
(switch-to-buffer (current-buffer))
(local-set-key (kbd "q") (lambda () (interactive) (kill-buffer (current-buffer))))))
;;;###autoload
(defun cold-open-setup ()
"Register `cold-open' to run on startup when no files are passed."
(when (< (length command-line-args) 2)
(add-hook 'emacs-startup-hook
(lambda ()
(when (display-graphic-p)
(cold-open))))))
(provide 'cold-open)
;;; cold-open.el ends here