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.
This commit is contained in:
TEC 2021-10-04 23:44:18 +08:00 committed by Henrik Lissner
parent f0d0ce65ed
commit 3ced11e7cb

View file

@ -616,6 +616,19 @@ See `+mu4e-msg-gmail-p' and `mu4e-sent-messages-behavior'.")
(mu4e-alert-enable-mode-line-display) (mu4e-alert-enable-mode-line-display)
(mu4e-alert-enable-notifications) (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 (when IS-LINUX
(mu4e-alert-set-default-style 'libnotify) (mu4e-alert-set-default-style 'libnotify)
@ -628,7 +641,7 @@ Disabled when set to nil.")
"Default function to format MAIL-GROUP for notification. "Default function to format MAIL-GROUP for notification.
ALL-MAILS are the all the unread emails" ALL-MAILS are the all the unread emails"
(when +mu4e-alert-bell-cmd (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) (if (> (length mail-group) 1)
(let* ((mail-count (length mail-group)) (let* ((mail-count (length mail-group))
(first-mail (car mail-group)) (first-mail (car mail-group))
@ -652,7 +665,8 @@ ALL-MAILS are the all the unread emails"
((string-match-p "\\`Fwd:" ((string-match-p "\\`Fwd:"
(plist-get mail :subject)) "") (plist-get mail :subject)) "")
(t "  ")) (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) 20 nil nil t)
(truncate-string-to-width (truncate-string-to-width
(replace-regexp-in-string "\\`Re: \\|\\`Fwd: " "" (replace-regexp-in-string "\\`Re: \\|\\`Fwd: " ""