Add new small window splash - emacs "E", add @yoavm448 suggested tweaks

This commit is contained in:
tecosaur 2020-03-28 10:30:08 +08:00
parent 2d0569cc4a
commit 62d8f6972f
2 changed files with 25 additions and 17 deletions

View File

@ -164,7 +164,8 @@ I'd like to have just the buffer name, then if applicable the project folder
#+END_SRC
*** Splash screen
Emacs can render an image as the splash screen, and *@val0r* on the Discord came
up with a cracker!
up with a cracker! He's also provided me with a nice emacs-style /E/, which is
good for smaller windows. *@val0r* you have my sincere thanks, you're great!
[[file:misc/blackhole-lines.svg]]
Let's make a few different sensible sizes for this, and auto-generate for every theme.
#+BEGIN_SRC emacs-lisp
@ -172,17 +173,19 @@ Let's make a few different sensible sizes for this, and auto-generate for every
(expand-file-name "misc/blackhole-lines-template.svg" doom-private-dir)
"Default template svg used for the splash image, with substitutions from ")
(setq fancy-splash-e-image (expand-file-name "misc/emacs-e-template.svg" doom-private-dir))
(setq fancy-splash-0-image (expand-file-name "misc/transparent-pixel.png" doom-private-dir))
(defvar fancy-splash-sizes
`((:height 500 :minheight 50 :padding (0 . 2))
(:height 440 :minheight 42 :padding (1 . 4))
(:height 330 :minheight 36 :padding (1 . 3))
(:height 220 :minheight 30 :padding (1 . 2))
(:height 0 :minheight 0 :padding (0 . 0) :file ,fancy-splash-0-image))
`((:height 500 :min-height 50 :padding (0 . 2))
(:height 440 :min-height 42 :padding (1 . 4))
(:height 330 :min-height 35 :padding (1 . 3))
(:height 220 :min-height 30 :padding (1 . 2))
(:height 110 :min-height 25 :padding (1 . 2) :template ,fancy-splash-e-image)
(:height 0 :min-height 0 :padding (0 . 0) :file ,fancy-splash-0-image))
"list of plists with the following properties
:height the height of the image
:minheight minimum `frame-height' for image
:min-height minimum `frame-height' for image
:padding `+doom-dashboard-banner-padding' to apply
:template non-default template file
:file file to use instead of template")
@ -229,12 +232,12 @@ Let's make a few different sensible sizes for this, and auto-generate for every
(plist-get size :height)))))
(defun ensure-theme-splash-images-exist (&optional height)
(if (file-exists-p (fancy-splash-filename (symbol-name doom-theme) (cond (height height) (plist-get (car fancy-splash-sizes) :height))))
t (fancy-splash-generate-images)))
(unless (file-exists-p (fancy-splash-filename (symbol-name doom-theme) (cond (height height) (plist-get (car fancy-splash-sizes) :height))))
(fancy-splash-generate-images)))
(defun get-appropriate-splash ()
(let ((height (frame-height)))
(cl-some (lambda (size) (if (>= height (plist-get size :minheight)) size nil))
(cl-some (lambda (size) (when (>= height (plist-get size :min-height)) size))
fancy-splash-sizes)))
(setq fancy-splash-last-size nil)
@ -244,13 +247,14 @@ Let's make a few different sensible sizes for this, and auto-generate for every
(ensure-theme-splash-images-exist (plist-get appropriate-image :height))
(unless (and (equal appropriate-image fancy-splash-last-size)
(equal doom-theme fancy-splash-last-theme))
(if (plist-get appropriate-image :file)
(setq fancy-splash-image (plist-get appropriate-image :file))
(setq fancy-splash-image (fancy-splash-filename (symbol-name doom-theme) (plist-get appropriate-image :height))))
(setq +doom-dashboard-banner-padding (plist-get appropriate-image :padding))
(setq fancy-splash-last-size appropriate-image)
(setq fancy-splash-last-theme doom-theme)
(+doom-dashboard-reload))))
(setq fancy-splash-image
(if (plist-get appropriate-image :file)
(plist-get appropriate-image :file)
(fancy-splash-filename (symbol-name doom-theme) (plist-get appropriate-image :height))))
(setq +doom-dashboard-banner-padding (plist-get appropriate-image :padding))
(setq fancy-splash-last-size appropriate-image)
(setq fancy-splash-last-theme doom-theme)
(+doom-dashboard-reload))))
(add-hook 'window-size-change-functions #'set-appropriate-splash)
(add-hook 'doom-load-theme-hook #'set-appropriate-splash)

View File

@ -0,0 +1,4 @@
<svg height="$height" viewBox="0 0 86 107" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M 35.684432,2.414371 C 51.596051,6.4730319 61.046468,12.37858 63.185587,16.938833 65.790075,22.491175 58.1583,26.21135 40.2224,22.7325 30.956,20.9349 26.2183,22.203 24.6233,24.3817 17.569,34.0071 42.023,50.4654 53.3936,57.1938 -1.82031,43.4302 -27.0365,81.1662 44.5521,96.697 c 6.1236,1.3288 17.8718,1.8044 17.8415,3.568 -0.0034,1.896 -30.1831,2.054 -46.1025,2.54 10.858,2.904 36.9642,4.88 53.9391,3.271 16.4994,-1.561 23.7055,-7.1632 2.8966,-12.2828 C 62.3868,91.1525 20.2969,83.1695 24.7312,74.6638 31.2089,62.2426 59.2036,65.234 75.5142,63.5376 35.4138,35.97 26.316,29.4744 80.7341,36.5703 94.9709,39.7305 74.712649,16.562009 53.473749,6.8725691 48.485702,4.8931821 41.839525,3.3641875 35.684432,2.414371"
fill="$colour1" />
</svg>

After

Width:  |  Height:  |  Size: 839 B