* BUG: notmuch-emacs-mua wrong signing MML placement
@ 2019-12-11 18:55 Robbie Harwood
2019-12-12 9:46 ` message.el and browse-url.el interaction [was: Re: BUG: notmuch-emacs-mua wrong signing MML placement] David Edmondson
0 siblings, 1 reply; 5+ messages in thread
From: Robbie Harwood @ 2019-12-11 18:55 UTC (permalink / raw)
To: notmuch
[-- Attachment #1: Type: text/plain, Size: 540 bytes --]
Hello, I brought this up on IRC and was advised to post here.
My emacs config contains `(add-hook 'message-setup-hook
'mml-secure-sign-pgpmime)` as recommended in the emacstips
https://notmuchmail.org/emacstips/#index14h2
However, when I run (something like):
notmuch-emacs-mua 'mailto:testto?body=testbody'
I get an email in which the requested body contents appear *before* the
signing MML. If I understand correctly how this all fits together, that
won't do the right thing - but at any rate, it's unexpected.
Thanks,
--Robbie
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* message.el and browse-url.el interaction [was: Re: BUG: notmuch-emacs-mua wrong signing MML placement]
2019-12-11 18:55 BUG: notmuch-emacs-mua wrong signing MML placement Robbie Harwood
@ 2019-12-12 9:46 ` David Edmondson
2019-12-12 22:21 ` Tomi Ollila
0 siblings, 1 reply; 5+ messages in thread
From: David Edmondson @ 2019-12-12 9:46 UTC (permalink / raw)
To: Robbie Harwood, notmuch; +Cc: emacs-devel
On Wednesday, 2019-12-11 at 13:55:16 -05, Robbie Harwood wrote:
> My emacs config contains `(add-hook 'message-setup-hook
> 'mml-secure-sign-pgpmime)` as recommended in the emacstips
> https://notmuchmail.org/emacstips/#index14h2
>
> However, when I run (something like):
>
> notmuch-emacs-mua 'mailto:testto?body=testbody'
>
> I get an email in which the requested body contents appear *before* the
> signing MML. If I understand correctly how this all fits together, that
> won't do the right thing - but at any rate, it's unexpected.
This is an unfortunate interaction between message.el and browse-url.el
and isn't specific to notmuch or notmuch-emacs-mua.
You can see the same behaviour in “emacs -Q -q” if you execute:
(progn
(add-hook 'message-setup-hook 'mml-secure-sign-pgpmime)
(browse-url-mail "mailto:fred?body=testbody"))
Given that, it's not something that we should be fixing in notmuch
itself, as it's an emacs bug.
The problem is that `browse-url-mail' always inserts the body after the
header separator, which in this case happens after
`mml-secure-sign-pgpmime' has already inserted the MML header.
Having `browse-url-mail' insert the body at the end of the message would
work for this case, but would presumably make a mess of situations where
someone inserts their signature block via `message-setup-hook'.
Perhaps `browse-url-mail' should skip past any MML headers before
inserting the body? That's a bit messy, as browse-url.el currently
doesn't know anything about MML.
The nicest fix would perhaps be to have `compose-mail' accept the
initial body as a parameter, which would eventually flow into the
relevant code in message.el which could do the right thing (which I
think would just be to skip past MML headers before inserting the body).
Any advice from emacs-devel on how to move forward? I'm happy to produce
a patch for whatever solution is considered most appropriate.
dme.
--
If the girls start moving the boys will start moving.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: message.el and browse-url.el interaction [was: Re: BUG: notmuch-emacs-mua wrong signing MML placement]
2019-12-12 9:46 ` message.el and browse-url.el interaction [was: Re: BUG: notmuch-emacs-mua wrong signing MML placement] David Edmondson
@ 2019-12-12 22:21 ` Tomi Ollila
2019-12-13 7:33 ` Tomi Ollila
0 siblings, 1 reply; 5+ messages in thread
From: Tomi Ollila @ 2019-12-12 22:21 UTC (permalink / raw)
To: notmuch; +Cc: emacs-devel
On Thu, Dec 12 2019, David Edmondson wrote:
> On Wednesday, 2019-12-11 at 13:55:16 -05, Robbie Harwood wrote:
>
>> My emacs config contains `(add-hook 'message-setup-hook
>> 'mml-secure-sign-pgpmime)` as recommended in the emacstips
>> https://notmuchmail.org/emacstips/#index14h2
>>
>> However, when I run (something like):
>>
>> notmuch-emacs-mua 'mailto:testto?body=testbody'
>>
>> I get an email in which the requested body contents appear *before* the
>> signing MML. If I understand correctly how this all fits together, that
>> won't do the right thing - but at any rate, it's unexpected.
>
> This is an unfortunate interaction between message.el and browse-url.el
> and isn't specific to notmuch or notmuch-emacs-mua.
>
> You can see the same behaviour in “emacs -Q -q” if you execute:
>
> (progn
> (add-hook 'message-setup-hook 'mml-secure-sign-pgpmime)
> (browse-url-mail "mailto:fred?body=testbody"))
>
> Given that, it's not something that we should be fixing in notmuch
> itself, as it's an emacs bug.
>
> The problem is that `browse-url-mail' always inserts the body after the
> header separator, which in this case happens after
> `mml-secure-sign-pgpmime' has already inserted the MML header.
>
> Having `browse-url-mail' insert the body at the end of the message would
> work for this case, but would presumably make a mess of situations where
> someone inserts their signature block via `message-setup-hook'.
>
> Perhaps `browse-url-mail' should skip past any MML headers before
> inserting the body? That's a bit messy, as browse-url.el currently
> doesn't know anything about MML.
I've never found `browse-url-mail' adequate for handling mailto: links,
so couple of years ago I wrote mailto: "wrapper" of my own (*). It,
among other things, spits the following elisp for emacs to swallow:
(with-demoted-errors
(require 'notmuch)
(notmuch-mua-mail "fred" nil nil nil
(notmuch-mua-get-switch-function))
(cd "/home/too/vc/projects/nottoomuch")
(message-goto-body) (insert "testbody")
(goto-char (point-max))
(if (/= (point) (line-beginning-position))
(newline))
(set-buffer-modified-p nil) (message-goto-to))
Surprise! this has exactly the same problems as David explains above; I
could add code to check for this [#part sign=pgpmime] (**) and skip it if
it exists (and, as first step, not look for anything else to skip). That
is just so hacky and error prone I would not like to do so (at least as
a general solution)...
>
> The nicest fix would perhaps be to have `compose-mail' accept the
> initial body as a parameter, which would eventually flow into the
> relevant code in message.el which could do the right thing (which I
> think would just be to skip past MML headers before inserting the body).
This suggestion of an optional parameter to take initial body sounds
very good solution (as first sight =D), so if I don't come up with
any other suggestions +1 for that..
>
> Any advice from emacs-devel on how to move forward? I'm happy to produce
> a patch for whatever solution is considered most appropriate.
>
> dme.
> --
> If the girls start moving the boys will start moving.
Tomi
(*) https://github.com/domo141/nottoomuch/blob/master/nottoomuch-emacs-mailto.rst
(**) replace [...] with <...>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: message.el and browse-url.el interaction [was: Re: BUG: notmuch-emacs-mua wrong signing MML placement]
2019-12-12 22:21 ` Tomi Ollila
@ 2019-12-13 7:33 ` Tomi Ollila
2019-12-13 10:20 ` David Edmondson
0 siblings, 1 reply; 5+ messages in thread
From: Tomi Ollila @ 2019-12-13 7:33 UTC (permalink / raw)
To: notmuch; +Cc: emacs-devel
On Fri, Dec 13 2019, Tomi Ollila wrote:
> On Thu, Dec 12 2019, David Edmondson wrote:
>
>> On Wednesday, 2019-12-11 at 13:55:16 -05, Robbie Harwood wrote:
>>
>>> My emacs config contains `(add-hook 'message-setup-hook
>>> 'mml-secure-sign-pgpmime)` as recommended in the emacstips
>>> https://notmuchmail.org/emacstips/#index14h2
>>>
>>> However, when I run (something like):
>>>
>>> notmuch-emacs-mua 'mailto:testto?body=testbody'
>>>
>>> I get an email in which the requested body contents appear *before* the
>>> signing MML. If I understand correctly how this all fits together, that
>>> won't do the right thing - but at any rate, it's unexpected.
>>
>> This is an unfortunate interaction between message.el and browse-url.el
>> and isn't specific to notmuch or notmuch-emacs-mua.
>>
>> You can see the same behaviour in “emacs -Q -q” if you execute:
>>
>> (progn
>> (add-hook 'message-setup-hook 'mml-secure-sign-pgpmime)
>> (browse-url-mail "mailto:fred?body=testbody"))
>>
>> Given that, it's not something that we should be fixing in notmuch
>> itself, as it's an emacs bug.
>>
>> The problem is that `browse-url-mail' always inserts the body after the
>> header separator, which in this case happens after
>> `mml-secure-sign-pgpmime' has already inserted the MML header.
>>
>> Having `browse-url-mail' insert the body at the end of the message would
>> work for this case, but would presumably make a mess of situations where
>> someone inserts their signature block via `message-setup-hook'.
>>
>> Perhaps `browse-url-mail' should skip past any MML headers before
>> inserting the body? That's a bit messy, as browse-url.el currently
>> doesn't know anything about MML.
>
> I've never found `browse-url-mail' adequate for handling mailto: links,
> so couple of years ago I wrote mailto: "wrapper" of my own (*). It,
> among other things, spits the following elisp for emacs to swallow:
>
> (with-demoted-errors
> (require 'notmuch)
> (notmuch-mua-mail "fred" nil nil nil
> (notmuch-mua-get-switch-function))
> (cd "/home/too/vc/projects/nottoomuch")
> (message-goto-body) (insert "testbody")
> (goto-char (point-max))
> (if (/= (point) (line-beginning-position))
> (newline))
> (set-buffer-modified-p nil) (message-goto-to))
Small update from my front -- looked message.el and (message-setup-1)
there in particular, and then tested the following code:
(with-demoted-errors
(require 'notmuch)
(let ((message-signature-setup-hook message-signature-setup-hook))
(add-hook 'message-signature-setup-hook
(lambda () (message-goto-body) (insert "testbody")
(if (/= (point) (line-beginning-position))
(newline))))
(notmuch-mua-mail "fred" nil nil nil
(notmuch-mua-get-switch-function))
))
This has moderate chance of working, so I'll have to think it a bit
further (and clean up the code =D)...
>
> Surprise! this has exactly the same problems as David explains above; I
> could add code to check for this [#part sign=pgpmime] (**) and skip it if
> it exists (and, as first step, not look for anything else to skip). That
> is just so hacky and error prone I would not like to do so (at least as
> a general solution)...
>
>>
>> The nicest fix would perhaps be to have `compose-mail' accept the
>> initial body as a parameter, which would eventually flow into the
>> relevant code in message.el which could do the right thing (which I
>> think would just be to skip past MML headers before inserting the body).
>
> This suggestion of an optional parameter to take initial body sounds
> very good solution (as first sight =D), so if I don't come up with
> any other suggestions +1 for that..
>
>>
>> Any advice from emacs-devel on how to move forward? I'm happy to produce
>> a patch for whatever solution is considered most appropriate.
>>
>> dme.
>> --
>> If the girls start moving the boys will start moving.
>
> Tomi
>
> (*) https://github.com/domo141/nottoomuch/blob/master/nottoomuch-emacs-mailto.rst
>
> (**) replace [...] with <...>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: message.el and browse-url.el interaction [was: Re: BUG: notmuch-emacs-mua wrong signing MML placement]
2019-12-13 7:33 ` Tomi Ollila
@ 2019-12-13 10:20 ` David Edmondson
0 siblings, 0 replies; 5+ messages in thread
From: David Edmondson @ 2019-12-13 10:20 UTC (permalink / raw)
To: Tomi Ollila, notmuch; +Cc: emacs-devel
On Friday, 2019-12-13 at 09:33:11 +02, Tomi Ollila wrote:
> Small update from my front -- looked message.el and (message-setup-1)
> there in particular, and then tested the following code:
>
> (with-demoted-errors
> (require 'notmuch)
> (let ((message-signature-setup-hook message-signature-setup-hook))
> (add-hook 'message-signature-setup-hook
> (lambda () (message-goto-body) (insert "testbody")
> (if (/= (point) (line-beginning-position))
> (newline))))
> (notmuch-mua-mail "fred" nil nil nil
> (notmuch-mua-get-switch-function))
> ))
>
> This has moderate chance of working, so I'll have to think it a bit
> further (and clean up the code =D)...
This seems like liberal abuse of `message-signature-setup-hook' :-)
It's also message.el specific, which may not matter. The `compose-mail'
argument approach should in principle work with all mail-user-agent
settings.
dme.
--
Why stay in college? Why go to night school?
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2019-12-13 10:20 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-11 18:55 BUG: notmuch-emacs-mua wrong signing MML placement Robbie Harwood
2019-12-12 9:46 ` message.el and browse-url.el interaction [was: Re: BUG: notmuch-emacs-mua wrong signing MML placement] David Edmondson
2019-12-12 22:21 ` Tomi Ollila
2019-12-13 7:33 ` Tomi Ollila
2019-12-13 10:20 ` David Edmondson
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).