unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH] Fix notmuch-mua.el notmuch-mua-mail
@ 2022-05-22  7:08 Damien Cassou
  2022-05-23  6:21 ` Damien Cassou
  0 siblings, 1 reply; 6+ messages in thread
From: Damien Cassou @ 2022-05-22  7:08 UTC (permalink / raw)
  To: notmuch

[-- Attachment #1: Type: text/plain, Size: 888 bytes --]

Hi,

Emacs' `mail-user-agent` variable specifies several options and
notmuch-mua.el defines a new one that can be used with:

  (setq mail-user-agent 'notmuch-user-agent)

This setup works well except that notmuch-mua-mail moves point to the TO
header at the end whereas message, sendmail and gnus all move point to
the BODY. This is ok because nothing in the Emacs documentation says
that point should be in the BODY but some functions expect it there such
as submit-emacs-patch: I sent a fix upstream in
https://debbugs.gnu.org/cgi/bugreport.cgi?bug=55571 so point doesn't
have to be in the BODY at then end.

The attached patch makes sure that notmuch-mua-mail moves point to the
BODY at the end so that its behavior is closer to the one of other MUAs.

Best

-- 
Damien Cassou

"Success is the ability to go from one failure to another without
losing enthusiasm." --Winston Churchill

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: fix-notmuch-mua-mail.patch --]
[-- Type: text/x-patch, Size: 323 bytes --]

--- notmuch-mua.el	1970-01-01 01:00:01.000000000 +0100
+++ notmuch-mua2.el	2022-05-22 08:58:10.073043741 +0200
@@ -418,7 +418,7 @@
   (message-hide-headers)
   (set-buffer-modified-p nil)
   (notmuch-mua-maybe-set-window-dedicated)
-  (message-goto-to))
+  (message-goto-body))
 
 (defvar notmuch-mua-sender-history nil)
 

[-- Attachment #3: Type: text/plain, Size: 0 bytes --]



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] Fix notmuch-mua.el notmuch-mua-mail
  2022-05-22  7:08 [PATCH] Fix notmuch-mua.el notmuch-mua-mail Damien Cassou
@ 2022-05-23  6:21 ` Damien Cassou
  2022-06-01  9:49   ` David Bremner
  0 siblings, 1 reply; 6+ messages in thread
From: Damien Cassou @ 2022-05-23  6:21 UTC (permalink / raw)
  To: notmuch

[-- Attachment #1: Type: text/plain, Size: 311 bytes --]

Here is a new version of the patch that takes into account the fact that
notmuch-mua-mail can also be called interactively by notmuch and not
only through the mail-user-agent variable.

-- 
Damien Cassou

"Success is the ability to go from one failure to another without
losing enthusiasm." --Winston Churchill

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Change-where-to-move-point-at-the-end-of-notmuch-mua.patch --]
[-- Type: text/x-patch, Size: 1030 bytes --]

From 6106765b56464edc649d73916f97208b67ef5eb4 Mon Sep 17 00:00:00 2001
From: Damien Cassou <damien@cassou.me>
Date: Mon, 23 May 2022 08:17:27 +0200
Subject: [PATCH] Change where to move point at the end of `notmuch-mua-mail`

* emacs/notmuch-mua.el (notmuch-mua-mail): 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.
---
 emacs/notmuch-mua.el | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el
index 60801f4b..4ee252f2 100644
--- a/emacs/notmuch-mua.el
+++ b/emacs/notmuch-mua.el
@@ -420,7 +420,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


[-- Attachment #3: Type: text/plain, Size: 0 bytes --]



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] Fix notmuch-mua.el notmuch-mua-mail
  2022-05-23  6:21 ` Damien Cassou
@ 2022-06-01  9:49   ` David Bremner
  2022-06-01 19:57     ` Damien Cassou
  0 siblings, 1 reply; 6+ messages in thread
From: David Bremner @ 2022-06-01  9:49 UTC (permalink / raw)
  To: Damien Cassou, notmuch


If possible, please use git-send-email, as it makes applying the patches
easier.

Damien Cassou <damien@cassou.me> writes:

> From 6106765b56464edc649d73916f97208b67ef5eb4 Mon Sep 17 00:00:00 2001
> From: Damien Cassou <damien@cassou.me>
> Date: Mon, 23 May 2022 08:17:27 +0200
> Subject: [PATCH] Change where to move point at the end of `notmuch-mua-mail`
>
> * emacs/notmuch-mua.el (notmuch-mua-mail): 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.

It's a minor issue, but...

Our conventions for commit messages are different than emacs [1], we don't
list filenames in the commit message but we do usually list the
"subsystem" in the subject [2]

> ---
>  emacs/notmuch-mua.el | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el
> index 60801f4b..4ee252f2 100644
> --- a/emacs/notmuch-mua.el
> +++ b/emacs/notmuch-mua.el
> @@ -420,7 +420,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))))

I think the cursor positioning behaviour should be documented in the
function docstring. 

[1]: It might be a personal issue, but the emacs commit message style
really annoys me.

[2]: https://notmuchmail.org/contributing/ "Write meaningful commit messages"

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] Fix notmuch-mua.el notmuch-mua-mail
  2022-06-01  9:49   ` David Bremner
@ 2022-06-01 19:57     ` Damien Cassou
  2022-06-02 11:12       ` David Bremner
  0 siblings, 1 reply; 6+ messages in thread
From: Damien Cassou @ 2022-06-01 19:57 UTC (permalink / raw)
  To: David Bremner, notmuch

Hi David,

David Bremner <david@tethera.net> writes:
> If possible, please use git-send-email, as it makes applying the patches
> easier.


I've sent a new version in <20220601195048.166397-1-damien@cassou.me>. I
hope I followed all recommendations. If I didn't, please tell me so I
can do better next time.

Can you please explain me what in git-send-email makes it easier to
apply the patches? I'm also interested in your process to apply patches
from your mua (notmuch in Emacs hopefully) to your git repository.

> Our conventions for commit messages are different than emacs [1], we
> don't list filenames in the commit message but we do usually list the
> "subsystem" in the subject [2]


I'm sorry I completely forgot to have a look at the conventions before
sending.

> I think the cursor positioning behaviour should be documented in the
> function docstring. 


done


> [1]: It might be a personal issue, but the emacs commit message style
> really annoys me.


I also don't like it. I think it focuses too much on what has changed
(something that could be inferred from the patch with a little tooling)
instead of why the code has changed this way (something only the author
can tell).

-- 
Damien Cassou

"Success is the ability to go from one failure to another without
losing enthusiasm." --Winston Churchill

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] Fix notmuch-mua.el notmuch-mua-mail
  2022-06-01 19:57     ` Damien Cassou
@ 2022-06-02 11:12       ` David Bremner
  2022-06-02 12:53         ` Damien Cassou
  0 siblings, 1 reply; 6+ messages in thread
From: David Bremner @ 2022-06-02 11:12 UTC (permalink / raw)
  To: Damien Cassou, notmuch

[-- Attachment #1: Type: text/plain, Size: 1655 bytes --]

Damien Cassou <damien@cassou.me> writes:

> Hi David,
>
> Can you please explain me what in git-send-email makes it easier to
> apply the patches?  I'm also interested in your process to apply
> patches from your mua (notmuch in Emacs hopefully) to your git
> repository.

There are some convenient tools for applying patches from notmuch in
Sean Whitton's mailscripts collection [1]. I tend to work in the shell
with some git aliases.

        [alias]
                nmam = "!f() { notmuch extract-patch $1 | git am -; }; f"

        [alias]
                nmam8 = "!f() { notmuch extract-patch $1 | email-to-8bit |  git am -; }; f"

        [alias]
                nmam3 = "!f() { notmuch extract-patch $1 | git am -3 -; }; f"
                
I use "c i" to copy the message id, and then paste it into a command
line
        $ git nmam <paste id here>

email-to-8bit is a little hack to work around mailman induced damage to
patches; it seems less needed with new versions of git.

notmuch-extract-patch is from mailscripts, and it fails (well, fails to
extract any patch) with attached
patches. I used to use

         notmuch show --format=raw

in place of "notmuch extract-patch". This succeeds in extracting a
patch, but smashes the body text together with the commit message in the
resulting commit.

>> [ about emacs git commit messages ]

> I think it focuses too much on what has changed
> (something that could be inferred from the patch with a little tooling)
> instead of why the code has changed this way (something only the author
> can tell).

Exactly.


[1]: https://git.spwhitton.name/mailscripts
     also available in e.g. Debian.


[-- Attachment #2: email-to-8bit --]
[-- Type: application/octet-stream, Size: 667 bytes --]

#!/usr/bin/env python3

import sys
import email
import email.policy
import logging
from email.charset import Charset
from email.message import EmailMessage

def main():
    msg = email.message_from_file(sys.stdin,policy=email.policy.default)

    if isinstance(msg, EmailMessage):
        body = msg.get_payload(decode=True).decode(encoding='utf8')
        msg.replace_header('Content-Transfer-Encoding','8bit')
        for field in msg.keys():
            print("{:s}: {:s}".format(field,msg[field]))
        print("")
        print(body.replace('\r\n','\n'))
    else:
        logging.error('Input was not an e-mail message')

if __name__ == '__main__':
    main()

[-- Attachment #3: Type: text/plain, Size: 0 bytes --]



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] Fix notmuch-mua.el notmuch-mua-mail
  2022-06-02 11:12       ` David Bremner
@ 2022-06-02 12:53         ` Damien Cassou
  0 siblings, 0 replies; 6+ messages in thread
From: Damien Cassou @ 2022-06-02 12:53 UTC (permalink / raw)
  To: David Bremner, notmuch

David Bremner <david@tethera.net> writes:
> There are some convenient tools for applying patches from notmuch in
> Sean Whitton's mailscripts collection [1]. I tend to work in the shell
> with some git aliases…

thank you very much for your explanations!

-- 
Damien Cassou

"Success is the ability to go from one failure to another without
losing enthusiasm." --Winston Churchill\r

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-06-02 12:53 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-22  7:08 [PATCH] Fix notmuch-mua.el notmuch-mua-mail Damien Cassou
2022-05-23  6:21 ` Damien Cassou
2022-06-01  9:49   ` David Bremner
2022-06-01 19:57     ` Damien Cassou
2022-06-02 11:12       ` David Bremner
2022-06-02 12:53         ` Damien Cassou

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).