Open Sbozzolo opened 6 years ago
I took a stab at this as I wanted this too. Here's what I came up with:
Add this to mu4e-alert package settings
(setq mu4e-alert-modeline-formatter 'ts/mu4e-alert-modeline-formatter)
And add the function referenced above somewhere:
(defun ts/mu4e-alert-modeline-formatter (mail-count)
"Mu4e-alert modeline formatter for spaceline-all-the-icons."
(when (not (zerop mail-count))
(let* ((icon (all-the-icons-faicon "envelope" :v-adjust 0.0)))
(propertize
(concat
(propertize icon
'face `(:height ,(spaceline-all-the-icons--height 0.9) :inherit)
'display '(raise 0.1))
(propertize (format " %d" mail-count) 'face `(:height ,(spaceline-all-the-icons--height 0.9) :inherit) 'display '(raise 0.1)))
'help-echo (concat (if (= mail-count 1)
"You have an unread email"
(format "You have %s unread emails" mail-count))
"\nClick here to view "
(if (= mail-count 1) "it" "them"))
'mouse-face (spaceline-all-the-icons--highlight)))))
And finally tell spaceline-all-the-icons to use a custom segment.
(spaceline-all-the-icons-theme 'mu4e-alert-segment)
This works, but it doesn't quite look as good as I'd like. The custom segments are rendered next to some other segments which have padding around them. So it leaves quite a gap between the mail alert and the other segments. I can see if I can whip up a PR to get this into spaceline-all-the-icons proper.
Ah, forgot to add the mouse click stuff there. So even though it tells you to "Click here to view", that doesn't actually work yet. I'll see if I can get this cleaned up and do a PR.
Here's an updated formatter which opens the unread mails when clicked with mouse:
(defun ts/mu4e-alert-modeline-formatter (mail-count)
"Mu4e-alert modeline formatter for spaceline-all-the-icons."
(when (not (zerop mail-count))
(let* ((icon (all-the-icons-faicon "envelope" :v-adjust 0.0)))
(propertize
(concat
(propertize icon
'face `(:height ,(spaceline-all-the-icons--height 0.9) :inherit)
'display '(raise 0.1))
(propertize (format " %d" mail-count) 'face `(:height ,(spaceline-all-the-icons--height 0.9) :inherit) 'display '(raise 0.1)))
'help-echo (concat (if (= mail-count 1)
"You have an unread email"
(format "You have %s unread emails" mail-count))
"\nClick here to view "
(if (= mail-count 1) "it" "them"))
'mouse-face (spaceline-all-the-icons--highlight)
'local-map (make-mode-line-mouse-map 'mouse-1 'mu4e-alert-view-unread-mails)))))
Did a pull request for this https://github.com/domtronn/spaceline-all-the-icons.el/pull/87
I couldn't find any information about whether this package supports mu4e-alert or not. In the case it doesn't, I believe it would be a nice feature to have.
Best, sbozzolo