Mu4e: Revamp the header view icons
This commit is contained in:
parent
3f76578721
commit
9f044717bd
1 changed files with 57 additions and 13 deletions
|
@ -62,19 +62,63 @@
|
|||
;; set mail user agent
|
||||
(setq mail-user-agent 'mu4e-user-agent)
|
||||
|
||||
;; Use fancy icons
|
||||
;;----------------
|
||||
;; Icons
|
||||
;;----------------
|
||||
|
||||
;; Icons need a bit of work
|
||||
;; Spacing needs to be determined and adjucted
|
||||
|
||||
(defun +get-string-width (str)
|
||||
"Return the width in pixels of a string in the current
|
||||
window's default font. If the font is mono-spaced, this
|
||||
will also be the width of all other printable characters."
|
||||
(let ((window (selected-window))
|
||||
(remapping face-remapping-alist))
|
||||
(with-temp-buffer
|
||||
(make-local-variable 'face-remapping-alist)
|
||||
(setq face-remapping-alist remapping)
|
||||
(set-window-buffer window (current-buffer))
|
||||
(insert str)
|
||||
(car (window-text-pixel-size)))))
|
||||
|
||||
(cl-defun mu4e~normalised-icon (name &key set colour height v-adjust)
|
||||
"Convert :icon declaration to icon"
|
||||
(let* ((icon-set (intern (concat "all-the-icons-" (or set "faicon"))))
|
||||
(v-adjust (or v-adjust 0.02))
|
||||
(height (or height 0.8))
|
||||
(icon (if colour
|
||||
(apply icon-set `(,name :face ,(intern (concat "all-the-icons-" colour)) :height ,height :v-adjust ,v-adjust))
|
||||
(apply icon-set `(,name :height ,height :v-adjust ,v-adjust))))
|
||||
(icon-width (+get-string-width icon))
|
||||
(space-width (+get-string-width " "))
|
||||
(space-factor (- 2 (/ (float icon-width) space-width))))
|
||||
(concat (propertize " " 'display `(space . (:width ,space-factor))) icon)))
|
||||
|
||||
;; Set up all the fancy icons
|
||||
(defun mu4e~initialise-icons ()
|
||||
(setq mu4e-use-fancy-chars t
|
||||
mu4e-headers-draft-mark '("D" . "")
|
||||
mu4e-headers-flagged-mark '("F" . "")
|
||||
mu4e-headers-new-mark '("N" . "")
|
||||
mu4e-headers-passed-mark '("P" . "")
|
||||
mu4e-headers-replied-mark '("R" . "")
|
||||
mu4e-headers-seen-mark '("S" . "")
|
||||
mu4e-headers-trashed-mark '("T" . "")
|
||||
mu4e-headers-attach-mark '("a" . "")
|
||||
mu4e-headers-encrypted-mark '("x" . "")
|
||||
mu4e-headers-signed-mark '("s" . "")
|
||||
mu4e-headers-unread-mark '("u" . ""))
|
||||
mu4e-headers-draft-mark (cons "D" (mu4e~normalised-icon "pencil"))
|
||||
mu4e-headers-flagged-mark (cons "F" (mu4e~normalised-icon "flag"))
|
||||
mu4e-headers-new-mark (cons "N" (mu4e~normalised-icon "sync" :set "material" :height 0.8 :v-adjust -0.10))
|
||||
mu4e-headers-passed-mark (cons "P" (mu4e~normalised-icon "arrow-right"))
|
||||
mu4e-headers-replied-mark (cons "R" (mu4e~normalised-icon "arrow-right"))
|
||||
mu4e-headers-seen-mark (cons "S" "") ;(mu4e~normalised-icon "eye" :height 0.6 :v-adjust 0.07 :colour "dsilver"))
|
||||
mu4e-headers-trashed-mark (cons "T" (mu4e~normalised-icon "trash"))
|
||||
mu4e-headers-attach-mark (cons "a" (mu4e~normalised-icon "file-text-o" :colour "silver"))
|
||||
mu4e-headers-encrypted-mark (cons "x" (mu4e~normalised-icon "lock"))
|
||||
mu4e-headers-signed-mark (cons "s" (mu4e~normalised-icon "certificate" :height 0.7 :colour "dpurple"))
|
||||
mu4e-headers-unread-mark (cons "u" (mu4e~normalised-icon "eye-slash" :v-adjust 0.05))))
|
||||
|
||||
;; Set the icons only when a graphical frame has been created
|
||||
(if (display-graphic-p)
|
||||
(mu4e~initialise-icons)
|
||||
;; When it's the server, wait till the first graphical frame
|
||||
(add-hook! 'server-after-make-frame-hook
|
||||
(defun mu4e~initialise-icons-hook ()
|
||||
(when (display-graphic-p)
|
||||
(mu4e~initialise-icons)
|
||||
(remove-hook #'mu4e~initialise-icons-hook)))))
|
||||
|
||||
;; Add a column to display what email account the email belongs to.
|
||||
(add-to-list 'mu4e-header-info-custom
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue