From 4326b4327f8b253051bb0f4ee4c6ae7d20985207 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Mon, 21 Feb 2022 22:40:35 -0600 Subject: Further configure mail --- init.el | 7 ++++--- lisp/+message.el | 26 ++++++++++++++++++++++++++ lisp/+tab-bar.el | 2 +- 3 files changed, 31 insertions(+), 4 deletions(-) create mode 100644 lisp/+message.el diff --git a/init.el b/init.el index 8d17de2..d7f7d8c 100644 --- a/init.el +++ b/init.el @@ -465,7 +465,7 @@ (setup notmuch (:load-from "~/usr/share/emacs/site-lisp/") ;;(:load-after org-contacts) - (:also-load +notmuch) + (:also-load +notmuch +message) (+define-dir notmuch/ (sync/ "emacs/notmuch") "Notmuch configuration and data.") (:option notmuch-init-file (notmuch/ "notmuch-init.el" t) @@ -473,7 +473,8 @@ notmuch-address-use-company (featurep 'company) notmuch-search-oldest-first nil) ;; Composing mail - (:option message-kill-buffer-on-exit t) + (:option message-kill-buffer-on-exit t + message-auto-save-directory "~/var/mail/drafts") ;; Sending mail (:option send-mail-function #'sendmail-send-it mail-specify-envelope-from t @@ -482,7 +483,7 @@ ;; Extras and fixes (with-eval-after-load 'notmuch (load notmuch-init-file :noerror) - ;;(add-hook 'notmuch-show-mode-hook #'visual-fill-column-mode) + (add-hook 'message-setup-hook #'+message-signature-setup) (add-hook 'message-send-hook #'+send-mail-dispatch) (advice-add 'notmuch-tag :filter-args #'+notmuch-correct-tags) (:option notmuch-saved-searches (list diff --git a/lisp/+message.el b/lisp/+message.el new file mode 100644 index 0000000..b8bc234 --- /dev/null +++ b/lisp/+message.el @@ -0,0 +1,26 @@ +;;; +message.el --- Extra message-mode functions -*- lexical-binding: t; -*- + +;;; Commentary: + +;;; Code: + +;; Thanks to Alex Schroeder for this! +;; https://www.emacswiki.org/emacs/Change_Signature_Dynamically + +(defun +message-check-for-signature-change (&rest ignore) + "Check for a change in the To: or Cc: fields" + (when (and (message--in-tocc-p) + (not (buffer-narrowed-p))) + (save-excursion + (goto-char (point-max)) + (let ((end (point))) + (when (re-search-backward message-signature-separator nil t) + (delete-region (1- (match-beginning 0)) end))) + (message-insert-signature)))) + +(defun +message-signature-setup () + (make-local-variable 'after-change-functions) + (push '+message-check-for-signature-change after-change-functions)) + +(provide '+message) +;;; +message.el ends here diff --git a/lisp/+tab-bar.el b/lisp/+tab-bar.el index c56ca68..c4b7420 100644 --- a/lisp/+tab-bar.el +++ b/lisp/+tab-bar.el @@ -53,7 +53,7 @@ "Display a notmuch count in the tab-bar." (when (featurep 'notmuch) (let* ((counts (notmuch-hello-query-counts notmuch-saved-searches)) - (next (cl-find "next" counts :key (lambda (l) (plist-get l :name)) :test 'equal)) + (next (cl-find "inbox" counts :key (lambda (l) (plist-get l :name)) :test 'equal)) (next-count (plist-get next :count))) (when (and next-count (> next-count 0)) `((notmuch-count menu-item -- cgit 1.4.1-21-gabe81