feat(mu4e): add space-right argument to `+mu4e-normalised-icon'

This allows a tiny (but equal) amount of space to the right of the icon.
In the next patch, we'll use this for some icons in the modeline.
This commit is contained in:
Sean Farley 2023-09-28 21:19:22 -07:00 committed by Henrik Lissner
parent 9f922065ba
commit b40e435f53

View file

@ -113,7 +113,7 @@ will also be the width of all other printable characters."
(insert str) (insert str)
(car (window-text-pixel-size))))) (car (window-text-pixel-size)))))
(cl-defun +mu4e-normalised-icon (name &key set color height v-adjust) (cl-defun +mu4e-normalised-icon (name &key set color height v-adjust space-right)
"Convert :icon declaration to icon" "Convert :icon declaration to icon"
(let* ((icon-set (intern (concat "nerd-icons-" (or set "faicon")))) (let* ((icon-set (intern (concat "nerd-icons-" (or set "faicon"))))
(v-adjust (or v-adjust 0.02)) (v-adjust (or v-adjust 0.02))
@ -125,8 +125,10 @@ will also be the width of all other printable characters."
(space-width (+mu4e--get-string-width " ")) (space-width (+mu4e--get-string-width " "))
(space-factor (- 2 (/ (float icon-width) space-width))) (space-factor (- 2 (/ (float icon-width) space-width)))
;; always pad the left ;; always pad the left
(space-left (propertize " " 'display `(space . (:width ,space-factor))))) (space-left (propertize " " 'display `(space . (:width ,space-factor))))
(format "%s%s" space-left icon))) ;; optionally pad the right
(space-right (if space-right space-left "")))
(format "%s%s%s" space-left icon space-right)))
;; Set up all the fancy icons ;; Set up all the fancy icons
;;;###autoload ;;;###autoload