Merge pull request #1950 from mnick/notmuch
email/notmuch: general improvements - Filter read messages in notmuch show (by folding them automatically) - Refresh all notmuch buffers after sync (via process sentinel) - Support custom sync commands (introduces an additional defvar) - Add command to select From email prior to composing via ivy
This commit is contained in:
commit
515fba2fda
2 changed files with 77 additions and 13 deletions
|
@ -32,8 +32,14 @@
|
|||
;;;###autoload
|
||||
(defun +notmuch/update ()
|
||||
(interactive)
|
||||
;; create output buffer and jump to beginning
|
||||
(let ((buf (get-buffer-create "*notmuch update*")))
|
||||
(with-current-buffer buf
|
||||
(erase-buffer))
|
||||
(pop-to-buffer buf nil t)
|
||||
(set-process-sentinel
|
||||
(start-process-shell-command
|
||||
"notmuch update" nil
|
||||
"notmuch update" buf
|
||||
(pcase +notmuch-sync-backend
|
||||
(`gmi
|
||||
(concat "cd " +notmuch-mail-folder " && gmi push && gmi pull && notmuch new && afew -a -t"))
|
||||
|
@ -42,7 +48,12 @@
|
|||
(`mbsync-xdg
|
||||
"mbsync -c \"$XDG_CONFIG_HOME\"/isync/mbsyncrc -a && notmuch new && afew -a -t")
|
||||
(`offlineimap
|
||||
"offlineimap && notmuch new && afew -a -t"))))
|
||||
"offlineimap && notmuch new && afew -a -t")
|
||||
(`custom +notmuch-sync-command)))
|
||||
;; refresh notmuch buffers if sync was successful
|
||||
(lambda (_process event)
|
||||
(if (string= event "finished\n")
|
||||
(notmuch-refresh-all-buffers))))))
|
||||
|
||||
;;;###autoload
|
||||
(defun +notmuch/search-delete ()
|
||||
|
@ -56,6 +67,13 @@
|
|||
(notmuch-tree-add-tag (list "+trash" "-inbox" "-unread"))
|
||||
(notmuch-tree-next-message))
|
||||
|
||||
;;;###autoload
|
||||
(defun +notmuch/show-delete ()
|
||||
"Mark email for deletion in notmuch-show"
|
||||
(interactive)
|
||||
(notmuch-show-add-tag (list "+trash" "-inbox" "-unread"))
|
||||
(notmuch-show-next-thread-show))
|
||||
|
||||
;;;###autoload
|
||||
(defun +notmuch/search-spam ()
|
||||
(interactive)
|
||||
|
@ -68,6 +86,15 @@
|
|||
(notmuch-tree-add-tag (list "+spam" "-inbox" "-unread"))
|
||||
(notmuch-tree-next-message))
|
||||
|
||||
;;;###autoload
|
||||
(defun +notmuch/compose ()
|
||||
"Compose new mail"
|
||||
(interactive)
|
||||
(notmuch-mua-mail
|
||||
nil
|
||||
nil
|
||||
(list (cons 'From (completing-read "From: " (notmuch-user-emails))))))
|
||||
|
||||
;;;###autoload
|
||||
(defun +notmuch/open-message-with-mail-app-notmuch-tree ()
|
||||
(interactive)
|
||||
|
@ -85,6 +112,25 @@
|
|||
(start-process-shell-command "email" nil (format "xdg-open '%s'" temp))))
|
||||
|
||||
|
||||
;;;###autoload
|
||||
(defun +notmuch/show-filter-thread ()
|
||||
"Show the current thread with a different filter"
|
||||
(interactive)
|
||||
(setq notmuch-show-query-context (notmuch-read-query "Filter thread: "))
|
||||
(notmuch-show-refresh-view t))
|
||||
|
||||
;;;###autoload
|
||||
(defun +notmuch-show-expand-only-unread-h ()
|
||||
(interactive)
|
||||
(let ((unread nil)
|
||||
(open (notmuch-show-get-message-ids-for-open-messages)))
|
||||
(notmuch-show-mapc (lambda ()
|
||||
(when (member "unread" (notmuch-show-get-tags))
|
||||
(setq unread t))))
|
||||
(when unread
|
||||
(let ((notmuch-show-hook (remove '+notmuch-show-expand-only-unread-h notmuch-show-hook)))
|
||||
(notmuch-show-filter-thread "tag:unread")))))
|
||||
|
||||
;;
|
||||
;; Advice
|
||||
|
||||
|
|
|
@ -5,6 +5,9 @@
|
|||
(defvar +notmuch-sync-backend 'gmi
|
||||
"Which backend to use. Can be either gmi, mbsync, offlineimap or nil (manual).")
|
||||
|
||||
(defvar +notmuch-sync-command nil
|
||||
"Command for custom notmuch sync")
|
||||
|
||||
(defvar +notmuch-mail-folder "~/.mail/account.gmail"
|
||||
"Where your email folder is located (for use with gmailieer).")
|
||||
|
||||
|
@ -42,6 +45,9 @@
|
|||
|
||||
;; (setq-hook! 'notmuch-show-mode-hook line-spacing 0)
|
||||
|
||||
;; only unfold unread messages in thread by default
|
||||
(add-hook 'notmuch-show-hook #'+notmuch-show-expand-only-unread-h)
|
||||
|
||||
(add-hook 'doom-real-buffer-functions #'notmuch-interesting-buffer)
|
||||
|
||||
(advice-add #'notmuch-start-notmuch-sentinel :around #'+notmuch-dont-confirm-on-kill-process-a)
|
||||
|
@ -50,7 +56,20 @@
|
|||
(add-hook! '(notmuch-show-mode-hook
|
||||
notmuch-tree-mode-hook
|
||||
notmuch-search-mode-hook)
|
||||
#'hide-mode-line-mode))
|
||||
#'hide-mode-line-mode)
|
||||
|
||||
(map!
|
||||
:localleader
|
||||
:map (notmuch-search-mode-map notmuch-tree-mode-map notmuch-show-mode-map)
|
||||
:desc "compose email" "c" #'+notmuch/compose
|
||||
:desc "fetch new email" "u" #'+notmuch/update
|
||||
:desc "quit notmuch" "q" #'+notmuch/quit
|
||||
:map notmuch-search-mode-map
|
||||
:desc "mark as deleted" "d" #'+notmuch/search-delete
|
||||
:desc "mark as spam" "s" #'+notmuch/search-spam
|
||||
:map notmuch-tree-mode-map
|
||||
:desc "mark as deleted" "d" #'+notmuch/tree-delete
|
||||
:desc "mark as spam" "s" #'+notmuch/tree-spam))
|
||||
|
||||
|
||||
(use-package! org-mime
|
||||
|
@ -67,4 +86,3 @@
|
|||
:when (featurep! :completion helm)
|
||||
:commands helm-notmuch
|
||||
:after notmuch)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue