summaryrefslogtreecommitdiffhomepage
path: root/email.org
diff options
context:
space:
mode:
authorjao <jao@gnu.org>2021-04-20 04:41:20 +0100
committerjao <jao@gnu.org>2021-04-20 04:41:20 +0100
commit02ea4771f79fb33247cdf13c97af0104ae49d1a3 (patch)
treed7d5f88f903a1329813c0214b1affad32ee42fb4 /email.org
parent81e017821c7e96b1cbc91f7cae4f001a530d2e36 (diff)
downloadelibs-02ea4771f79fb33247cdf13c97af0104ae49d1a3.tar.gz
elibs-02ea4771f79fb33247cdf13c97af0104ae49d1a3.tar.bz2
email: a simple m4e configuration just for good measure
Diffstat (limited to 'email.org')
-rw-r--r--email.org373
1 files changed, 232 insertions, 141 deletions
diff --git a/email.org b/email.org
index 6e4f592..826e818 100644
--- a/email.org
+++ b/email.org
@@ -1,4 +1,4 @@
-#+title: email handling (message mode, bbdb, notmuch, et al.)
+#+title: email handling (message mode, bbdb, notmuch, mu4e et al.)
#+property: header-args :tangle no :comments no :results silent :shebang "#!/bin/bash"
#+auto_tangle: t
@@ -194,6 +194,155 @@
;; (jao-sendmail-gmail)
(jao-sendmail-local)
#+END_SRC
+* mailcap
+ #+BEGIN_SRC emacs-lisp
+ (require 'mailcap)
+
+ (add-to-list 'mailcap-mime-extensions '(".JPEG" . "image/jpeg"))
+ (add-to-list 'mailcap-mime-extensions '(".JPG" . "image/jpeg"))
+
+ (let* ((apps (cdr (assoc "application" mailcap-mime-data)))
+ (apps (cl-remove-if (lambda (x) (string= (car x) "pdf")) apps)))
+ (setcdr (assoc "application" mailcap-mime-data) apps)
+ (mailcap-parse-mailcaps nil t))
+ #+END_SRC
+* frm
+ #+begin_src emacs-lisp
+ (use-package jao-frm
+ :init (setq jao-frm-mail-command 'jao-open-gnus-frame))
+
+ (defun jao-frm--formatter (mbox n)
+ (apply #'format "%s/%s: %s" `(,@(last (split-string mbox "/") 2) ,n)))
+
+ (defun jao-frm--show ()
+ (interactive)
+ (jao-frm-show-mail-numbers #'jao-frm--formatter))
+
+ (global-set-key [(f12)] 'jao-frm--show)
+ (global-set-key [(f8)] 'jao-frm)
+
+ #+end_src
+* maildirs
+ #+begin_src emacs-lisp
+ (defun jao-list-mailboxes (base)
+ (let ((dir (expand-file-name base "~/var/mail")))
+ (cl-remove-if (lambda (x)
+ (member x '("." ".." "sent" "inbox" "trash")))
+ (directory-files dir))))
+
+ (defvar jao-maildir-maildirs nil)
+ (defvar jao-maildir-tracked-maildirs nil)
+ (use-package jao-maildir
+ :config
+ (defun jao-maildir--ensure-counts ()
+ (when gnus-newsgroup-name
+ (when (string-match "^nnimap.*:\\(.+\\)" gnus-newsgroup-name)
+ (let ((mbox (format "/home/jao/var/mail/%s"
+ (match-string 1 gnus-newsgroup-name))))
+ (jao-maildir-update-info-string mbox)))))
+ (with-eval-after-load "gnus-sum"
+ (add-hook 'gnus-exit-group-hook #'jao-maildir--ensure-counts)))
+
+ (jao-maildir-setup jao-maildir-maildirs jao-maildir-tracked-maildirs -20)
+ #+end_src
+* bbdb
+ #+begin_src emacs-lisp
+ (use-package bbdb
+ :ensure t
+ :init (setq bbdb-complete-name-allow-cycling t
+ bbdb-completion-display-record nil
+ bbdb-gui t
+ bbdb-message-all-addresses t
+ bbdb-complete-mail-allow-cycling t
+ bbdb-north-american-phone-numbers-p nil
+ bbdb-add-aka t
+ bbdb-add-name 2
+ bbdb-message-all-addresses t
+ bbdb-mua-pop-up t ;; 'horiz
+ bbdb-mua-pop-up-window-size 0.3
+ bbdb-layout 'multi-line
+ bbdb-mua-update-interactive-p '(query . create)
+ bbdb-mua-auto-update-p 'bbdb-select-message
+ bbdb-user-mail-address-re jao-mails-regexp
+ bbdb-auto-notes-ignore-headers
+ `(("From" . ,jao-mails-regexp)
+ ("From" . ".*@.*github\.com.*")
+ ("To" . ".*@.*github\.com.*")
+ ("Reply-to" . ".*")
+ ("References" . ".*"))
+ bbdb-auto-notes-ignore-messages
+ `(("To" . ".*@.*github\\.com.*")
+ ("From" . ".*@.*github\\.com.*")
+ ("From" . "info-list")
+ ("From" . "no-?reply\\|deploy")
+ ("X-Mailer" . "MailChimp"))
+ bbdb-accept-message-alist
+ `(("To" . ,jao-mails-regexp)
+ ("Cc" . ,jao-mails-regexp)
+ ("BCc" . ,jao-mails-regexp))
+ bbdb-ignore-message-alist bbdb-auto-notes-ignore-messages)
+ :config
+ (add-hook 'message-setup-hook 'bbdb-mail-aliases)
+ ;; (add-hook 'bbdb-notice-mail-hook 'bbdb-auto-notes)
+ (add-hook 'bbdb-after-change-hook (lambda (arg) (bbdb-save)))
+ (require 'bbdb-anniv) ;; BBDB 3.x this gets birthdays in org agenda
+ ;; and diary - clever stuff
+ (add-hook 'diary-list-entries-hook 'bbdb-anniv-diary-entries)
+ (eval-after-load "gnus-sum"
+ '(progn
+ (define-key gnus-summary-mode-map ":" 'bbdb-mua-annotate-sender)
+ (define-key gnus-summary-mode-map ";" 'bbdb-mua-annotate-recipients))))
+
+ (require 'bbdb)
+ (bbdb-initialize 'gnus 'message 'pgp 'mail)
+ (bbdb-mua-auto-update-init 'gnus)
+ (setq bbdb-file (expand-file-name "bbdb" gnus-home-directory))
+ #+end_src
+* gnus
+*** notmuch -> gnus
+ #+begin_src emacs-lisp
+ (defun jao-notmuch-goto-message-in-gnus ()
+ "Open a summary buffer containing the current notmuch article."
+ (interactive)
+ (let ((group (jao-maildir-file-to-group (notmuch-show-get-filename)))
+ (message-id (replace-regexp-in-string "^id:"
+ ""
+ (notmuch-show-get-message-id))))
+ (if (and group message-id)
+ (org-gnus-follow-link group message-id)
+ (message "Couldn't get relevant infos for switching to Gnus."))))
+ #+end_src
+*** gnus.el tangling
+ The core of Gnus's configuration is tangled to the usual ~gnus.el~
+ from [[./gnus.org][gnus.org]].
+ #+begin_src emacs-lisp
+ (defalias 'jao-open-gnus-frame 'jao-afio--goto-mail)
+ (setq gnus-init-file (jao-maybe-tangle "gnus"))
+ #+end_src
+*** Directories
+ #+begin_src emacs-lisp
+ (setq gnus-home-directory "~/.emacs.d/gnus"
+ gnus-directory gnus-home-directory)
+
+ (defun jao-gnus-dir (dir)
+ (expand-file-name dir gnus-home-directory))
+
+ (setq smtpmail-queue-dir (jao-gnus-dir "Mail/queued-mail/"))
+
+ (setq mail-source-directory (jao-gnus-dir "Mail/")
+ message-auto-save-directory (jao-gnus-dir "Mail/drafts/")
+ message-directory (jao-gnus-dir "Mail/"))
+
+ (setq gnus-default-directory (expand-file-name "~")
+ gnus-startup-file (jao-gnus-dir "newsrc")
+ gnus-agent-directory (jao-gnus-dir "News/agent")
+ gnus-home-score-file (jao-gnus-dir "scores")
+ gnus-article-save-directory (jao-gnus-dir "saved/")
+ nntp-authinfo-file (jao-gnus-dir "authinfo")
+ nnmail-message-id-cache-file (jao-gnus-dir "nnmail-cache")
+ nndraft-directory (jao-gnus-dir "drafts")
+ nnrss-directory (jao-gnus-dir "rss"))
+ #+end_src
* notmuch
*** hello page
#+begin_src emacs-lisp
@@ -453,152 +602,94 @@
notmuch new > $HOME/var/log/notmuch-expire.log 2>&1
notmuch compact >> $HOME/var/log/notmuch-expire.log 2>&1
#+end_src
-* gnus
-*** notmuch -> gnus
- #+begin_src emacs-lisp
- (defun jao-notmuch-goto-message-in-gnus ()
- "Open a summary buffer containing the current notmuch article."
- (interactive)
- (let ((group (jao-maildir-file-to-group (notmuch-show-get-filename)))
- (message-id (replace-regexp-in-string "^id:"
- ""
- (notmuch-show-get-message-id))))
- (if (and group message-id)
- (org-gnus-follow-link group message-id)
- (message "Couldn't get relevant infos for switching to Gnus."))))
- #+end_src
-*** gnus.el tangling
- The core of Gnus's configuration is tangled to the usual ~gnus.el~
- from [[./gnus.org][gnus.org]].
- #+begin_src emacs-lisp
- (defalias 'jao-open-gnus-frame 'jao-afio--goto-mail)
- (setq gnus-init-file (jao-maybe-tangle "gnus"))
- #+end_src
-*** Directories
- #+begin_src emacs-lisp
- (setq gnus-home-directory "~/.emacs.d/gnus"
- gnus-directory gnus-home-directory)
-
- (defun jao-gnus-dir (dir)
- (expand-file-name dir gnus-home-directory))
+* mu4e
+ #+begin_src emacs-lisp
+ (jao-load-path "mu4e")
+ (use-package mu4e
+ :init
+ (setq
+ mu4e-attachment-dir (expand-file-name "~/var/download/attachments")
+ mu4e-change-filenames-when-moving nil
+ mu4e-completing-read-function 'completing-read
+ mu4e-display-update-status-in-modeline nil
+ mu4e-get-mail-command "true" ;; "run-mb.sh || [ $? -eq 1 ]"
+ mu4e-headers-show-threads t
+ mu4e-headers-sort-direction 'ascending
+ mu4e-headers-visible-columns 100
+ mu4e-headers-visible-lines 12
+ mu4e-hide-index-messages t
+ mu4e-index-cleanup t ;; don't do a full cleanup check
+ mu4e-index-lazy-check t ;; don't consider up-to-date dirs
+ mu4e-maildir "~/var/mail/"
+ mu4e-split-view 'horizontal ;; 'vertical
+ mu4e-update-interval 300
+ mu4e-use-fancy-chars nil
+ mu4e-user-mail-address-list jao-mails
+ mu4e-view-show-addresses t
+ mu4e-view-show-images t
+ jao-mu4e-uninteresting-mail-query
+ (concat
+ "flag:unread AND NOT flag:trashed"
+ " AND NOT (maildir:/bigml/inbox OR maildir:/bigml/bugs OR"
+ " maildir:/bigml/support OR maildir:/jao/inbox)")
+ jao-mu4e-interesting-mail-query
+ (concat
+ "flag:unread AND NOT flag:trashed"
+ " AND (maildir:/bigml/inbox OR maildir:/bigml/bugs OR"
+ " maildir:/bigml/support OR maildir:/jao/inbox)")
+ mu4e-bookmarks
+ `((:name "Inbox" :query ,jao-mu4e-interesting-mail-query :key ?i)
+ (:name "Unread messages"
+ :query ,jao-mu4e-uninteresting-mail-query
+ :key 117)
+ (:name "Today's messages" :query "date:today..now"
+ :key 116)
+ (:name "Last 7 days" :query "date:7d..now" :hide-unread t
+ :key 119)
+ (:name "Messages with PDFs"
+ :query "mime:application/pdf OR mime:x-application/pdf"
+ :key 112)))
+
+ (setq mu4e-maildir-shortcuts
+ '(("/bigml/inbox" . ?i)
+ ("/bigml/bugs" . ?b)
+ ("/bigml/support" . ?s)
+ ("/jao/lists" . ?l)
+ ("/feeds/emacs" . ?e)))
- (setq smtpmail-queue-dir (jao-gnus-dir "Mail/queued-mail/"))
+ :config
+ (defun jao-mu4e--maildir (msg)
+ (when msg
+ (let ((md (mu4e-message-field msg :maildir)))
+ (when (string-match "/\\([^/]+\\)/.*" md)
+ (match-string 1 md)))))
- (setq mail-source-directory (jao-gnus-dir "Mail/")
- message-auto-save-directory (jao-gnus-dir "Mail/drafts/")
- message-directory (jao-gnus-dir "Mail/"))
+ (defun jao-mu4e--maildir-folder (dir)
+ `(lambda (msg)
+ (format "/%s/%s" (jao-mu4e--maildir msg) ,dir)))
- (setq gnus-default-directory (expand-file-name "~")
- gnus-startup-file (jao-gnus-dir "newsrc")
- gnus-agent-directory (jao-gnus-dir "News/agent")
- gnus-home-score-file (jao-gnus-dir "scores")
- gnus-article-save-directory (jao-gnus-dir "saved/")
- nntp-authinfo-file (jao-gnus-dir "authinfo")
- nnmail-message-id-cache-file (jao-gnus-dir "nnmail-cache")
- nndraft-directory (jao-gnus-dir "drafts")
- nnrss-directory (jao-gnus-dir "rss"))
- #+end_src
-* mailcap
- #+BEGIN_SRC emacs-lisp
- (require 'mailcap)
+ (defun jao-mu4e--refile-folder (msg)
+ (let ((md (jao-mu4e--maildir msg)))
+ (if (string= md "trove")
+ "/trove/jao"
+ (format "/trove/%" md))))
- (add-to-list 'mailcap-mime-extensions '(".JPEG" . "image/jpeg"))
- (add-to-list 'mailcap-mime-extensions '(".JPG" . "image/jpeg"))
+ (setq mu4e-sent-folder (jao-mu4e--maildir-folder "sent"))
+ (setq mu4e-drafts-folder (jao-mu4e--maildir-folder "trash"))
+ (setq mu4e-trash-folder (jao-mu4e--maildir-folder "trash"))
+ (setq mu4e-refile-folder 'jao-mu4e--refile-folder)
- (let* ((apps (cdr (assoc "application" mailcap-mime-data)))
- (apps (cl-remove-if (lambda (x) (string= (car x) "pdf")) apps)))
- (setcdr (assoc "application" mailcap-mime-data) apps)
- (mailcap-parse-mailcaps nil t))
- #+END_SRC
-* frm
- #+begin_src emacs-lisp
- (use-package jao-frm
- :init (setq jao-frm-mail-command 'jao-open-gnus-frame))
+ (setq mu4e-contexts nil)
- (defun jao-frm--formatter (mbox n)
- (apply #'format "%s/%s: %s" `(,@(last (split-string mbox "/") 2) ,n)))
+ (setq mu4e-view-show-images t)
+ (when (fboundp 'imagemagick-register-types)
+ (imagemagick-register-types))
- (defun jao-frm--show ()
- (interactive)
- (jao-frm-show-mail-numbers #'jao-frm--formatter))
+ (define-key mu4e-view-mode-map [remap mu4e-view-verify-msg-popup]
+ 'epa-mail-verify)
- (global-set-key [(f12)] 'jao-frm--show)
- (global-set-key [(f8)] 'jao-frm)
+ ;; View html message in browser (type aV)
+ (add-to-list 'mu4e-view-actions
+ '("ViewInBrowser" . mu4e-action-view-in-browser) t))
- #+end_src
-* maildirs
- #+begin_src emacs-lisp
- (defun jao-list-mailboxes (base)
- (let ((dir (expand-file-name base "~/var/mail")))
- (cl-remove-if (lambda (x)
- (member x '("." ".." "sent" "inbox" "trash")))
- (directory-files dir))))
-
- (defvar jao-maildir-maildirs nil)
- (defvar jao-maildir-tracked-maildirs nil)
- (use-package jao-maildir
- :config
- (defun jao-maildir--ensure-counts ()
- (when gnus-newsgroup-name
- (when (string-match "^nnimap.*:\\(.+\\)" gnus-newsgroup-name)
- (let ((mbox (format "/home/jao/var/mail/%s"
- (match-string 1 gnus-newsgroup-name))))
- (jao-maildir-update-info-string mbox)))))
- (with-eval-after-load "gnus-sum"
- (add-hook 'gnus-exit-group-hook #'jao-maildir--ensure-counts)))
-
- (jao-maildir-setup jao-maildir-maildirs jao-maildir-tracked-maildirs -20)
- #+end_src
-* bbdb
- #+begin_src emacs-lisp
- (use-package bbdb
- :ensure t
- :init (setq bbdb-complete-name-allow-cycling t
- bbdb-completion-display-record nil
- bbdb-gui t
- bbdb-message-all-addresses t
- bbdb-complete-mail-allow-cycling t
- bbdb-north-american-phone-numbers-p nil
- bbdb-add-aka t
- bbdb-add-name 2
- bbdb-message-all-addresses t
- bbdb-mua-pop-up t ;; 'horiz
- bbdb-mua-pop-up-window-size 0.3
- bbdb-layout 'multi-line
- bbdb-mua-update-interactive-p '(query . create)
- bbdb-mua-auto-update-p 'bbdb-select-message
- bbdb-user-mail-address-re jao-mails-regexp
- bbdb-auto-notes-ignore-headers
- `(("From" . ,jao-mails-regexp)
- ("From" . ".*@.*github\.com.*")
- ("To" . ".*@.*github\.com.*")
- ("Reply-to" . ".*")
- ("References" . ".*"))
- bbdb-auto-notes-ignore-messages
- `(("To" . ".*@.*github\\.com.*")
- ("From" . ".*@.*github\\.com.*")
- ("From" . "info-list")
- ("From" . "no-?reply\\|deploy")
- ("X-Mailer" . "MailChimp"))
- bbdb-accept-message-alist
- `(("To" . ,jao-mails-regexp)
- ("Cc" . ,jao-mails-regexp)
- ("BCc" . ,jao-mails-regexp))
- bbdb-ignore-message-alist bbdb-auto-notes-ignore-messages)
- :config
- (add-hook 'message-setup-hook 'bbdb-mail-aliases)
- ;; (add-hook 'bbdb-notice-mail-hook 'bbdb-auto-notes)
- (add-hook 'bbdb-after-change-hook (lambda (arg) (bbdb-save)))
- (require 'bbdb-anniv) ;; BBDB 3.x this gets birthdays in org agenda
- ;; and diary - clever stuff
- (add-hook 'diary-list-entries-hook 'bbdb-anniv-diary-entries)
- (eval-after-load "gnus-sum"
- '(progn
- (define-key gnus-summary-mode-map ":" 'bbdb-mua-annotate-sender)
- (define-key gnus-summary-mode-map ";" 'bbdb-mua-annotate-recipients))))
-
- (require 'bbdb)
- (bbdb-initialize 'gnus 'message 'pgp 'mail)
- (bbdb-mua-auto-update-init 'gnus)
- (setq bbdb-file (expand-file-name "bbdb" gnus-home-directory))
- #+end_src
+ #+end_src