From daf84a2e6e46258c210cb8d6345cd7155ef5c2d8 Mon Sep 17 00:00:00 2001 From: jao Date: Sun, 18 Apr 2021 22:29:24 +0100 Subject: notmuch clean-ups --- email.org | 160 +++++++++++++++++++++++++++++++++++++++++--------------------- eww.org | 2 +- 2 files changed, 107 insertions(+), 55 deletions(-) diff --git a/email.org b/email.org index ff7b3b7..3af339d 100644 --- a/email.org +++ b/email.org @@ -194,24 +194,96 @@ ;; (jao-sendmail-gmail) (jao-sendmail-local) #+END_SRC -* notmucn -*** notmuch config +* notmuch +*** hello page #+begin_src emacs-lisp (defun jao-notmuch--mboxes-search (box) (mapcar (lambda (m) - `(:name ,m - :search-type tree - :query ,(format "folder:%s/%s and tag:unread" box m))) + `(:name ,(format "%s:%s" box m) + :search-type tree + :query ,(format "folder:%s/%s and tag:unread" box m))) (jao-list-mailboxes box))) + (defun jao--refresh-agenda () (save-window-excursion (org-agenda-list))) + + (with-eval-after-load "notmuch-hello" + (add-hook 'notmuch-hello-refresh-hook #'jao--refresh-agenda)) + + (setq notmuch-saved-searches + `((:name "jao" :key "j" + :query "folder:jao/inbox" + :search-type tree + :count-query "folder:jao/inbox and tag:unread") + (:name "bigml" :key "b" + :count-query "folder:bigml/inbox and tag:unread" + :search-type tree + :query "folder:bigml/inbox") + (:name "today" :key "t" :search-type tree + :query "tag:/support|inbox|bugs|bills|hacking/ and date:1d..") + ,@(jao-notmuch--mboxes-search "bigml") + ,@(jao-notmuch--mboxes-search "jao") + ,@(jao-notmuch--mboxes-search "feeds") + (:name "feeds" :query "tag:new and tag:feeds and not tag:emacs" + :key "f" :search-type tree) + (:name "new" :query "tag:new" :key "n" :search-type tree)) + notmuch-hello-sections '(notmuch-hello-insert-saved-searches + notmuch-hello-insert-alltags + notmuch-hello-insert-recent-searches + notmuch-hello-insert-header) + notmuch-hello-thousands-separator "," + notmuch-hello-recent-searches-max 5 + notmuch-show-all-tags-list t + notmuch-show-logo nil + notmuch-show-empty-saved-searches nil) + #+end_src +*** extended commands + #+begin_src emacs-lisp + (defvar-local jao-notmuch--tree-buffer nil) + + (defun jao-notmuch-goto-message-buffer () + (interactive) + (when (window-live-p notmuch-tree-message-window) + (let ((b (current-buffer))) + (select-window notmuch-tree-message-window) + (setq-local jao-notmuch--tree-buffer b)))) + + (defun jao-notmuch-goto-index-buffer () + (interactive) + (if (buffer-live-p jao-notmuch--tree-buffer) + (pop-to-buffer jao-notmuch--tree-buffer) + (user-error "No index for this buffer"))) + + (defun jao-notmuch-jump () + (interactive) + (let ((resize-mini-windows t)) (notmuch-jump-search))) + + (defun jao-notmuch-tag-jump (reverse) + (interactive "P") + (let ((resize-mini-windows t)) (notmuch-tag-jump reverse))) + + (defun jao-notmuch-tree-tag (&optional new) + (interactive "P") + (when-let (tag (notmuch-select-tag-with-completion "Forest of tag: ")) + (notmuch-tree (concat "tag:" tag) (when new "tag:/unread|new/")))) + + (defun jao-notmuch-browse-urls () + (interactive) + (when (or (derived-mode-p 'notmuch-show-mode) + (jao-notmuch-goto-message-buffer)) + (notmuch-show-browse-urls))) + #+end_src +*** package + #+begin_src emacs-lisp (use-package notmuch :ensure t :init - (setq notmuch-fcc-dirs '(("jao@bigml.com" . "bigml/sent") - (".*" . "jao/sent")) + (setq notmuch-fcc-dirs + '(("jao@bigml.com" . "bigml/sent") (".*" . "jao/sent")) notmuch-message-headers-visible t - notmuch-message-headers '("Subject" "To" "Cc" "Date" "List-Id" - "X-Mailer" "User-Agent" "X-User-Agent") + jao-notmuch-message-headers '("Subject" "To" "Cc" "Date" "List-Id" + "Reply-To" + "X-Mailer" "User-Agent" "X-User-Agent") + notmuch-message-headers jao-notmuch-message-headers notmuch-show-mark-read-tags '("-new" "-unread") notmuch-archive-tags '("+archive" "-new" "-unread") notmuch-tagging-keys @@ -220,55 +292,27 @@ ("f" ("+flagged") "Flag") ("s" ("+spam" "-new") "Mark as spam") ("d" ("+deleted" "-new" "-unread") "Delete")) - notmuch-saved-searches - `((:name "jao" :key "j" - :query "folder:jao/inbox" - :search-type tree - :count-query "folder:jao/inbox and tag:unread") - (:name "bigml" :key "b" - :count-query "folder:bigml/inbox and tag:unread" - :search-type tree - :query "folder:bigml/inbox") - ,@(jao-notmuch--mboxes-search "jao") - ,@(jao-notmuch--mboxes-search "bigml") - ,@(jao-notmuch--mboxes-search "feeds") - (:name "new" :query "tag:new" :key "u" :search-type tree) - (:name "sent" :query "tag:sent" :key "t" :search-type tree) - (:name "drafts" :query "tag:draft" :key "d" :search-type tree) - (:name "all mail" - :query "*" :count-query "tag:new" :key "a" :search-type tree)) - notmuch-hello-sections '(notmuch-hello-insert-saved-searches - notmuch-hello-insert-alltags - notmuch-hello-insert-header) - notmuch-hello-thousands-separator "," notmuch-show-all-multipart/alternative-parts nil - notmuch-show-all-tags-list t notmuch-show-indent-messages-width 2 notmuch-show-part-button-default-action 'notmuch-show-view-part - notmuch-show-logo nil - notmuch-show-empty-saved-searches nil notmuch-tree-result-format '(("date" . "%12s ") ("authors" . "%-35s") - ((("subject" . "%.95s")) . " %-95s") + ((("subject" . "%.95s")) . " %-95s") ("tags" . " (%s)")) + notmuch-search-result-format + '(("date" . "%12s ") + ("count" . "%-7s ") + ("authors" . "%-35s") + ("subject" . "%-95s") + ("tags" . "(%s)")) + notmuch-show-only-matching-messages t notmuch-unthreaded-result-format notmuch-tree-result-format notmuch-wash-wrap-lines-length 80 notmuch-wash-citation-lines-prefix 10 notmuch-wash-citation-lines-suffix 20) :config - - (defun jao--refresh-agenda () (save-window-excursion (org-agenda-list))) - (add-hook 'notmuch-hello-refresh-hook #'jao--refresh-agenda) - - (defun jao-notmuch-goto-message-buffer () - (interactive) - (when (window-live-p notmuch-tree-message-window) - (select-window notmuch-tree-message-window))) - - (defun jao-notmuch-jump () - (interactive) - (let ((resize-mini-windows t)) (notmuch-jump-search))) + (setq mm-text-html-renderer 'shr) (defun jao-mail-clean-address (fun address) (let ((address (if (string-match ".+ updates on arXiv.org: \\(.+\\)" @@ -283,15 +327,21 @@ (advice-add 'notmuch-clean-address :around #'jao-mail-clean-address) - :bind (:map notmuch-show-mode-map - ("C-c C-c" . jao-notmuch-goto-message-in-gnus) + :bind (:map + notmuch-common-keymap (("T" . jao-notmuch-tree-tag) + ("B" . jao-notmuch-browse-urls)) + :map notmuch-show-mode-map + (("h" . jao-notmuch-goto-index-buffer) + ("k" . jao-notmuch-tag-jump) + ("C-c C-c" . jao-notmuch-goto-message-in-gnus)) :map notmuch-hello-mode-map (("j" . jao-notmuch-jump) ("S" . consult-notmuch)) :map notmuch-tree-mode-map - (("h" . jao-notmuch-goto-message-buffer)))) + (("h" . jao-notmuch-goto-message-buffer) + ("k" . jao-notmuch-tag-jump)))) #+end_src -*** notmuch tagger +*** tag shell script #+begin_src bash :tangle ./bin/notmuch-tags.sh :tangle-mode (identity #o755) notmuch new > $HOME/var/log/notmuch.log 2>&1 @@ -308,7 +358,10 @@ notmuch tag +bigml +$f -- tag:new AND folder:bigml/$f done; - notmuch tag +feeds -- tag:new AND folder:/feeds.+/ + for f in ~/var/mail/feeds/*; do + f=$(basename $f) + notmuch tag +feeds +$f -- tag:new AND folder:feeds/$f + done tag_deleted "/feeds.+/" notmuch tag +jao -- tag:new AND folder:/jao.+/ @@ -318,13 +371,12 @@ tag_deleted jao/$f done - mkdir -p /tmp/trash/notmuch - notmuch search --output=files --format=text0 tag:deleted xargs -r0 rm + notmuch search --output=files --format=text0 tag:deleted | xargs -r0 rm notmuch new >> $HOME/var/log/notmuch.log 2>&1 notmuch compact >> $HOME/var/log/notmuch.log 2>&1 #+end_src -*** notmuch expirer +*** expire shell script #+begin_src bash :tangle ./bin/notmuch-expire.sh :tangle-mode (identity #o755) notmuch search --output=files --format=text0 tag:deleted | xargs -r0 rm notmuch new > $HOME/var/log/notmuch-expire.log 2>&1 diff --git a/eww.org b/eww.org index c668b04..0e9dfec 100644 --- a/eww.org +++ b/eww.org @@ -28,7 +28,7 @@ (mm-html-blocked-images nil) (fill-column (min (window-width) 110))) (mm-shr handle))) - (setq mm-text-html-renderer 'jao-eww-html-renderer) + ;; (setq mm-text-html-renderer 'jao-eww-html-renderer) #+end_src * Buffer names #+begin_src emacs-lisp -- cgit v1.2.3