|
33 | 33 | (when msg
|
34 | 34 | (or (mu4e-message-contact-field-matches msg :to addr-lex)
|
35 | 35 | (mu4e-message-contact-field-matches msg :cc addr-lex)))))))
|
| 36 | + |
| 37 | + ;; Most of the time, I merely want mu4e to re-index my local maildir (because |
| 38 | + ;; I'm running mbsync as a cron job). However, sometimes I want to fetch mails |
| 39 | + ;; immediately. Do this by changing the meaning of a prefix for |
| 40 | + ;; mu4e-update-mail-and-index (bound to "U"). |
| 41 | + ;; |
| 42 | + ;; A prefix usually means run in the background, but I don't think I ever want |
| 43 | + ;; that. Change things so a prefix means to call mbsync. |
| 44 | + (defun rjs/mu4e-update-mail-and-index (orig-fun prefix &rest args) |
| 45 | + (interactive "P") |
| 46 | + (if prefix (funcall orig-fun nil) (mu4e-update-index))) |
| 47 | + |
| 48 | + (setq my/mu4e-unread-messages-count "Mail: -") |
| 49 | + |
| 50 | + (defcustom my/inbox-count-command "echo -n ( mu find date:1w..now maildir:/INBOX flag:unread 2>/dev/null | wc -l )" |
| 51 | + "Command to retrieve count of emails in Inbox." |
| 52 | + :type 'string |
| 53 | + :group 'inbox) |
| 54 | + |
| 55 | + ;; I want to show unread messages count in awesome-tray, so add an advice |
| 56 | + ;; function to set get it and set it to a global variable. |
| 57 | + (defun my/count-mu4e-set-unread-messages () |
| 58 | + (let ((unread (shell-command-to-string my/inbox-count-command))) |
| 59 | + (setq my/mu4e-unread-messages-count (format "Mail: %s" (string-trim unread))))) |
| 60 | + |
36 | 61 | (use-package mu4e
|
37 | 62 | :straight (:type built-in)
|
38 | 63 | :bind
|
39 | 64 | ("C-c c" . mu4e-org-store-and-capture) ;; org-agenda
|
40 | 65 | ("C-c c" . mu4e-org-store-and-capture) ;; org-agenda
|
41 | 66 | :commands mu4e
|
| 67 | + :hook |
| 68 | + (mu4e-index-updated . my/count-mu4e-set-unread-messages) |
42 | 69 | :custom
|
43 | 70 | ;; http://pragmaticemacs.com/emacs/fixing-duplicate-uid-errors-when-using-mbsync-and-mu4e/
|
44 | 71 | (mu4e-change-filenames-when-moving t)
|
45 |
| - ;; Update mails every 2 minutes. |
46 |
| - (mu4e-update-interval 120) |
| 72 | + ;; Update mails every 10 minutes. |
| 73 | + (mu4e-update-interval 600) |
47 | 74 | ;; Don't save message to Sent Messages, Gmail/IMAP takes care of this
|
48 | 75 | ;; Override in context switching for other type of mailboxes
|
49 | 76 | (mu4e-sent-messages-behavior 'delete)
|
|
53 | 80 | `( ,(my-make-mu4e-context "main" "[email protected]" nil)))
|
54 | 81 | (message-send-mail-function 'smtpmail-send-it)
|
55 | 82 | (smtpmail-stream-type 'starttls)
|
| 83 | + |
| 84 | + (advice-add 'mu4e-update-mail-and-index |
| 85 | + :around #'rjs/mu4e-update-mail-and-index) |
| 86 | + |
56 | 87 | (starttls-use-gnutls t)
|
57 | 88 | ;; Personal info
|
58 | 89 | (user-full-name "Gray King")
|
|
103 | 134 | :straight t
|
104 | 135 | :after mu4e
|
105 | 136 | :hook
|
106 |
| - (after-init mu4e-alert-enable-notifications) |
| 137 | + (after-init . mu4e-alert-enable-notifications) |
107 | 138 | :config
|
108 | 139 | (mu4e-alert-set-default-style 'notifier))))
|
109 | 140 |
|
|
0 commit comments