Skip to content

Commit

Permalink
refactor(mu4e): remove commented code
Browse files Browse the repository at this point in the history
  • Loading branch information
abougouffa committed May 1, 2023
1 parent 8372b89 commit a766768
Showing 1 changed file with 87 additions and 98 deletions.
185 changes: 87 additions & 98 deletions modules/extras/me-mu4e-ui.el
Original file line number Diff line number Diff line change
Expand Up @@ -132,109 +132,98 @@ will also be the width of all other printable characters."
(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 '("─>" . "─▶")
mu4e-headers-thread-orphan-prefix '("┬>" . "┬▶ ")
mu4e-headers-thread-connection-prefix '("" . "")
mu4e-headers-thread-first-child-prefix '("├>" . "├▶")
mu4e-headers-thread-child-prefix '("├>" . "├▶")
mu4e-headers-thread-last-child-prefix '("└>" . "╰▶")
mu4e-headers-fields '((:account-stripe . 2)
(:flags . 6) ;; 3 flags
(:human-date . 8)
(:from-or-to . 25)
(:subject-truncated)))
(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 '("─>" . "─▶")
mu4e-headers-thread-orphan-prefix '("┬>" . "┬▶ ")
mu4e-headers-thread-connection-prefix '("" . "")
mu4e-headers-thread-first-child-prefix '("├>" . "├▶")
mu4e-headers-thread-child-prefix '("├>" . "├▶")
mu4e-headers-thread-last-child-prefix '("└>" . "╰▶")
mu4e-headers-fields '((:account-stripe . 2)
(:flags . 6) ;; 3 flags
(:human-date . 8)
(: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
(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
"^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))))))

;; Evil collection overwrite the jump, search, compose and quit commands
;; TODO: Useless now, to be updated/deleted when `evil-collection-mu4e' gets
;; fixed.
;; (with-eval-after-load 'evil-collection
;; (setq evil-collection-mu4e-new-region-basic
;; (concat (+mu4e--main-action-prettier-a
;; "\t* [J]ump to some maildir\n" 'mu4e-search-maildir)
;; (+mu4e--main-action-prettier-a
;; "\t* Enter a [s]earch query\n" 'mu4e-search)
;; (+mu4e--main-action-prettier-a
;; "\t* [C]ompose a new message\n" 'mu4e-compose-new))
;; evil-collection-mu4e-end-region-misc "quit"))
"\\`/?\\([^/]+\\)/.*\\'" "\\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))
Expand Down

0 comments on commit a766768

Please sign in to comment.