mirror of https://github.com/djcb/mu.git
* mu4e.el, mu4e-view.el: colorize cited message parts
This commit is contained in:
parent
d922808ff8
commit
a596961fe1
|
@ -120,6 +120,7 @@ marking if it still had that."
|
|||
(switch-to-buffer buf)
|
||||
(goto-char (point-min))
|
||||
|
||||
(mu4e-color-cited)
|
||||
(mu4e-mark-footer)
|
||||
(mu4e-make-urls-clickable)
|
||||
|
||||
|
@ -158,7 +159,6 @@ marking if it still had that."
|
|||
"*internal* Hash which maps a number to a (part-id name mime-type).")
|
||||
|
||||
|
||||
|
||||
(defun mu4e-open-save-attach-func (num is-open)
|
||||
"Return a function that offers to extracts (saves) attachment NUM
|
||||
if IS-OPEN is nil, and otherwise open it."
|
||||
|
@ -373,6 +373,39 @@ Seen; if the message is not New/Unread, do nothing."
|
|||
(mu4e-proc-flag docid "+S-u-N")))))
|
||||
|
||||
|
||||
(defun mu4e-color-cited ()
|
||||
"Colorize message content based on the citation level."
|
||||
(save-excursion
|
||||
(let ((more-lines t))
|
||||
(goto-char (point-min))
|
||||
(while more-lines
|
||||
;; Get the citation level at point -- ie., the number of '>'
|
||||
;; prefixes, starting with 0 for 'no citation'
|
||||
(beginning-of-line 1)
|
||||
(let* ((text (re-search-forward "[[:word:]]" (line-end-position 1) t 1))
|
||||
(level (or (and text
|
||||
(how-many ">" (line-beginning-position 1) text)) 0))
|
||||
(face
|
||||
(cond
|
||||
((= 0 level) nil) ;; don't do anything
|
||||
((= 1 level) 'mu4e-cited-1-face)
|
||||
((= 2 level) 'mu4e-cited-2-face)
|
||||
((= 3 level) 'mu4e-cited-3-face)
|
||||
((= 4 level) 'mu4e-cited-4-face)
|
||||
(t nil))))
|
||||
(when face
|
||||
(add-text-properties (line-beginning-position 1)
|
||||
(line-end-position 1) `(face ,face))))
|
||||
(setq more-lines
|
||||
(and (= 0 (forward-line 1))
|
||||
;; we need to add this weird check below; it seems in some cases
|
||||
;; `forward-line' continues to return 0, even when at the end, which
|
||||
;; would lead to an infinite loop
|
||||
(not (= (point-max) (line-end-position)))))))))
|
||||
|
||||
|
||||
|
||||
|
||||
(defun mu4e-mark-footer ()
|
||||
"Give the message footers a distinctive color."
|
||||
(let ((inhibit-read-only t))
|
||||
|
|
|
@ -264,7 +264,7 @@ flag set)."
|
|||
:group 'mu4e-faces)
|
||||
|
||||
(defface mu4e-view-header-key-face
|
||||
'((t :inherit font-lock-builtin-face))
|
||||
'((t :inherit font-lock-builtin-face :bold t))
|
||||
"Face for the header title (such as \"Subject\" in the message view)."
|
||||
:group 'mu4e-faces)
|
||||
|
||||
|
@ -293,6 +293,26 @@ flag set)."
|
|||
"Face for the number tags for attachments."
|
||||
:group 'mu4e-faces)
|
||||
|
||||
(defface mu4e-cited-1-face
|
||||
'((t :inherit font-lock-builtin-face :bold nil :italic t))
|
||||
"Face for cited message parts (level 1)."
|
||||
:group 'mu4e-faces)
|
||||
|
||||
(defface mu4e-cited-2-face
|
||||
'((t :inherit font-lock-type-face :bold nil :italic t))
|
||||
"Face for cited message parts (level 2)."
|
||||
:group 'mu4e-faces)
|
||||
|
||||
(defface mu4e-cited-3-face
|
||||
'((t :inherit font-lock-variable-name-face :bold nil :italic t))
|
||||
"Face for cited message parts (level 3)."
|
||||
:group 'mu4e-faces)
|
||||
|
||||
(defface mu4e-cited-4-face
|
||||
'((t :inherit font-lock-pseudo-keyword-face :bold nil :italic t))
|
||||
"Face for cited message parts (level 4)."
|
||||
:group 'mu4e-faces)
|
||||
|
||||
(defface mu4e-view-footer-face
|
||||
'((t :inherit font-lock-comment-face))
|
||||
"Face for message footers (signatures)."
|
||||
|
|
Loading…
Reference in New Issue