[PATCH v2] emacs: change where notmuch-mua-mail moves point

Subject: [PATCH v2] emacs: change where notmuch-mua-mail moves point

Date: Wed, 1 Jun 2022 21:50:48 +0200

To: notmuch@notmuchmail.org

Cc: Damien Cassou

From: Damien Cassou

Move point to the position that makes the most sense instead of always
moving point to the TO.  This is useful when TO/SUBJECT are passed as


- Explain new behavior in docstring
- Add NEWS entry
- Fix commit message to follow notmuch guidelines
- Use git-send-email

Previous version in <87zgj8zs3k.fsf@cassou.me>
 NEWS                 |  3 +++
 emacs/notmuch-mua.el | 13 +++++++++++--
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/NEWS b/NEWS
index c18d63d3..6646e307 100644
--- a/NEWS
+++ b/NEWS
@@ -38,6 +38,9 @@ Bind the usual undo key sequences to new command
 "notmuch-tag-undo". This allows transparent undo of tagging
+The function `notmuch-mua-mail` now moves point depending on the
+provided arguments.
diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el
index 60801f4b..0ae33127 100644
--- a/emacs/notmuch-mua.el
+++ b/emacs/notmuch-mua.el
@@ -385,7 +385,13 @@ (defun notmuch-mua-pop-to-buffer (name switch-function)
 (defun notmuch-mua-mail (&optional to subject other-headers _continue
 				   switch-function yank-action send-actions
 				   return-action &rest ignored)
-  "Invoke the notmuch mail composition window."
+  "Invoke the notmuch mail composition window.
+The position of point when the function returns differs depending
+on the values of TO and SUBJECT.  If both are non-nil, point is
+moved to the message's body.  If SUBJECT is nil but TO isn't,
+point is moved to the \"Subject:\" header.  Otherwise, point is
+moved to the \"To:\" header."
   (when notmuch-mua-user-agent-function
     (let ((user-agent (funcall notmuch-mua-user-agent-function)))
@@ -420,7 +426,10 @@ (defun notmuch-mua-mail (&optional to subject other-headers _continue
   (set-buffer-modified-p nil)
-  (message-goto-to))
+  (cond
+   ((and to subject) (message-goto-body))
+   (to (message-goto-subject))
+   (t (message-goto-to))))
 (defvar notmuch-mua-sender-history nil)

notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-leave@notmuchmail.org