Skip to content

Commit

Permalink
tweak: use nerd-icons instead of all-the-icons
Browse files Browse the repository at this point in the history
  • Loading branch information
abougouffa committed May 26, 2023
1 parent 5bbfe68 commit 403a3a1
Show file tree
Hide file tree
Showing 8 changed files with 110 additions and 112 deletions.
4 changes: 2 additions & 2 deletions core/me-completion.el
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,9 @@
:straight t
:hook (minemacs-after-startup . marginalia-mode))

(use-package all-the-icons-completion
(use-package nerd-icons-completion
:straight t
:hook (marginalia-mode . all-the-icons-completion-marginalia-setup))
:hook (marginalia-mode . nerd-icons-completion-mode))

(use-package orderless
:straight t
Expand Down
7 changes: 0 additions & 7 deletions core/me-core-ui.el
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,6 @@ Useful for keeping track of the enabled theme."
"Disable previously enabled themes before enabling the new one."
(mapc #'disable-theme custom-enabled-themes)))

(use-package all-the-icons
:straight t
:config
;; Show .m files as matlab/octave files
(setcdr (assoc "m" all-the-icons-extension-icon-alist)
(cdr (assoc "matlab" all-the-icons-extension-icon-alist))))

(use-package nerd-icons
:straight t
:config
Expand Down
183 changes: 94 additions & 89 deletions modules/extras/me-mu4e-ui.el
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ This is enacted by `+mu4e--main-action-str-prettier-a' and
`+mu4e--main-keyval-str-prettier-a'.")

(defvar +mu4e-header-colorized-faces
'(all-the-icons-green
all-the-icons-lblue
all-the-icons-purple-alt
all-the-icons-blue-alt
all-the-icons-purple
all-the-icons-yellow)
'(nerd-icons-green
nerd-icons-lblue
nerd-icons-purple-alt
nerd-icons-blue-alt
nerd-icons-purple
nerd-icons-yellow)
"Faces to use when coloring folders and account stripes.")

(defun +mu4e-colorize-str (str &optional unique herring)
Expand Down Expand Up @@ -119,35 +119,22 @@ will also be the width of all other printable characters."
(car (window-text-pixel-size)))))

(cl-defun +normalized-icon (name &key set color height v-adjust)
"Convert :icon declaration to icon"
(let* ((icon-set (intern (concat "all-the-icons-" (or set "material"))))
"Convert icon declaration to nerd icon with width normalized to space-width."
(let* ((set (or set "fa"))
(icon-set (intern (format "nerd-icons-%sicon" set)))
(v-adjust (or v-adjust 0.02))
(height (or height 0.8))
(name (format "nf-%s-%s" set name))
(icon (if color
(apply icon-set `(,name :face ,(intern (concat "all-the-icons-" color)) :height ,height :v-adjust ,v-adjust))
(apply icon-set `(,name :height ,height :v-adjust ,v-adjust))))
(apply icon-set `(,name :face ,(intern (format "nerd-icons-%s" color)) :height ,height :v-adjust ,v-adjust))
(apply icon-set `(,name :height ,height :v-adjust ,v-adjust))))
(icon-width (+mu4e--get-string-width icon))
(space-width (+mu4e--get-string-width " "))
(space-factor (- 2.0 (/ (float icon-width) space-width))))
(concat (propertize " " 'display `(space . (:width ,space-factor))) icon)))

(defun +mu4e--ui-setup ()
(setq
mu4e-use-fancy-chars t
mu4e-headers-draft-mark (cons "D" (+normalized-icon "edit"))
mu4e-headers-flagged-mark (cons "F" (+normalized-icon "flag"))
mu4e-headers-new-mark (cons "N" (+normalized-icon "file_download" :color "dred"))
mu4e-headers-passed-mark (cons "P" (+normalized-icon "forward"))
mu4e-headers-replied-mark (cons "R" (+normalized-icon "reply"))
mu4e-headers-seen-mark (cons "S" "")
mu4e-headers-trashed-mark (cons "T" (+normalized-icon "delete"))
mu4e-headers-attach-mark (cons "a" (+normalized-icon "attach_file"))
mu4e-headers-encrypted-mark (cons "x" (+normalized-icon "lock"))
mu4e-headers-signed-mark (cons "s" (+normalized-icon "verified_user" :color "dpurple"))
mu4e-headers-unread-mark (cons "u" (+normalized-icon "remove_red_eye" :color "dred"))
mu4e-headers-list-mark (cons "l" (+normalized-icon "list"))
mu4e-headers-personal-mark (cons "p" (+normalized-icon "person"))
mu4e-headers-calendar-mark (cons "c" (+normalized-icon "date_range"))
mu4e-headers-date-format "%d/%m/%y"
mu4e-headers-time-format "%H:%M"
mu4e-headers-thread-single-orphan-prefix '("─>" . "─▶")
Expand All @@ -162,71 +149,89 @@ will also be the width of all other printable characters."
(:from-or-to . 25)
(:subject-truncated)))

;; Add a column to display what email account the email belongs to,
;; and an account color stripe column
(defvar +mu4e-header--maildir-colors nil)
(setq
mu4e-header-info-custom
'((:account
. (:name "Account"
:shortname "Account"
:help "which account/maildir this email belongs to"
:function
(lambda (msg)
(let ((maildir (replace-regexp-in-string
"\\`/?\\([^/]+\\)/.*\\'" "\\1"
(mu4e-message-field msg :maildir))))
(+mu4e-colorize-str
(replace-regexp-in-string
"^gmail"
(propertize "g" 'face 'bold-italic)
maildir)
'+mu4e-header--maildir-colors
maildir)))))
(:subject-truncated
. (:name "Subject"
:shortname "Subject"
:help "Subject of the message"
:sortable t
:function
(lambda (msg)
(let ((prefix (mu4e~headers-thread-prefix (mu4e-message-field msg :meta))))
(concat
prefix
(truncate-string-to-width
;; Some times, a newline/carriage return char slips in the
;; subject and drives mu4e crazy! Let's fix it and truncate
;; the string at 100 characters.
(replace-regexp-in-string
"[\n\r]" ""
(mu4e-message-field msg :subject))
(- 100 (length prefix)) nil nil t))))))
(:account-stripe
. (:name "Account"
:shortname ""
:help "Which account/maildir this email belongs to"
:function
(lambda (msg)
(let ((account
(replace-regexp-in-string
"\\`/?\\([^/]+\\)/.*\\'" "\\1"
(mu4e-message-field msg :maildir))))
(propertize
(+mu4e-colorize-str "" '+mu4e-header--maildir-colors account)
'help-echo account)))))
(:recipnum
. (:name "Number of recipients"
:shortname ""
:help "Number of recipients for this message"
:function
(lambda (msg)
(propertize (format "%2d"
(+ (length (mu4e-message-field msg :to))
(length (mu4e-message-field msg :cc))))
'face 'mu4e-footer-face))))))

(advice-add #'mu4e--key-val :filter-return #'+mu4e--main-keyval-str-prettier-a)
(advice-add #'mu4e--main-action :override #'+mu4e--main-action-prettier-a))
(advice-add #'mu4e--main-action :override #'+mu4e--main-action-prettier-a)

(with-eval-after-load 'nerd-icons
(setq
mu4e-use-fancy-chars t
mu4e-headers-draft-mark (cons "D" (+normalized-icon 'edit))
mu4e-headers-flagged-mark (cons "F" (+normalized-icon 'flag :set 'md))
mu4e-headers-new-mark (cons "N" (+normalized-icon 'download :set 'oct :color 'dred))
mu4e-headers-passed-mark (cons "P" (+normalized-icon 'mail_forward))
mu4e-headers-replied-mark (cons "R" (+normalized-icon 'mail_reply))
mu4e-headers-seen-mark (cons "S" "")
mu4e-headers-trashed-mark (cons "T" (+normalized-icon 'trash_can_outline :set 'md))
mu4e-headers-attach-mark (cons "a" (+normalized-icon 'attachment :set 'md))
mu4e-headers-encrypted-mark (cons "x" (+normalized-icon 'lock))
mu4e-headers-signed-mark (cons "s" (+normalized-icon 'verified :set 'oct :color 'dpurple))
mu4e-headers-unread-mark (cons "u" (+normalized-icon 'unread :set 'oct :color 'dred))
mu4e-headers-list-mark (cons "l" (+normalized-icon 'list_ul))
mu4e-headers-personal-mark (cons "p" (+normalized-icon 'person :set 'oct))
mu4e-headers-calendar-mark (cons "c" (+normalized-icon 'calendar :set 'md)))

;; Add a column to display what email account the email belongs to,
;; and an account color stripe column
(defvar +mu4e-header--maildir-colors nil)
(setq
mu4e-header-info-custom
'((:account
. (:name "Account"
:shortname "Account"
:help "which account/maildir this email belongs to"
:function
(lambda (msg)
(let ((maildir (replace-regexp-in-string
"\\`/?\\([^/]+\\)/.*\\'" "\\1"
(mu4e-message-field msg :maildir))))
(+mu4e-colorize-str
(replace-regexp-in-string
"^gmail"
(propertize "g" 'face 'bold-italic)
maildir)
'+mu4e-header--maildir-colors
maildir)))))
(:subject-truncated
. (:name "Subject"
:shortname "Subject"
:help "Subject of the message"
:sortable t
:function
(lambda (msg)
(let ((prefix (mu4e~headers-thread-prefix (mu4e-message-field msg :meta))))
(concat
prefix
(truncate-string-to-width
;; Some times, a newline/carriage return char slips in the
;; subject and drives mu4e crazy! Let's fix it and truncate
;; the string at 100 characters.
(replace-regexp-in-string
"[\n\r]" ""
(mu4e-message-field msg :subject))
(- 100 (length prefix)) nil nil t))))))
(:account-stripe
. (:name "Account"
:shortname ""
:help "Which account/maildir this email belongs to"
:function
(lambda (msg)
(let ((account
(replace-regexp-in-string
"\\`/?\\([^/]+\\)/.*\\'" "\\1"
(mu4e-message-field msg :maildir))))
(propertize
(+mu4e-colorize-str "" '+mu4e-header--maildir-colors account)
'help-echo account)))))
(:recipnum
. (:name "Number of recipients"
:shortname ""
:help "Number of recipients for this message"
:function
(lambda (msg)
(propertize (format "%2d"
(+ (length (mu4e-message-field msg :to))
(length (mu4e-message-field msg :cc))))
'face 'mu4e-footer-face))))))))

(defun +mu4e-ui-setup ()
(if (display-graphic-p)
Expand Down
8 changes: 4 additions & 4 deletions modules/me-biblio.el
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@
(org-cite-activate-processor 'citar)
(citar-symbol-separator " ")
:config
(with-eval-after-load 'all-the-icons
(with-eval-after-load 'nerd-icons
(defun +citar--set-symbols ()
(setq citar-symbols
`((file ,(all-the-icons-octicon "file-pdf" :face 'error) . " ")
(note ,(all-the-icons-octicon "file-text" :face 'warning) . " ")
(link ,(all-the-icons-octicon "link-external" :face 'org-link) . " "))))
`((file ,(nerd-icons-codicon "nf-cod-file_pdf" :face 'error) . " ")
(note ,(nerd-icons-faicon "nf-fa-file_text" :face 'warning) . " ")
(link ,(nerd-icons-mdicon "nf-md-link" :face 'org-link) . " "))))

;; Properly setup citar-symbols
(if (display-graphic-p)
Expand Down
8 changes: 4 additions & 4 deletions modules/me-files.el
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
:straight t
:hook (minemacs-after-startup . dirvish-override-dired-mode)
:custom
(dirvish-attributes '(subtree-state all-the-icons file-size vc-state git-msg))
(dirvish-attributes '(subtree-state nerd-icons file-size vc-state git-msg))
(dirvish-cache-dir (+directory-ensure minemacs-cache-dir "dirvish/"))
(dirvish-mode-line-format '(:left (sort file-time symlink) :right (omit yank index)))
(dirvish-side-width 30)
Expand Down Expand Up @@ -52,12 +52,12 @@
:after treemacs evil
:demand t)

(use-package treemacs-all-the-icons
(use-package treemacs-nerd-icons
:straight t
:after treemacs all-the-icons
:after treemacs nerd-icons
:demand t
:config
(treemacs-load-theme "all-the-icons"))
(treemacs-load-theme "nerd-icons"))


(provide 'me-files)
Expand Down
2 changes: 1 addition & 1 deletion modules/me-lifestyle.el
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
;; calculation method, either by setting the right angles for Fajr and Isha,
;; or by using one of the predefined presets (see `awqat' for more
;; information).
(awqat-mode-line-format " 🕌 ${prayer} (${hours}h${minutes}m) ")
(awqat-mode-line-format (concat " " (nerd-icons-mdicon "nf-md-mosque") " ${prayer} (${hours}h${minutes}m) "))
(awqat-update-interval 30.0))


Expand Down
6 changes: 3 additions & 3 deletions modules/me-modeling.el
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
(+map-local! :keymaps 'scad-mode-map
"p" #'scad-preview)

(with-eval-after-load 'all-the-icons
(with-eval-after-load 'nerd-icons
(add-to-list
'all-the-icons-extension-icon-alist
'("scad" all-the-icons-fileicon "openscad" :height 0.9 :face all-the-icons-yellow)))
'nerd-icons-extension-icon-alist
'("scad" nerd-icons-mdicon "nf-md-cad_file" :face nerd-icons-yellow)))

(with-eval-after-load 'apheleia-formatters
(push '(scad-mode . clang-format) apheleia-mode-alist))
Expand Down
4 changes: 2 additions & 2 deletions modules/me-ui.el
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@
:init
(+map! "tF" #'focus-mode))

(use-package all-the-icons-ibuffer
(use-package nerd-icons-ibuffer
:straight t
:hook (ibuffer-mode . all-the-icons-ibuffer-mode))
:hook (ibuffer-mode . nerd-icons-ibuffer-mode))


(provide 'me-ui)
Expand Down

0 comments on commit 403a3a1

Please sign in to comment.