ambevar-dotfiles/.emacs.d/lisp/init-notmuch.el

71 lines
2.6 KiB
EmacsLisp
Raw Normal View History

2019-03-17 09:27:18 +01:00
;; Notmuch
(require 'init-message)
(require 'patch-notmuch)
2019-03-18 18:55:24 +01:00
(require 'init-notmuch-sync)
;; To find files matching email:
;; notmuch search --output=files FOO
2019-03-18 10:22:29 +01:00
;; The following is good enough for multiple-account support if they use the
;; same SMTP server.
(setq notmuch-fcc-dirs
2019-03-18 10:22:29 +01:00
'(("mail@ambrevar.xyz" . "mail/Sent +sent -inbox -unread")
("pierre@atlas.engineer" . "atlas/Sent +sent -inbox -unread")))
(setq notmuch-saved-searches
`((:name "inbox" :query "tag:inbox and date:1w.." :key ,(kbd "i"))
(:name "unread" :query "tag:unread" :key ,(kbd "u"))
(:name "flagged" :query "tag:flagged" :key ,(kbd "f"))
(:name "sent" :query "tag:sent and date:1w.." :key ,(kbd "t"))
(:name "drafts" :query "tag:draft" :key ,(kbd "d"))
(:name "all mail" :query "date:2w.." :key ,(kbd "a"))))
(defun ambrevar/notmuch-change-sender (&optional sender)
(interactive)
(unless (derived-mode-p 'message-mode)
(error "Must be in message mode"))
(unless sender
(setq sender (completing-read "Sender: " (mapcar 'car notmuch-fcc-dirs))))
(message-replace-header "From" sender)
(message-remove-header "Fcc")
(notmuch-fcc-header-setup))
2019-03-17 09:27:18 +01:00
(when (require 'patch-helm nil 'noerror)
(helm-defswitcher
"notmuch"
#'notmuch-interesting-buffer
2019-03-17 09:27:18 +01:00
notmuch-hello))
(when (require 'helm-notmuch nil t)
(setq helm-notmuch-match-incomplete-words t)
(dolist (map (list notmuch-search-mode-map
notmuch-hello-mode-map
notmuch-show-mode-map
notmuch-tree-mode-map))
2019-04-05 15:08:35 +02:00
(define-key map "s" 'helm-notmuch))
(define-key notmuch-show-mode-map (kbd "M-s f") #'helm-imenu))
2019-03-18 18:55:24 +01:00
2019-03-18 10:51:26 +01:00
(when (require 'org-notmuch nil 'noerror)
(dolist (map (list notmuch-show-mode-map notmuch-tree-mode-map))
(define-key map (kbd "C-c C-t") 'org-capture))
(add-to-list 'org-capture-templates
`("t" "Mark e-mail in agenda" entry (file+headline ,(car org-agenda-files) "E-mails")
"* %?\nSCHEDULED: %(org-insert-time-stamp (org-read-date nil t \"++7d\" nil (notmuch-show-get-date)))\n%a\n")))
2019-03-17 09:27:18 +01:00
(defun notmuch-show-bounce (&optional address)
"Bounce the current message."
(interactive "sBounce To: ")
(notmuch-show-view-raw-message)
(message-resend address))
(define-key notmuch-show-mode-map "b" #'notmuch-show-bounce)
;; Improve address completion with Helm.
(setq notmuch-address-use-company nil)
(setq notmuch-address-selection-function
(lambda (prompt collection initial-input)
(completing-read prompt (cons initial-input collection) nil t nil 'notmuch-address-history)))
2019-03-17 09:27:18 +01:00
(provide 'init-notmuch)