From 3ced11e7cb86b465a83877ea351ab41730ab65ec Mon Sep 17 00:00:00 2001 From: TEC Date: Mon, 4 Oct 2021 23:44:18 +0800 Subject: [PATCH] fix(mu4e): make alerts work again At some point in the original PR alerts stopped working. I've finally tracked down why and found three components to the problem: - I'm calling `start-process` incorrectly - `truncate-string-to-width` is called on `nil` when no from name is given - mu4e-alert uses :docid to check for duplicates, which is not provided in mu 1.6, and so :message-id must be used instead. --- modules/email/mu4e/config.el | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/modules/email/mu4e/config.el b/modules/email/mu4e/config.el index 057de380f..2c82ee165 100644 --- a/modules/email/mu4e/config.el +++ b/modules/email/mu4e/config.el @@ -616,6 +616,19 @@ See `+mu4e-msg-gmail-p' and `mu4e-sent-messages-behavior'.") (mu4e-alert-enable-mode-line-display) (mu4e-alert-enable-notifications) + (when (version<= "1.6" mu4e-mu-version) + (defadvice! +mu4e-alert-filter-repeated-mails-fixed-a (mails) + "Filters the MAILS that have been seen already\nUses :message-id not :docid." + :override #'mu4e-alert-filter-repeated-mails + (cl-remove-if (lambda (mail) + (prog1 (and (not mu4e-alert-notify-repeated-mails) + (ht-get mu4e-alert-repeated-mails + (plist-get mail :message-id))) + (ht-set! mu4e-alert-repeated-mails + (plist-get mail :message-id) + t))) + mails))) + (when IS-LINUX (mu4e-alert-set-default-style 'libnotify) @@ -628,7 +641,7 @@ Disabled when set to nil.") "Default function to format MAIL-GROUP for notification. ALL-MAILS are the all the unread emails" (when +mu4e-alert-bell-cmd - (start-process (car +mu4e-alert-bell-cmd) (cdr +mu4e-alert-bell-cmd))) + (start-process "mu4e-alert-bell" nil (car +mu4e-alert-bell-cmd) (cdr +mu4e-alert-bell-cmd))) (if (> (length mail-group) 1) (let* ((mail-count (length mail-group)) (first-mail (car mail-group)) @@ -652,7 +665,8 @@ ALL-MAILS are the all the unread emails" ((string-match-p "\\`Fwd:" (plist-get mail :subject)) " ⮯ ") (t "  ")) - (truncate-string-to-width (caar (plist-get mail :from)) + (truncate-string-to-width (or (caar (plist-get mail :from)) + (cdar (plist-get mail :from))) 20 nil nil t) (truncate-string-to-width (replace-regexp-in-string "\\`Re: \\|\\`Fwd: " ""