From 274ea7e40a7dfcce4a7d09efb1f2d507416b3905 Mon Sep 17 00:00:00 2001 From: Kjetil Orbekk Date: Tue, 31 Oct 2023 20:02:33 -0400 Subject: email fixes --- emacs/.config/emacs-kj/lisp/kj-email.el | 99 ++++++++++++++++----------------- 1 file changed, 49 insertions(+), 50 deletions(-) (limited to 'emacs/.config/emacs-kj') diff --git a/emacs/.config/emacs-kj/lisp/kj-email.el b/emacs/.config/emacs-kj/lisp/kj-email.el index 509f615..f398eb2 100644 --- a/emacs/.config/emacs-kj/lisp/kj-email.el +++ b/emacs/.config/emacs-kj/lisp/kj-email.el @@ -2,64 +2,63 @@ (setq kj/fastmail-maildir (expand-file-name "~/Maildir/fastmail")) -(setq notmuch-show-all-tags-list t - notmuch-show-relative-dates t - notmuch-hello-tag-list-make-query "tag:unread" - notmuch-archive-tags '("-inbox" "-unread") - notmuch-fcc-dirs nil) -(add-hook 'message-mode-hook 'turn-off-auto-fill) -(add-hook 'message-mode-hook 'visual-line-mode) +(when (file-exists-p (expand-file-name "~/Maildir")) + (use-package notmuch + :config -(defun kj/confirm-empty-subject () - "Allow user to quit when current message subject is empty." - (or (message-field-value "Subject") - (yes-or-no-p "Really send without Subject? ") - (keyboard-quit))) + (setq message-mail-user-agent 'notmuch-user-agent + message-kill-buffer-on-exit t + message-send-mail-function 'message-send-mail-with-sendmail) + (setq notmuch-show-all-tags-list t + notmuch-show-relative-dates t + notmuch-hello-tag-list-make-query "tag:unread" + notmuch-archive-tags '("-inbox" "-unread") + notmuch-fcc-dirs nil + notmuch-show-logo nil) + (add-hook 'message-mode-hook 'turn-off-auto-fill) + (add-hook 'message-mode-hook 'visual-line-mode) -(add-hook 'message-send-hook #'kj/confirm-empty-subject) + (defun kj/confirm-empty-subject () + "Allow user to quit when current message subject is empty." + (or (message-field-value "Subject") + (yes-or-no-p "Really send without Subject? ") + (keyboard-quit))) + (add-hook 'message-send-hook #'kj/confirm-empty-subject) + (advice-add + 'notmuch :before (defun kj/notmuch-switch-to-local () + (when (file-remote-p default-directory) + (cd (expand-file-name "~"))))) + (setq notmuch-saved-searches + '((:name "inbox" :query "tag:inbox -tag:_gz" :key "i" :search-type tree) + (:name "unread" :query "tag:unread" :key "u" :search-type tree) + (:name "flagged" :query "tag:flagged" :key "f" :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 "*" :key "a" :search-type tree) + ))) -(advice-add - 'notmuch :before (defun kj/notmuch-switch-to-local () - (when (file-remote-p default-directory) - (cd (expand-file-name "~"))))) + (defun kj/notmuch-tree-by-tag (tag) + (interactive + (list (notmuch-select-tag-with-completion "Notmuch search tag: "))) + (notmuch-tree (concat "tag:" tag))) -(setq notmuch-saved-searches - '((:name "inbox" :query "tag:inbox -tag:_gz" :key "i" :search-type tree) - (:name "unread" :query "tag:unread" :key "u" :search-type tree) - (:name "flagged" :query "tag:flagged" :key "f" :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 "*" :key "a" :search-type tree) - (:name "d" :query "tag:d-team tag:inbox" :search-type tree))) + (define-key notmuch-hello-mode-map "T" + 'kj/notmuch-tree-by-tag) -(defun kj/notmuch-tree-by-tag (tag) - (interactive - (list (notmuch-select-tag-with-completion "Notmuch search tag: "))) - (notmuch-tree (concat "tag:" tag))) + (define-key notmuch-show-mode-map "!" + (lambda () + "mark message as spam" + (interactive) + (notmuch-show-tag (list "+_gz" "-inbox")))) -(define-key notmuch-hello-mode-map "T" - 'kj/notmuch-tree-by-tag) - - -(define-key notmuch-show-mode-map "!" - (lambda () - "mark message as spam" - (interactive) - (notmuch-show-tag (list "+_gz" "-inbox")))) - -(define-key notmuch-search-mode-map "!" - (lambda (&optional beg end) - "mark thread as spam" - (interactive (notmuch-interactive-region)) - (notmuch-search-tag (list "+_gz" "-inbox") beg end))) + (define-key notmuch-search-mode-map "!" + (lambda (&optional beg end) + "mark thread as spam" + (interactive (notmuch-interactive-region)) + (notmuch-search-tag (list "+_gz" "-inbox") beg end))) + ) (when (file-exists-p kj/fastmail-maildir) - (use-package notmuch) - - (setq message-mail-user-agent 'notmuch-user-agent - message-kill-buffer-on-exit t - message-send-mail-function 'message-send-mail-with-sendmail) - (setq sendmail-program "mujmap" message-sendmail-extra-arguments (list "-C" kj/fastmail-maildir "send"))) -- cgit v1.2.3