unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Damien Cassou <damien@cassou.me>
To: notmuch@notmuchmail.org
Cc: Damien Cassou <damien@cassou.me>
Subject: [PATCH v2] emacs: change where notmuch-mua-mail moves point
Date: Wed,  1 Jun 2022 21:50:48 +0200	[thread overview]
Message-ID: <20220601195048.166397-1-damien@cassou.me> (raw)

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.

---

- 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
 operations.
 
+The function `notmuch-mua-mail` now moves point depending on the
+provided arguments.
+
 Tests
 -----
 
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."
   (interactive)
   (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
   (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)
 
-- 
2.36.0

             reply	other threads:[~2022-06-01 19:51 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-01 19:50 Damien Cassou [this message]
2022-06-02 11:24 ` [PATCH v2] emacs: change where notmuch-mua-mail moves point David Bremner
2022-06-02 15:07   ` Damien Cassou
2022-06-02 15:29     ` David Bremner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220601195048.166397-1-damien@cassou.me \
    --to=damien@cassou.me \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).