Prefer ;; Version over ;; Package-Version
[mu4e-marker-icons.git] / mu4e-marker-icons.el
blob3bcc02a18eb417867c0569360fe57d2cf3582028
1 ;;; mu4e-marker-icons.el --- Display icons for mu4e markers -*- lexical-binding: t; -*-
2 ;; -*- coding: utf-8 -*-
4 ;;; Time-stamp: <2021-01-09 20:01:59 stardiviner>
6 ;; Authors: stardiviner <numbchild@gmail.com>
7 ;; Package-Requires: ((emacs "26.1") (all-the-icons "4.0.0"))
8 ;; Version: 0.1.0
9 ;; Keywords: mail
10 ;; homepage: https://github.com/stardiviner/mu4e-marker-icons
12 ;; Copyright (C) 2020-2021 Free Software Foundation, Inc.
14 ;; mu4e-marker-icons is free software; you can redistribute it and/or modify it
15 ;; under the terms of the GNU General Public License as published by
16 ;; the Free Software Foundation; either version 3, or (at your option)
17 ;; any later version.
19 ;; mu4e-marker-icons is distributed in the hope that it will be useful, but WITHOUT
20 ;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
21 ;; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
22 ;; License for more details.
25 ;; You should have received a copy of the GNU General Public License
26 ;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
28 ;;; Commentary:
30 ;; Usage
32 ;; (mu4e-marker-icons-mode 1)
34 ;;; Code:
36 (require 'mu4e-headers)
37 (require 'all-the-icons)
39 (defgroup mu4e-marker-icons nil
40 "Display icons for mu4e markers."
41 :group 'mu4e-marker-icons)
43 (defvar mu4e-marker-icons-marker-alist
44 '((mu4e-headers-seen-mark . mu4e-marker-icons-saved-headers-seen-mark)
45 (mu4e-headers-new-mark . mu4e-marker-icons-saved-headers-new-mark)
46 (mu4e-headers-unread-mark . mu4e-marker-icons-saved-headers-unread-mark)
47 (mu4e-headers-signed-mark . mu4e-marker-icons-saved-headers-signed-mark)
48 (mu4e-headers-encrypted-mark . mu4e-marker-icons-saved-headers-encrypted-mark)
49 (mu4e-headers-draft-mark . mu4e-marker-icons-saved-headers-draft-mark)
50 (mu4e-headers-attach-mark . mu4e-marker-icons-saved-headers-attach-mark)
51 (mu4e-headers-passed-mark . mu4e-marker-icons-saved-headers-passed-mark)
52 (mu4e-headers-flagged-mark . mu4e-marker-icons-saved-headers-flagged-mark)
53 (mu4e-headers-replied-mark . mu4e-marker-icons-saved-headers-replied-mark)
54 (mu4e-headers-trashed-mark . mu4e-marker-icons-saved-headers-trashed-mark))
55 "An alist of markers used in mu4e.")
57 (defun mu4e-marker-icons--store (l)
58 "Store mu4e header markers value from `L'."
59 (mapcar (lambda (x) (set (cdr x) (symbol-value (car x)))) l))
61 (defun mu4e-marker-icons--restore (l)
62 "Restore mu4e header markers value from `L'."
63 (let ((lrev (mapcar (lambda (x) (cons (cdr x) (car x))) l)))
64 (mu4e-marker-icons--store lrev)))
67 (defun mu4e-marker-icons-enable ()
68 "Enable mu4e-marker-icons."
69 (mu4e-marker-icons--store mu4e-marker-icons-marker-alist)
70 (setq mu4e-use-fancy-chars t)
71 (setq mu4e-headers-precise-alignment t)
72 (setq
73 mu4e-headers-seen-mark `("S" . ,(propertize
74 (all-the-icons-material "mail_outline")
75 'face `(:family ,(all-the-icons-material-family)
76 :foreground ,(face-background 'default))))
77 mu4e-headers-new-mark `("N" . ,(propertize
78 (all-the-icons-material "markunread")
79 'face `(:family ,(all-the-icons-material-family)
80 :foreground ,(face-background 'default))))
81 mu4e-headers-unread-mark `("u" . ,(propertize
82 (all-the-icons-material "notifications_none")
83 'face 'mu4e-unread-face))
84 mu4e-headers-signed-mark `("s" . ,(propertize
85 (all-the-icons-material "check")
86 'face `(:family ,(all-the-icons-material-family)
87 :foreground "DarkCyan")))
88 mu4e-headers-encrypted-mark `("x" . ,(propertize
89 (all-the-icons-material "enhanced_encryption")
90 'face `(:family ,(all-the-icons-material-family)
91 :foreground "CornflowerBlue")))
92 mu4e-headers-draft-mark `("D" . ,(propertize
93 (all-the-icons-material "drafts")
94 'face 'mu4e-draft-face))
95 mu4e-headers-attach-mark `("a" . ,(propertize
96 (all-the-icons-material "attachment")
97 'face 'mu4e-attach-number-face))
98 mu4e-headers-passed-mark `("P" . ,(propertize ; ❯ (I'm participated in thread)
99 (all-the-icons-material "center_focus_weak")
100 'face `(:family ,(all-the-icons-material-family)
101 :foreground "yellow")))
102 mu4e-headers-flagged-mark `("F" . ,(propertize
103 (all-the-icons-material "flag")
104 'face 'mu4e-flagged-face))
105 mu4e-headers-replied-mark `("R" . ,(propertize
106 (all-the-icons-material "reply_all")
107 'face 'mu4e-replied-face))
108 mu4e-headers-trashed-mark `("T" . ,(propertize
109 (all-the-icons-material "delete_forever")
110 'face 'mu4e-trashed-face))))
112 (defun mu4e-marker-icons-disable ()
113 "Disable mu4e-marker-icons."
114 (mu4e-marker-icons--restore mu4e-marker-icons-marker-alist))
116 ;;;###autoload
117 (define-minor-mode mu4e-marker-icons-mode
118 "Display icons for mu4e markers."
119 :require 'mu4e-marker-icons-mode
120 :init-value nil
121 :global t
122 (if mu4e-marker-icons-mode
123 (mu4e-marker-icons-enable)
124 (mu4e-marker-icons-disable)))
128 (provide 'mu4e-marker-icons)
130 ;;; mu4e-marker-icons.el ends here