]> git.cworth.org Git - notmuch/commitdiff
emacs: change where notmuch-mua-mail moves point
authorDamien Cassou <damien@cassou.me>
Wed, 1 Jun 2022 19:50:48 +0000 (21:50 +0200)
committerDavid Bremner <david@tethera.net>
Thu, 2 Jun 2022 11:21:56 +0000 (08:21 -0300)
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
argument.

Amended by db: move news item to UNRELEASED.

NEWS
emacs/notmuch-mua.el

diff --git a/NEWS b/NEWS
index c18d63d3212aaba4873e12c0d02780f63b5c4ec9..44551b82960a73c039fe01a118a8de63224cc11a 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,12 @@
+Notmuch 0.37 (UNRELEASED)
+=========================
+
+Emacs
+-----
+
+The function `notmuch-mua-mail` now moves point depending on the
+provided arguments.
+
 Notmuch 0.36 (2022-04-25)
 =========================
 
index 60801f4be7d331269a578599c00abc2c0cc5c831..0ae331271dbfbc508d8b1f8be2841bb528d0f352 100644 (file)
@@ -385,7 +385,13 @@ instead of `message-mode' and SWITCH-FUNCTION is mandatory."
 (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."
   (interactive)
   (when notmuch-mua-user-agent-function
     (let ((user-agent (funcall notmuch-mua-user-agent-function)))
@@ -420,7 +426,10 @@ instead of `message-mode' and SWITCH-FUNCTION is mandatory."
   (message-hide-headers)
   (set-buffer-modified-p nil)
   (notmuch-mua-maybe-set-window-dedicated)
-  (message-goto-to))
+  (cond
+   ((and to subject) (message-goto-body))
+   (to (message-goto-subject))
+   (t (message-goto-to))))
 
 (defvar notmuch-mua-sender-history nil)