Mu4e: enforce consistent naming scheme, "+" prefix

This commit is contained in:
TEC 2020-10-13 16:41:33 +08:00
parent b609b82d95
commit 6118ad5c12
No known key found for this signature in database
GPG key ID: 779591AFDB81F06C
2 changed files with 45 additions and 45 deletions

View file

@ -93,7 +93,7 @@ will also be the width of all other printable characters."
(car (window-text-pixel-size)))))
;;;###autoload
(cl-defun mu4e~normalised-icon (name &key set colour height v-adjust)
(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))
@ -108,22 +108,22 @@ will also be the width of all other printable characters."
;; Set up all the fancy icons
;;;###autoload
(defun mu4e~initialise-icons ()
(defun +mu4e-initialise-icons ()
(setq mu4e-use-fancy-chars t
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))))
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))))
;;;###autoload
(defun mu4e~header-colourise (str)
(defun +mu4e-header-colourise (str)
(let* ((str-sum (apply #'+ (mapcar (lambda (c) (% c 3)) str)))
(colour (nth (% str-sum (length mu4e-header-colourised-faces))
mu4e-header-colourised-faces)))
@ -134,7 +134,7 @@ will also be the width of all other printable characters."
;; Perfect for when you see an email you want to reply to
;; later, but don't want to forget about
;;;###autoload
(defun mu4e-msg-to-agenda (arg)
(defun +mu4e-msg-to-agenda (arg)
"Refile a message and add a entry in the agenda file with a
deadline. Default deadline is today. With one prefix, deadline
is tomorrow. With two prefixes, select the deadline."
@ -208,7 +208,7 @@ Otherwise, the user is prompted for the account they wish to use."
(ivy-read "Account: " (plist-get mu4e~server-props :personal-addresses) :action (lambda (candidate) (setq user-mail-address candidate)))))
;;;###autoload
(defun mu4e~main-action-prettier-str (str &optional func-or-shortcut)
(defun +mu4e~main-action-str-prettier (str &optional func-or-shortcut)
"Highlight the first occurrence of [.] in STR.
If FUNC-OR-SHORTCUT is non-nil and if it is a function, call it
when STR is clicked (using RET or mouse-2); if FUNC-OR-SHORTCUT is
@ -268,7 +268,7 @@ clicked."
(list :style (format "transform: scale(%.3f)"
(/ 1.0 (plist-get org-format-latex-options :scale))))))
(defun org-html-latex-fragment-scaled (latex-fragment _contents info)
(defun +org-html-latex-fragment-scaled (latex-fragment _contents info)
"Transcode a LATEX-FRAGMENT object from Org to HTML.
CONTENTS is nil. INFO is a plist holding contextual information.
@ -299,7 +299,7 @@ account for the value of :scale in `org-format-latex-options'."
(org-html--format-image source attributes info)))))
(t latex-frag))))
(defun org-html-latex-environment-scaled (latex-environment _contents info)
(defun +org-html-latex-environment-scaled (latex-environment _contents info)
"Transcode a LATEX-ENVIRONMENT element from Org to HTML.
CONTENTS is nil. INFO is a plist holding contextual information.

View file

@ -79,26 +79,26 @@
;; Set the icons only when a graphical frame has been created
(if (display-graphic-p)
(mu4e~initialise-icons)
(+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 ()
(defun +mu4e-initialise-icons-hook ()
(when (display-graphic-p)
(mu4e~initialise-icons)
(remove-hook #'mu4e~initialise-icons-hook)))))
(+mu4e-initialise-icons)
(remove-hook #'+mu4e-initialise-icons-hook)))))
(plist-put (cdr (assoc :flags mu4e-header-info)) :shortname " Flags") ; default=Flgs
(add-to-list 'mu4e-bookmarks
'(:name "Flagged messages" :query "flag:flagged" :key ?f) t)
(defun mu4e-header-colourise (str)
(defun +mu4e-header-colourise (str)
(let* ((str-sum (apply #'+ (mapcar (lambda (c) (% c 3)) str)))
(colour (nth (% str-sum (length mu4e-header-colourised-faces))
mu4e-header-colourised-faces)))
(colour (nth (% str-sum (length ++mu4e-header-colourised-faces))
++mu4e-header-colourised-faces)))
(put-text-property 0 (length str) 'face colour str)
str))
(defvar mu4e-header-colourised-faces
(defvar ++mu4e-header-colourised-faces
'(all-the-icons-lblue
all-the-icons-purple
all-the-icons-blue-alt
@ -117,7 +117,7 @@
(lambda (msg)
(let ((maildir
(mu4e-message-field msg :maildir)))
(mu4e-header-colourise
(+mu4e-header-colourise
(replace-regexp-in-string
"^gmail"
(propertize "g" 'face 'bold-italic)
@ -168,7 +168,7 @@
:ne "h" #'+workspace/other)
(map! :map mu4e-headers-mode-map
:e "l" #'mu4e-msg-to-agenda)
:e "l" #'+mu4e-msg-to-agenda)
(map! :localleader
:map mu4e-compose-mode-map
@ -186,13 +186,13 @@
:v "!" #'mu4e-headers-mark-for-read
:v "?" #'mu4e-headers-mark-for-unread
:v "u" #'mu4e-headers-mark-for-unmark
:vn "l" #'mu4e-msg-to-agenda))
:vn "l" #'+mu4e-msg-to-agenda))
(add-hook 'mu4e-compose-pre-hook '+mu4e-set-account)
(advice-add #'mu4e~main-action-str :override #'mu4e~main-action-prettier-str)
(advice-add #'mu4e~main-action-str :override #'+mu4e~main-action-str-prettier)
(when (featurep! :editor evil)
;; As mu4e~main-action-prettier-str replaces [k]ey with key q]uit should become quit
;; As +mu4e~main-action-str-prettier replaces [k]ey with key q]uit should become quit
(setq evil-collection-mu4e-end-region-misc "quit")))
(use-package! org-msg
@ -205,26 +205,26 @@
org-msg-greeting-name-limit 3
org-msg-text-plain-alternative t)
(defvar org-msg-currently-exporting nil
(defvar +org-msg-currently-exporting nil
"Helper variable to indicate whether org-msg is currently exporting the org buffer to HTML.
Usefull for affecting HTML export config.")
(defadvice! org-msg--now-exporting (&rest _)
(defadvice! +org-msg--now-exporting (&rest _)
:before #'org-msg-org-to-xml
(setq org-msg-currently-exporting t))
(defadvice! org-msg--not-exporting (&rest _)
(setq +org-msg-currently-exporting t))
(defadvice! +org-msg--not-exporting (&rest _)
:after #'org-msg-org-to-xml
(setq org-msg-currently-exporting nil))
(setq +org-msg-currently-exporting nil))
(advice-add #'org-html-latex-fragment :override #'org-html-latex-fragment-scaled)
(advice-add #'org-html-latex-environment :override #'org-html-latex-environment-scaled)
(advice-add #'org-html-latex-fragment :override #'+org-html-latex-fragment-scaled)
(advice-add #'org-html-latex-environment :override #'+org-html-latex-environment-scaled)
(defvar mu4e-compose--org-msg-toggle-next t ; t to initialise org-msg
(defvar +mu4e-compose-org-msg-toggle-next t ; t to initialise org-msg
"Whether to toggle ")
(defun mu4e-compose-org-msg-handle-toggle (toggle-p)
(when (xor toggle-p mu4e-compose--org-msg-toggle-next)
(when (xor toggle-p +mu4e-compose-org-msg-toggle-next)
(org-msg-mode (if org-msg-mode -1 1))
(setq mu4e-compose--org-msg-toggle-next
(not mu4e-compose--org-msg-toggle-next))))
(setq +mu4e-compose-org-msg-toggle-next
(not +mu4e-compose-org-msg-toggle-next))))
(defadvice! mu4e-maybe-toggle-org-msg (orig-fn toggle-p)
:around #'mu4e-compose-new
@ -353,7 +353,7 @@ Must be set before org-msg is loaded to take effect.")
(after! mu4e
;; don't save message to Sent Messages, Gmail/IMAP takes care of this
(setq mu4e-sent-messages-behavior
(lambda ()
(lambda () ;; TODO make use +mu4e-msg-gmail-p
(if (string-match-p "@gmail.com\\'" (message-sendmail-envelope-from))
'delete 'sent))
@ -449,7 +449,7 @@ Must be set before org-msg is loaded to take effect.")
(mu4e-alert-set-default-style 'libnotify)
(setq mu4e-alert-email-notification-types '(subjects))
(defun mu4e-alert-grouped-mail-notification-formatter-with-bell (mail-group all-mails)
(defun +mu4e-alert-grouped-mail-notification-formatter-with-bell (mail-group all-mails)
"Default function to format MAIL-GROUP for notification.
ALL-MAILS are the all the unread emails"
(shell-command "paplay /usr/share/sounds/freedesktop/stereo/message.oga")
@ -488,6 +488,6 @@ ALL-MAILS are the all the unread emails"
(subject (plist-get new-mail :subject))
(sender (caar (plist-get new-mail :from))))
(list :title sender :body subject))))
(setq mu4e-alert-grouped-mail-notification-formatter #'mu4e-alert-grouped-mail-notification-formatter-with-bell))
(setq mu4e-alert-grouped-mail-notification-formatter #'+mu4e-alert-grouped-mail-notification-formatter-with-bell))
(mu4e-alert-enable-mode-line-display))