* xdg-email vs browse-url-mail @ 2016-07-14 12:51 Kevin Brubeck Unhammer 2016-07-14 21:09 ` Dmitry Alexandrov 0 siblings, 1 reply; 7+ messages in thread From: Kevin Brubeck Unhammer @ 2016-07-14 12:51 UTC (permalink / raw) To: info-gnus-english Hi, I just tried using browse-url-mail as a mailto-handler with the below script as my mail handler (set in XFCE settings): #!/bin/bash mailto="${*//\"/}" if [[ ! ${mailto} =~ ^mailto: ]]; then mailto="mailto:${mailto}" fi emacsclient -c --eval "(browse-url-mail \"${mailto}\")" It seems to work with xdg-email, but when I use --attach to attach a file, it just appears as an "Attach: /path/to/file" header instead of the usual <#part thing. After sending, nothing is attached to the received message that I can tell. Is there a way to make browse-url-mail do the right thing, or to make message-mode treat that "Attach:" line correctly? -- Kevin Brubeck Unhammer GPG: 0x766AC60C ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: xdg-email vs browse-url-mail 2016-07-14 12:51 xdg-email vs browse-url-mail Kevin Brubeck Unhammer @ 2016-07-14 21:09 ` Dmitry Alexandrov 2016-07-15 8:31 ` Kevin Brubeck Unhammer 0 siblings, 1 reply; 7+ messages in thread From: Dmitry Alexandrov @ 2016-07-14 21:09 UTC (permalink / raw) To: Kevin Brubeck Unhammer; +Cc: info-gnus-english [-- Attachment #1: Type: text/plain, Size: 784 bytes --] Kevin Brubeck Unhammer <unhammer@fsfe.org> writes: > I just tried using browse-url-mail as a mailto-handler with the below > script as my mail handler (set in XFCE settings): > > #!/bin/bash > mailto="${*//\"/}" ... > if [[ ! ${mailto} =~ ^mailto: ]]; then > mailto="mailto:${mailto}" > fi Does not xdg-email(1) already do that? > emacsclient -c --eval "(browse-url-mail \"${mailto}\")" > > It seems to work with xdg-email, but when I use --attach to attach a > file, it just appears as an "Attach: /path/to/file" header instead of > the usual <#part thing. After sending, nothing is attached to the > received message that I can tell. Is there a way to make browse-url-mail > do the right thing, or to make message-mode treat that "Attach:" line > correctly? Try this: [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: browse-url-mail.patch --] [-- Type: text/x-diff, Size: 2886 bytes --] diff --git a/lisp/net/browse-url.el b/lisp/net/browse-url.el index c0b3591..a4d47f6 100644 --- a/lisp/net/browse-url.el +++ b/lisp/net/browse-url.el @@ -1562,31 +1562,42 @@ When called non-interactively, optional second argument NEW-WINDOW is used instead of `browse-url-new-window-flag'." (interactive (browse-url-interactive-arg "Mailto URL: ")) (save-excursion - (let* ((alist (rfc2368-parse-mailto-url url)) - (to (assoc "To" alist)) - (subject (assoc "Subject" alist)) - (body (assoc "Body" alist)) - (rest (delq to (delq subject (delq body alist)))) - (to (cdr to)) - (subject (cdr subject)) - (body (cdr body)) - (mail-citation-hook (unless body mail-citation-hook))) - (if (browse-url-maybe-new-window new-window) - (compose-mail-other-window to subject rest nil - (list 'insert-buffer (current-buffer))) - (compose-mail to subject rest nil nil - (list 'insert-buffer (current-buffer)))) - (when body - (goto-char (point-min)) - (unless (or (search-forward (concat "\n" mail-header-separator "\n") - nil 'move) - (bolp)) - (insert "\n")) - (goto-char (prog1 - (point) - (insert (replace-regexp-in-string "\r\n" "\n" body)) - (unless (bolp) - (insert "\n")))))))) + (let ((headers (rfc2368-parse-mailto-url url)) + to subject body attaches rest) + (dolist (header headers) + (cond + ((equal (car header) "To") + (setq to (cdr header))) + ((equal (car header) "Subject") + (setq subject (cdr header))) + ((equal (car header) "Body") + (setq body (cdr header))) + ((equal (car header) "Attach") + (add-to-list 'attaches (cdr header))) + (t + (push header rest)))) + (let ((mail-citation-hook (unless body mail-citation-hook))) + (if (browse-url-maybe-new-window new-window) + (compose-mail-other-window to subject rest nil + (list 'insert-buffer (current-buffer))) + (compose-mail to subject rest nil nil + (list 'insert-buffer (current-buffer)))) + (when body + (goto-char (point-min)) + (unless (or (search-forward (concat "\n" mail-header-separator "\n") + nil 'move) + (bolp)) + (insert "\n")) + (goto-char (prog1 + (point) + (insert (replace-regexp-in-string "\r\n" "\n" body)) + (unless (bolp) + (insert "\n"))))) + (when attaches + (if (not mml-mode) + (error "Enable MML mode if you want to attach files") + (dolist (attach attaches) + (mml-attach-file attach nil nil "attachment")))))))) ;; --- Random browser --- [-- Attachment #3: Type: text/plain, Size: 85 bytes --] (Note, that I have virtually no experience with elisp, so use at your own risk. :-) ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: xdg-email vs browse-url-mail 2016-07-14 21:09 ` Dmitry Alexandrov @ 2016-07-15 8:31 ` Kevin Brubeck Unhammer 2016-07-15 18:29 ` Dmitry Alexandrov 0 siblings, 1 reply; 7+ messages in thread From: Kevin Brubeck Unhammer @ 2016-07-15 8:31 UTC (permalink / raw) To: info-gnus-english; +Cc: Dmitry Alexandrov [-- Attachment #1.1: Type: text/plain, Size: 1466 bytes --] Dmitry Alexandrov <321942@gmail.com> čálii: > Kevin Brubeck Unhammer <unhammer@fsfe.org> writes: > >> I just tried using browse-url-mail as a mailto-handler with the below >> script as my mail handler (set in XFCE settings): >> >> #!/bin/bash >> mailto="${*//\"/}" > > ... > >> if [[ ! ${mailto} =~ ^mailto: ]]; then >> mailto="mailto:${mailto}" >> fi > > Does not xdg-email(1) already do that? No. Try 'echo "$@">/tmp/log' at the top of your mail script. >> It seems to work with xdg-email, but when I use --attach to attach a >> file, it just appears as an "Attach: /path/to/file" header instead of >> the usual <#part thing. After sending, nothing is attached to the >> received message that I can tell. Is there a way to make browse-url-mail >> do the right thing, or to make message-mode treat that "Attach:" line >> correctly? > > Try this: > [...] > (Note, that I have virtually no experience with elisp, so use at your > own risk. :-) That worked! And even handles multiple attachments correctly, even though xdg-email uses multiple "attach" headers (which https://tools.ietf.org/html/rfc6068#page-6 warns against). Maybe open a bug report on this? It looks like an improvement to me. I don't know how attachments are handled by other mailto-users though – multiple identical hfname's or some separator in the hfvalue like with the "to" header? -- Kevin Brubeck Unhammer GPG: 0x766AC60C [-- Attachment #1.2: signature.asc --] [-- Type: application/pgp-signature, Size: 818 bytes --] ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: xdg-email vs browse-url-mail 2016-07-15 8:31 ` Kevin Brubeck Unhammer @ 2016-07-15 18:29 ` Dmitry Alexandrov 2016-07-15 21:16 ` Kevin Brubeck Unhammer 0 siblings, 1 reply; 7+ messages in thread From: Dmitry Alexandrov @ 2016-07-15 18:29 UTC (permalink / raw) To: Kevin Brubeck Unhammer; +Cc: info-gnus-english [-- Attachment #1: Type: text/plain, Size: 1974 bytes --] Kevin Brubeck Unhammer <unhammer@fsfe.org> writes: > Dmitry Alexandrov <321942@gmail.com> čálii: > >> Kevin Brubeck Unhammer <unhammer@fsfe.org> writes: >> >>> I just tried using browse-url-mail as a mailto-handler with the below >>> script as my mail handler (set in XFCE settings): >>> >>> #!/bin/bash >>> mailto="${*//\"/}" >> >> ... >> >>> if [[ ! ${mailto} =~ ^mailto: ]]; then >>> mailto="mailto:${mailto}" >>> fi >> >> Does not xdg-email(1) already do that? > > No. Try 'echo "$@">/tmp/log' at the top of your mail script. I tried: --8<---------------cut here---------------start------------->8--- $ xdg-email --version xdg-email 1.1.0 rc1 $ cat /tmp/xdg-test #!/bin/bash echo "$@" > /tmp/xdg-test.log $ xdg-email foo@example.org $ cat /tmp/xdg-test.log mailto:foo@example.org --8<---------------cut here---------------end--------------->8--- >>> It seems to work with xdg-email, but when I use --attach to attach a >>> file, it just appears as an "Attach: /path/to/file" header instead of >>> the usual <#part thing. After sending, nothing is attached to the >>> received message that I can tell. Is there a way to make browse-url-mail >>> do the right thing, or to make message-mode treat that "Attach:" line >>> correctly? >> >> Try this: >> > > [...] > >> (Note, that I have virtually no experience with elisp, so use at your >> own risk. :-) > > That worked! And even handles multiple attachments correctly, even > though xdg-email uses multiple "attach" headers (which > https://tools.ietf.org/html/rfc6068#page-6 warns against). Maybe open a > bug report on this? It looks like an improvement to me. Hmm... Do you mean that I have to open a bug report? I am not familiar with GNU Emacs’ development customs, but a common sense suggests me that a feature request had better be filed by one who could ground its usefulness, while I hardy could. Anyway, I think it worth to change it a bit more in order to make it try to guess mime-type: [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: browse-url-mail.2.patch --] [-- Type: text/x-diff, Size: 585 bytes --] diff --git a/lisp/net/browse-url.el b/lisp/net/browse-url.el index a4d47f6..dca81fe 100644 --- a/lisp/net/browse-url.el +++ b/lisp/net/browse-url.el @@ -1597,7 +1597,8 @@ used instead of `browse-url-new-window-flag'." (if (not mml-mode) (error "Enable MML mode if you want to attach files") (dolist (attach attaches) - (mml-attach-file attach nil nil "attachment")))))))) + (mml-attach-file attach (mm-default-file-encoding attach) + nil "attachment")))))))) ;; --- Random browser --- [-- Attachment #3: Type: text/plain, Size: 765 bytes --] > I don't know how attachments are handled by other mailto-users though – For instance, Icedove (Thunderbird) does not support attaches in ‘mailto:’ at all and this is considered a feature [0]. [0] https://bugzil.la/99055#c6 > multiple identical hfname's or some separator in the hfvalue like with > the "to" header? The former seems to be the only way if we want to use xdg-email(1), since it requires that argument of ‘--attach’ should be existing file, not an arbitrary string and in particular not a comma separated list of files. --8<---------------cut here---------------start------------->8--- $ xdg-email foo@example.org --attach hfsdg xdg-email: file 'hfsdg' does not exist --8<---------------cut here---------------end--------------->8--- ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: xdg-email vs browse-url-mail 2016-07-15 18:29 ` Dmitry Alexandrov @ 2016-07-15 21:16 ` Kevin Brubeck Unhammer 2016-07-16 17:13 ` Dmitry Alexandrov 0 siblings, 1 reply; 7+ messages in thread From: Kevin Brubeck Unhammer @ 2016-07-15 21:16 UTC (permalink / raw) To: Dmitry Alexandrov; +Cc: info-gnus-english [-- Attachment #1.1: Type: text/plain, Size: 3682 bytes --] Dmitry Alexandrov <321942@gmail.com> čálii: > Kevin Brubeck Unhammer <unhammer@fsfe.org> writes: > >> Dmitry Alexandrov <321942@gmail.com> čálii: >> >>> Kevin Brubeck Unhammer <unhammer@fsfe.org> writes: >>> >>>> I just tried using browse-url-mail as a mailto-handler with the below >>>> script as my mail handler (set in XFCE settings): >>>> >>>> #!/bin/bash >>>> mailto="${*//\"/}" >>> >>> ... >>> >>>> if [[ ! ${mailto} =~ ^mailto: ]]; then >>>> mailto="mailto:${mailto}" >>>> fi >>> >>> Does not xdg-email(1) already do that? >> >> No. Try 'echo "$@">/tmp/log' at the top of your mail script. > > I tried: > > $ xdg-email --version > xdg-email 1.1.0 rc1 > > $ cat /tmp/xdg-test > #!/bin/bash > > echo "$@" > /tmp/xdg-test.log > > $ xdg-email foo@example.org > > $ cat /tmp/xdg-test.log > mailto:foo@example.org Weird, when I try, I get without mailto. $ xdg-email --version xdg-email 1.1.0 rc3 $ cat ~/bin/emacsmail #!/bin/bash echo "$@">/tmp/xdg-test.log $ xdg-email foo@bar.fi ;cat /tmp/log foo@bar.fi This seems to be because open_gnome3 in that script uses xdg-mime query default "x-scheme-handler/mailto" which on my system for some reason gives thunderbird.desktop instead of what I set it to in Xfce, and open_thunderbird does MAILTO=$(echo "$2" | sed 's/^mailto://') I guess that's one for the xdg-email authors. [...] > > Hmm... Do you mean that I have to open a bug report? I am not familiar > with GNU Emacs’ development customs, but a common sense suggests me that > a feature request had better be filed by one who could ground its > usefulness, while I hardy could. > > Anyway, I think it worth to change it a bit more in order to make it try > to guess mime-type: > > > diff --git a/lisp/net/browse-url.el b/lisp/net/browse-url.el > index a4d47f6..dca81fe 100644 > --- a/lisp/net/browse-url.el > +++ b/lisp/net/browse-url.el > @@ -1597,7 +1597,8 @@ used instead of `browse-url-new-window-flag'." > (if (not mml-mode) > (error "Enable MML mode if you want to attach files") > (dolist (attach attaches) > - (mml-attach-file attach nil nil "attachment")))))))) > + (mml-attach-file attach (mm-default-file-encoding attach) > + nil "attachment")))))))) > > ;; --- Random browser --- > > > >> I don't know how attachments are handled by other mailto-users though – > > For instance, Icedove (Thunderbird) does not support attaches in > ‘mailto:’ at all and this is considered a feature [0]. > > [0] https://bugzil.la/99055#c6 Aha, that makes sense. Hmm, now I'm not so sure I should be feature requesting this; even for hardened Emacs users, it's easy to hit C-c C-c too quickly. I'll probably continue using your patch myself though … >> multiple identical hfname's or some separator in the hfvalue like with >> the "to" header? > > The former seems to be the only way if we want to use xdg-email(1), > since it requires that argument of ‘--attach’ should be existing file, > not an arbitrary string and in particular not a comma separated list of > files. > > $ xdg-email foo@example.org --attach hfsdg > xdg-email: file 'hfsdg' does not exist Not necessarily; xdg-email could turn multiple --attach arguments into a single delimiter-separated list of file paths. But I'd rather not suggest a new standard without having done a full survey in case other programs support multiple mailto:-attachments in various ways :) best regards, Kevin Brubeck Unhammer [-- Attachment #1.2: signature.asc --] [-- Type: application/pgp-signature, Size: 818 bytes --] ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: xdg-email vs browse-url-mail 2016-07-15 21:16 ` Kevin Brubeck Unhammer @ 2016-07-16 17:13 ` Dmitry Alexandrov 2016-07-25 8:10 ` Kevin Brubeck Unhammer 0 siblings, 1 reply; 7+ messages in thread From: Dmitry Alexandrov @ 2016-07-16 17:13 UTC (permalink / raw) To: Kevin Brubeck Unhammer; +Cc: info-gnus-english Kevin Brubeck Unhammer <unhammer@fsfe.org> writes: >> $ xdg-email --version >> xdg-email 1.1.0 rc1 >> >> $ cat /tmp/xdg-test >> #!/bin/bash >> >> echo "$@" > /tmp/xdg-test.log >> >> $ xdg-email foo@example.org >> >> $ cat /tmp/xdg-test.log >> mailto:foo@example.org > > Weird, when I try, I get without mailto. > > $ xdg-email --version > xdg-email 1.1.0 rc3 > $ cat ~/bin/emacsmail > #!/bin/bash > > echo "$@">/tmp/xdg-test.log > $ xdg-email foo@bar.fi ;cat /tmp/log > foo@bar.fi > > This seems to be because open_gnome3 in that script uses > xdg-mime query default "x-scheme-handler/mailto" > which on my system for some reason gives thunderbird.desktop > instead of what I set it to in Xfce, and open_thunderbird does > MAILTO=$(echo "$2" | sed 's/^mailto://') > I guess that's one for the xdg-email authors. > > > > [...] > >> >> Hmm... Do you mean that I have to open a bug report? I am not familiar >> with GNU Emacs’ development customs, but a common sense suggests me that >> a feature request had better be filed by one who could ground its >> usefulness, while I hardy could. >> >> Anyway, I think it worth to change it a bit more in order to make it try >> to guess mime-type: >> >> >> diff --git a/lisp/net/browse-url.el b/lisp/net/browse-url.el >> index a4d47f6..dca81fe 100644 >> --- a/lisp/net/browse-url.el >> +++ b/lisp/net/browse-url.el >> @@ -1597,7 +1597,8 @@ used instead of `browse-url-new-window-flag'." >> (if (not mml-mode) >> (error "Enable MML mode if you want to attach files") >> (dolist (attach attaches) >> - (mml-attach-file attach nil nil "attachment")))))))) >> + (mml-attach-file attach (mm-default-file-encoding attach) >> + nil "attachment")))))))) >> >> ;; --- Random browser --- >> >> >> >>> I don't know how attachments are handled by other mailto-users though – >> >> For instance, Icedove (Thunderbird) does not support attaches in >> ‘mailto:’ at all and this is considered a feature [0]. >> >> [0] https://bugzil.la/99055#c6 > > Aha, that makes sense. Not for the authors of xdg-email(1). It seems that the whole point of above-mentioned quirk about special handling of Thunderbird® is to silently override that limitation. At least I have no other explanation on why to convert something like: --8<---------------cut here---------------start------------->8--- mailto:foo@example.org?subject=bar&attach=%2Ftmp%2Fatt --8<---------------cut here---------------end--------------->8--- into --8<---------------cut here---------------start------------->8--- -compose to='"foo@example.org",',subject=bar,attachment='/tmp/att' --8<---------------cut here---------------end--------------->8--- And that is exactly what ‘run_thunderbird()’ does. > Hmm, now I'm not so sure I should be feature requesting this; even for > hardened Emacs users, it's easy to hit C-c C-c too quickly. I'll > probably continue using your patch myself though … However, if a feature would be considered potentially hazardous, it always might be done as an option that is disabled by default. >>> multiple identical hfname's or some separator in the hfvalue like with >>> the "to" header? >> >> The former seems to be the only way if we want to use xdg-email(1), >> since it requires that argument of ‘--attach’ should be existing file, >> not an arbitrary string and in particular not a comma separated list of >> files. >> >> $ xdg-email foo@example.org --attach hfsdg >> xdg-email: file 'hfsdg' does not exist > > Not necessarily; xdg-email could turn multiple --attach arguments into a > single delimiter-separated list of file paths. But it does not. Or did I miss something? > But I'd rather not > suggest a new standard without having done a full survey in case other > programs support multiple mailto:-attachments in various ways :) _______________________________________________ info-gnus-english mailing list info-gnus-english@gnu.org https://lists.gnu.org/mailman/listinfo/info-gnus-english ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: xdg-email vs browse-url-mail 2016-07-16 17:13 ` Dmitry Alexandrov @ 2016-07-25 8:10 ` Kevin Brubeck Unhammer 0 siblings, 0 replies; 7+ messages in thread From: Kevin Brubeck Unhammer @ 2016-07-25 8:10 UTC (permalink / raw) To: info-gnus-english; +Cc: Dmitry Alexandrov [-- Attachment #1.1: Type: text/plain, Size: 737 bytes --] Dmitry Alexandrov <321942@gmail.com> čálii: > Kevin Brubeck Unhammer <unhammer@fsfe.org> writes: [...] >>> The former seems to be the only way if we want to use xdg-email(1), >>> since it requires that argument of ‘--attach’ should be existing file, >>> not an arbitrary string and in particular not a comma separated list of >>> files. >>> >>> $ xdg-email foo@example.org --attach hfsdg >>> xdg-email: file 'hfsdg' does not exist >> >> Not necessarily; xdg-email could turn multiple --attach arguments into a >> single delimiter-separated list of file paths. > > But it does not. Or did I miss something? It does not, I was speaking hypothetically (sorry for the late reply, been on vacation). -Kevin [-- Attachment #1.2: signature.asc --] [-- Type: application/pgp-signature, Size: 818 bytes --] ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2016-07-25 8:10 UTC | newest] Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2016-07-14 12:51 xdg-email vs browse-url-mail Kevin Brubeck Unhammer 2016-07-14 21:09 ` Dmitry Alexandrov 2016-07-15 8:31 ` Kevin Brubeck Unhammer 2016-07-15 18:29 ` Dmitry Alexandrov 2016-07-15 21:16 ` Kevin Brubeck Unhammer 2016-07-16 17:13 ` Dmitry Alexandrov 2016-07-25 8:10 ` Kevin Brubeck Unhammer
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 NNTP newsgroup(s).