Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for mu4e alert #72

Open
Sbozzolo opened this issue Dec 7, 2017 · 4 comments
Open

Support for mu4e alert #72

Sbozzolo opened this issue Dec 7, 2017 · 4 comments

Comments

@Sbozzolo
Copy link

Sbozzolo commented Dec 7, 2017

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

@syvanpera
Copy link

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.

@syvanpera
Copy link

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.

@syvanpera
Copy link

syvanpera commented Apr 10, 2018

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)))))

@syvanpera
Copy link

Did a pull request for this #87

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants