Add README file
[mu4e-marker-icons.git] / mu4e-marker-icons.el
blob3e1725779e13022999746aae77c74c69630e5348
1 ;;; mu4e-marker-icons.el --- Display icons for mu4e markers. -*- lexical-binding: t; -*-
2 ;; -*- coding: utf-8 -*-
4 ;;; Time-stamp: <2021-01-09 19:34:35 stardiviner>
6 ;; Copyright (C) 2020-2021 Free Software Foundation, Inc.
8 ;;; Commentary:
12 ;;; Code:
14 (require 'mu4e-headers)
16 (defgroup mu4e-marker-icons-mode nil
17 "Display icons for mu4e markers."
18 :group 'mu4e-marker-icons-mode)
20 (defvar mu4e-marker-icons-marker-alist
21 '((mu4e-headers-seen-mark . mu4e-marker-icons-saved-headers-seen-mark)
22 (mu4e-headers-new-mark . mu4e-marker-icons-saved-headers-new-mark)
23 (mu4e-headers-unread-mark . mu4e-marker-icons-saved-headers-unread-mark)
24 (mu4e-headers-signed-mark . mu4e-marker-icons-saved-headers-signed-mark)
25 (mu4e-headers-encrypted-mark . mu4e-marker-icons-saved-headers-encrypted-mark)
26 (mu4e-headers-draft-mark . mu4e-marker-icons-saved-headers-draft-mark)
27 (mu4e-headers-attach-mark . mu4e-marker-icons-saved-headers-attach-mark)
28 (mu4e-headers-passed-mark . mu4e-marker-icons-saved-headers-passed-mark)
29 (mu4e-headers-flagged-mark . mu4e-marker-icons-saved-headers-flagged-mark)
30 (mu4e-headers-replied-mark . mu4e-marker-icons-saved-headers-replied-mark)
31 (mu4e-headers-trashed-mark . mu4e-marker-icons-saved-headers-trashed-mark)
32 ;; thread prefix marks
33 (mu4e-headers-default-prefix . mu4e-marker-icons-saved-headers-default-prefix)
34 (mu4e-headers-has-child-prefix . mu4e-marker-icons-saved-headers-has-child-prefix)
35 (mu4e-headers-empty-parent-prefix . mu4e-marker-icons-saved-headers-empty-parent-prefix)
36 (mu4e-headers-first-child-prefix . mu4e-marker-icons-saved-headers-first-child-prefix)
37 (mu4e-headers-duplicate-prefix . mu4e-marker-icons-saved-headers-duplicate-prefix))
38 "An alist of markers used in mu4e.")
40 (defun mu4e-marker-icons--store (l)
41 (mapcar (lambda (x) (set (cdr x) (symbol-value (car x)))) l))
43 (defun mu4e-marker-icons--restore (l)
44 (let ((lrev (mapcar (lambda (x) (cons (cdr x) (car x))) l)))
45 (mu4e-save lrev)))
48 (defun mu4e-marker-icons-enable ()
49 "Enable mu4e-marker-icons."
50 (mu4e-marker-icons--store mu4e-marker-icons-marker-alist)
51 (setq mu4e-use-fancy-chars t)
52 (setq mu4e-headers-precise-alignment t)
53 (setq
54 mu4e-headers-seen-mark `("S" . ,(propertize
55 (all-the-icons-material "mail_outline")
56 'face `(:family ,(all-the-icons-material-family)
57 :foreground ,(face-background 'default))))
58 mu4e-headers-new-mark `("N" . ,(propertize
59 (all-the-icons-material "markunread")
60 'face `(:family ,(all-the-icons-material-family)
61 :foreground ,(face-background 'default))))
62 mu4e-headers-unread-mark `("u" . ,(propertize
63 (all-the-icons-material "notifications_none")
64 'face 'mu4e-unread-face))
65 mu4e-headers-signed-mark `("s" . ,(propertize
66 (all-the-icons-material "check")
67 'face `(:family ,(all-the-icons-material-family)
68 :foreground "DarkCyan")))
69 mu4e-headers-encrypted-mark `("x" . ,(propertize
70 (all-the-icons-material "enhanced_encryption")
71 'face `(:family ,(all-the-icons-material-family)
72 :foreground "CornflowerBlue")))
73 mu4e-headers-draft-mark `("D" . ,(propertize
74 (all-the-icons-material "drafts")
75 'face 'mu4e-draft-face))
76 mu4e-headers-attach-mark `("a" . ,(propertize
77 (all-the-icons-material "attachment")
78 'face 'mu4e-attach-number-face))
79 mu4e-headers-passed-mark `("P" . ,(propertize ; ❯ (I'm participated in thread)
80 (all-the-icons-material "center_focus_weak")
81 'face `(:family ,(all-the-icons-material-family)
82 :foreground "yellow")))
83 mu4e-headers-flagged-mark `("F" . ,(propertize
84 (all-the-icons-material "flag")
85 'face 'mu4e-flagged-face))
86 mu4e-headers-replied-mark `("R" . ,(propertize
87 (all-the-icons-material "reply_all")
88 'face 'mu4e-replied-face))
89 mu4e-headers-trashed-mark `("T" . ,(propertize
90 (all-the-icons-material "delete_forever")
91 'face 'mu4e-trashed-face))
92 ;; thread prefix marks
93 mu4e-headers-default-prefix `("|" . ,(propertize
94 (all-the-icons-material "message")
95 'face `(:family ,(all-the-icons-material-family))))
96 mu4e-headers-has-child-prefix `("+" . ,(propertize ; "Parent" ╰
97 (all-the-icons-material "expand_more")
98 'face `(:family ,(all-the-icons-material-family))))
99 mu4e-headers-empty-parent-prefix `("-" . ,(propertize ; "Orphan"
100 (all-the-icons-material "navigate_before")
101 'face `(:family ,(all-the-icons-material-family))))
102 mu4e-headers-first-child-prefix `("\\" . ,(propertize
103 (all-the-icons-material "navigate_next")
104 'face `(:family ,(all-the-icons-material-family))))
105 mu4e-headers-duplicate-prefix `("=" . ,(propertize
106 (all-the-icons-material "content_copy")
107 'face `(:family ,(all-the-icons-material-family)
108 :foreground "siennan")))))
110 (defun mu4e-marker-icons-disable ()
111 "Disable mu4e-marker-icons."
112 (mu4e-marker-icons--restore mu4e-marker-icons-marker-alist))
114 (define-minor-mode mu4e-marker-icons-mode
115 "Display icons for mu4e markers."
116 :require 'mu4e-marker-icons-mode
117 :init-value nil
118 :global t
119 (if mu4e-marker-icons-mode
120 (mu4e-marker-icons-enable)
121 (mu4e-marker-icons-disable)))
125 (provide 'mu4e-marker-icons)
127 ;;; mu4e-marker-icons.el ends here