Wajah garis didefinisikan dalam mu4e~headers-line-handler-functions
. Untuk mengubah wajah secara kondisional, Anda dapat mengatur preferensi Anda mu4e-mailing-list-colors
dan mencoba kode berikut (berdasarkan mu4e~headers-line-apply-flag-face
fungsi):
(defvar mu4e-mailing-list-colors
'(("emacs-devel.gnu.org" . "green")
("emacs-orgmode.gnu.org" . "blue")))
(defun mu4e~headers-line-apply-mailing-list-face (msg line)
"Adjust LINE's face property based on the MSG's mailing-list value."
(let* ((ml (mu4e-message-field msg :mailing-list))
(face (if (assoc ml mu4e-mailing-list-colors)
`(:foreground ,(assoc-default ml mu4e-mailing-list-colors))
'mu4e-header-face)))
(when (fboundp 'add-face-text-property)
(add-face-text-property 0 (length line) face t line))
line))
(add-to-list 'mu4e~headers-line-handler-functions
'mu4e~headers-line-apply-mailing-list-face)
Untuk efek yang lebih suddle, Anda dapat menambahkan bidang header baru dan menambahkan fontifikasi hanya pada bagian baris tersebut. Anda juga harus menambahkan (:colorize . 1)
untuk mu4e-headers-fields
dan tweak angka dalam add-face-text-property
. Ini sebuah contoh:
(add-to-list 'mu4e-header-info-custom
'(:colorize . (:name "Mailing list"
:shortname ""
:function (lambda (_msg)
(make-string 1 ?█)))))
(defun mu4e~headers-line-apply-mailing-list-face (msg line)
"Adjust LINE's face property based on the mailing list."
(let* ((ml (mu4e-message-field msg :mailing-list))
(face (if (assoc ml mu4e-mailing-list-colors)
(let ((color (assoc-default ml mu4e-mailing-list-colors)))
`(:foreground ,color :background ,color))
`(:foreground ,(face-attribute 'highlight :background)))))
(when (fboundp 'add-face-text-property)
(add-face-text-property 53 54 face t line))
line))