* message.el and browse-url.el interaction [was: Re: BUG: notmuch-emacs-mua wrong signing MML placement] [not found] ` <jlgo8we3d63.fsf-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> @ 2019-12-12 9:46 ` David Edmondson [not found] ` <m2o8wdc1vv.fsf-zDQXUQW/Few@public.gmane.org> 0 siblings, 1 reply; 4+ messages in thread From: David Edmondson @ 2019-12-12 9:46 UTC (permalink / raw) To: Robbie Harwood, notmuch-gxuj+Tv9EO5zyzON3hdc1g; +Cc: emacs-devel-mXXj517/zsQ 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. _______________________________________________ notmuch mailing list notmuch@notmuchmail.org https://notmuchmail.org/mailman/listinfo/notmuch ^ permalink raw reply [flat|nested] 4+ messages in thread
[parent not found: <m2o8wdc1vv.fsf-zDQXUQW/Few@public.gmane.org>]
* Re: message.el and browse-url.el interaction [was: Re: BUG: notmuch-emacs-mua wrong signing MML placement] [not found] ` <m2o8wdc1vv.fsf-zDQXUQW/Few@public.gmane.org> @ 2019-12-12 22:21 ` Tomi Ollila [not found] ` <m2immlyyl1.fsf-2dKNzN3HlsqBABcRff0nKcc4bpwCjbIv@public.gmane.org> 0 siblings, 1 reply; 4+ messages in thread From: Tomi Ollila @ 2019-12-12 22:21 UTC (permalink / raw) To: notmuch-gxuj+Tv9EO5zyzON3hdc1g; +Cc: emacs-devel-mXXj517/zsQ 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 <...> _______________________________________________ notmuch mailing list notmuch@notmuchmail.org https://notmuchmail.org/mailman/listinfo/notmuch ^ permalink raw reply [flat|nested] 4+ messages in thread
[parent not found: <m2immlyyl1.fsf-2dKNzN3HlsqBABcRff0nKcc4bpwCjbIv@public.gmane.org>]
* Re: message.el and browse-url.el interaction [was: Re: BUG: notmuch-emacs-mua wrong signing MML placement] [not found] ` <m2immlyyl1.fsf-2dKNzN3HlsqBABcRff0nKcc4bpwCjbIv@public.gmane.org> @ 2019-12-13 7:33 ` Tomi Ollila [not found] ` <m2h824llxk.fsf-2dKNzN3HlsqBABcRff0nKcc4bpwCjbIv@public.gmane.org> 0 siblings, 1 reply; 4+ messages in thread From: Tomi Ollila @ 2019-12-13 7:33 UTC (permalink / raw) To: notmuch-gxuj+Tv9EO5zyzON3hdc1g; +Cc: emacs-devel-mXXj517/zsQ 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 <...> _______________________________________________ notmuch mailing list notmuch@notmuchmail.org https://notmuchmail.org/mailman/listinfo/notmuch ^ permalink raw reply [flat|nested] 4+ messages in thread
[parent not found: <m2h824llxk.fsf-2dKNzN3HlsqBABcRff0nKcc4bpwCjbIv@public.gmane.org>]
* Re: message.el and browse-url.el interaction [was: Re: BUG: notmuch-emacs-mua wrong signing MML placement] [not found] ` <m2h824llxk.fsf-2dKNzN3HlsqBABcRff0nKcc4bpwCjbIv@public.gmane.org> @ 2019-12-13 10:20 ` David Edmondson 0 siblings, 0 replies; 4+ messages in thread From: David Edmondson @ 2019-12-13 10:20 UTC (permalink / raw) To: Tomi Ollila, notmuch-gxuj+Tv9EO5zyzON3hdc1g; +Cc: emacs-devel-mXXj517/zsQ 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] 4+ messages in thread
end of thread, other threads:[~2019-12-13 10:20 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- [not found] <jlgo8we3d63.fsf@redhat.com> [not found] ` <jlgo8we3d63.fsf-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> 2019-12-12 9:46 ` message.el and browse-url.el interaction [was: Re: BUG: notmuch-emacs-mua wrong signing MML placement] David Edmondson [not found] ` <m2o8wdc1vv.fsf-zDQXUQW/Few@public.gmane.org> 2019-12-12 22:21 ` Tomi Ollila [not found] ` <m2immlyyl1.fsf-2dKNzN3HlsqBABcRff0nKcc4bpwCjbIv@public.gmane.org> 2019-12-13 7:33 ` Tomi Ollila [not found] ` <m2h824llxk.fsf-2dKNzN3HlsqBABcRff0nKcc4bpwCjbIv@public.gmane.org> 2019-12-13 10:20 ` David Edmondson
Code repositories for project(s) associated with this external index https://git.savannah.gnu.org/cgit/emacs.git https://git.savannah.gnu.org/cgit/emacs/org-mode.git This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.