module-notmuch.el (4155B)
1 ;;; module-notmuch.el 2 3 ;; Author: Mark Feller <mark.feller@member.fsf.org> 4 5 ;; This file is not part of GNU Emacs. 6 7 ;; This file is free software; you can redistribute it and/or modify 8 ;; it under the terms of the GNU General Public License as published by 9 ;; the Free Software Foundation; either version 3, or (at your option) 10 ;; any later version. 11 12 ;; This file is distributed in the hope that it will be useful, 13 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 ;; GNU General Public License for more details. 16 17 ;; You should have received a copy of the GNU General Public License 18 ;; along with this file. If not, see <http://www.gnu.org/licenses/>. 19 20 ;;; Commentary: 21 22 ;; Notmuch mail provides email indexing and searching based on tags. See 23 ;; https://notmuchmail.org/ 24 25 ;;; Code: 26 27 (require 'smtpmail) 28 29 (defun mjf/initialize-gmail () 30 "Configure smtpmail to use gmail" 31 (setq message-send-mail-function 'smtpmail-send-it 32 send-mail-function 'smtpmail-send-it 33 smtpmail-default-smtp-server "smtp.gmail.com" 34 smtpmail-smtp-server "smtp.gmail.com" 35 smtpmail-local-domain "gmail.com" 36 smtpmail-stream-type 'ssl 37 smtpmail-smtp-service 465)) 38 39 (defun mjf/initialize-personal-email () 40 "Configure smtpmail to use personal mail server" 41 (setq message-send-mail-function 'smtpmail-send-it ; message-mode 42 send-mail-function 'smtpmail-send-it ; mail-mode 43 smtpmail-default-smtp-server "mail.mfeller.io" 44 smtpmail-smtp-server "mail.mfeller.io" 45 smtpmail-local-domain "mfeller.io" 46 smtpmail-stream-type 'ssl 47 smtpmail-smtp-service 465)) 48 49 (defun mjf/tag-deleted () 50 "Tag mail at point as deleted. This operation will not delete 51 the mail, but tag it for later deletion." 52 (interactive) 53 (notmuch-search-tag '("+deleted" "-unread")) 54 (next-line)) 55 56 (defun mjf/tree-tag-deleted () 57 "Tag mail at point as deleted. This operation will not delete 58 the mail, but tag it for later deletion." 59 (interactive) 60 (notmuch-tree-tag '("+deleted" "-unread")) 61 (next-line)) 62 63 (defun mjf/delete-tagged-mail () 64 "Delete mail that is tagged with the deleted tag" 65 (interactive) 66 (shell-command "notmuch_delete") 67 (notmuch-refresh-all-buffers)) 68 69 (defun mjf/getmail () 70 "Fetch mail using getmail" 71 (interactive) 72 (message "Fetching mail...") 73 (shell-command "getmail --getmaildir=$HOME/.config/getmail") 74 (notmuch-poll-and-refresh-this-buffer)) 75 76 (defun mjf/offlineimap () 77 "Fetch mail using getmail" 78 (interactive) 79 (message "Fetching mail...") 80 (shell-command "offlineimap") 81 (notmuch-poll-and-refresh-this-buffer)) 82 83 (use-package notmuch 84 :bind 85 (:map notmuch-search-mode-map 86 ("d" . mjf/tag-deleted) 87 ("D" . mjf/delete-tagged-mail) 88 ("/" . notmuch-search)) 89 (:map notmuch-tree-mode-map 90 ("d" . mjf/tree-tag-deleted) 91 ("D" . mjf/delete-tagged-mail)) 92 (:map notmuch-hello-mode-map 93 ("r" . mjf/offlineimap)) 94 95 :config 96 (add-hook 'notmuch-hello-mode-hook 'disable-line-numbers) 97 (add-hook 'notmuch-message-mode-hook 'disable-line-numbers) 98 (add-hook 'notmuch-search-mode-hook 'disable-line-numbers) 99 (add-hook 'notmuch-show-mode-hook 'disable-line-numbers) 100 (add-hook 'notmuch-tree-mode-hook 'disable-line-numbers) 101 102 (setq notmuch-saved-searches 103 '((:name "inbox" :query "tag:inbox" :key "i") 104 (:name "unread" :query "tag:unread" :key "u") 105 (:name "all" :query "*" :key "a") 106 (:name "deleted" :query "tag:deleted") 107 (:name "sent" :query "tag:sent" :key "t") 108 (:name "drafts" :query "tag:draft" :key "d") 109 (:name "work" :query "mark@getsunday.com tag:unread" :key "w" :search-type tree) 110 (:name "OpenBSD tech" :query "tech@openbsd.org tag:unread" :search-type tree) 111 (:name "OpenBSD misc" :query "misc@openbsd.org tag:unread" :search-type tree) 112 ))) 113 114 (provide 'module-notmuch) 115 116 ;;; module-notmuch.el ends here