Gnus development mailing list
 help / color / mirror / Atom feed
* Possible to make gnus handle mailto URLs with cc, subject and body?
@ 2020-06-06 15:32 Steinar Bang
  2020-06-06 16:28 ` Adam Sjøgren
  0 siblings, 1 reply; 6+ messages in thread
From: Steinar Bang @ 2020-06-06 15:32 UTC (permalink / raw)
  To: ding

Is there a way to make gnus handle mailto URLs with cc, subject and
body, when those URLs are clicked in a browser?

Here's an example URL:
 mailto:korr@somewhere.com?cc=some.one@somewhere.com&subject=Hittat%20fel%20i%3A%20%22Nytt%20ras%20i%20Nordnorge%20%E2%80%93%20orsakade%20stort%20h%C3%A5l%20%22&body=Jag%20har%20hittat%20fel%20i%20artikeln%20%22Nytt%20ras%20i%20Nordnorge%20%E2%80%93%20orsakade%20stort%20h%C3%A5l%20%22%0A(https%3A%2F%2Fwww.svt.se%2Fnyheter%2Futrikes%2Fnytt-ras-i-nordnorge-orsakade-stort-hal)%0A%0AKommentar%3A

I have no idea what's sent on from the browser, beyond the email addres.
And I have no idea how it's sent on different platforms.

What I would like to happen is Gnus preparing a message with to, cc,
subject and body, decoding the arguments for subject and body.



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

* Re: Possible to make gnus handle mailto URLs with cc, subject and body?
  2020-06-06 15:32 Possible to make gnus handle mailto URLs with cc, subject and body? Steinar Bang
@ 2020-06-06 16:28 ` Adam Sjøgren
  2020-06-06 16:35   ` Adam Sjøgren
  0 siblings, 1 reply; 6+ messages in thread
From: Adam Sjøgren @ 2020-06-06 16:28 UTC (permalink / raw)
  To: ding

Steinar writes:

> Is there a way to make gnus handle mailto URLs with cc, subject and
> body, when those URLs are clicked in a browser?
>
> Here's an example URL:
>  mailto:korr@somewhere.com?cc=some.one@somewhere.com&subject=Hittat%20fel%20i%3A%20%22Nytt%20ras%20i%20Nordnorge%20%E2%80%93%20orsakade%20stort%20h%C3%A5l%20%22&body=Jag%20har%20hittat%20fel%20i%20artikeln%20%22Nytt%20ras%20i%20Nordnorge%20%E2%80%93%20orsakade%20stort%20h%C3%A5l%20%22%0A(https%3A%2F%2Fwww.svt.se%2Fnyheter%2Futrikes%2Fnytt-ras-i-nordnorge-orsakade-stort-hal)%0A%0AKommentar%3A
>

> What I would like to happen is Gnus preparing a message with to, cc,
> subject and body, decoding the arguments for subject and body.

Looking at browse-url-mail in browse-url.el, it looks like it handles
To, Subject and Body, but not maybe not Cc:

  (defun browse-url-mail (url &optional new-window)
    "Open a new mail message buffer within Emacs for the RFC 2368 URL.
  Default to using the mailto: URL around or before point as the
  recipient's address.  Supplying a non-nil interactive prefix argument
  will cause the mail to be composed in another window rather than the
  current one.

  When called interactively, if variable `browse-url-new-window-flag' is
  non-nil use `compose-mail-other-window', otherwise `compose-mail'.  A
  non-nil interactive prefix argument reverses the effect of
  `browse-url-new-window-flag'.

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

?

I have a tiny script in ~/bin/mailto-handler:

  #!/bin/bash
  emacsclient -c --eval "(browse-url-mail \"$@\" nil)"

and I think/guess that I have configured ... something to use it, once,
at least Firefox runs it when I click a mailto: link.


  Best regards,

    Adam

-- 
 "Fader eg må be om undskyldning                            Adam Sjøgren
  Det er min feil at Tony er pakkt in i presenning"    asjo@koldfront.dk



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

* Re: Possible to make gnus handle mailto URLs with cc, subject and body?
  2020-06-06 16:28 ` Adam Sjøgren
@ 2020-06-06 16:35   ` Adam Sjøgren
  2020-06-06 17:07     ` Adam Sjøgren
  0 siblings, 1 reply; 6+ messages in thread
From: Adam Sjøgren @ 2020-06-06 16:35 UTC (permalink / raw)
  To: ding

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

Adam writes:

> Looking at browse-url-mail in browse-url.el, it looks like it handles
> To, Subject and Body, but not maybe not Cc:

I should have tested it - Cc works as well with browse-url-mail, for me.

In Firefox under Preferences → Applications I have "mailto" configured
to run /home/asjo/bin/mailto-handler, like this:


[-- Attachment #2: firefoxmailto.png --]
[-- Type: image/png, Size: 107369 bytes --]

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



  Best regards,

   Adam

-- 
 "Sometimes my burden is more than I can bear               Adam Sjøgren
  It's not dark yet, but it's getting there"           asjo@koldfront.dk

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

* Re: Possible to make gnus handle mailto URLs with cc, subject and body?
  2020-06-06 16:35   ` Adam Sjøgren
@ 2020-06-06 17:07     ` Adam Sjøgren
  2020-06-07 10:43       ` Steinar Bang
  0 siblings, 1 reply; 6+ messages in thread
From: Adam Sjøgren @ 2020-06-06 17:07 UTC (permalink / raw)
  To: ding

Adam writes:

> In Firefox under Preferences → Applications I have "mailto" configured
> to run /home/asjo/bin/mailto-handler, like this:

To make it work in Chromium, you need a ".desktop"-file, and then you
need to configure xdg-mime to use it¹.

I created a file, /usr/share/applications/gnus.desktop, (based on
mutt.desktop) like this:

  [Desktop Entry]
  Categories=Office;Network;Email;
  Comment=Comprehensive Emacs based Mail User Agent
  Exec=/home/asjo/bin/mailto-handler %u
  Icon=Gnus
  Name=Gnus
  MimeType=x-scheme-handler/mailto;
  NoDisplay=false
  Terminal=false
  Type=Application

(Pointing to the tiny script calling browse-url-mail with emacsclient.)

And then ran this command:

  $ xdg-mime query default x-scheme-handler/mailto
  mutt.desktop

to see the current default, and then changed it:

  $ xdg-mime default gnus.desktop x-scheme-handler/mailto

Now clicking a mailto-link in Chromium opens an email in Gnus, with To,
Cc, Subject and Body filled in.


  Best regards,

    Adam


¹ Information found here: https://lists.debian.org/debian-user/2018/06/msg00255.html
  after realizing that Chromium was running xdg-email.

-- 
 "There's such a glut of celebrities that they'll           Adam Sjøgren
  soon have to begin storing the surplus in silos in   asjo@koldfront.dk
  Iowa."



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

* Re: Possible to make gnus handle mailto URLs with cc, subject and body?
  2020-06-06 17:07     ` Adam Sjøgren
@ 2020-06-07 10:43       ` Steinar Bang
  2020-06-07 11:03         ` Adam Sjøgren
  0 siblings, 1 reply; 6+ messages in thread
From: Steinar Bang @ 2020-06-07 10:43 UTC (permalink / raw)
  To: ding

Thanks Adam!

I will adopt your approach (or something very similar) on GNU/linux and
other unixoid systems.

But now I have to figure out if an approach can be used in windows as
well?  What happens when a mailto URL is clicked on window?

This URL shows how to change the email client used to an arbitrary
program:
 https://support.procore.com/faq/how-do-i-change-my-web-browsers-default-email-client-for-mailto-links

But what should that arbitrary program look like? How are arguments
transferred to the program?

Hm... from what I found here https://stackoverflow.com/a/1812 it looks
like it will be run as: 
 <full-path-to-executable> <mailto-URL>

So that could be handled with something similar to Adam's shell script
except probably not bourne shell?  And how well does emacsclient work on
window?

I tried it from a cmd.exe window and it seems to work, both the command
	C:\ProgramFiles\emacs-26.3-i686\bin\emacsclient.exe .emacs
and the command
	C:\ProgramFiles\emacs-26.3-i686\bin\emacsclientw.exe .emacs
opened up .emacs in a window, that could be closed with 'C-x #'

(what's the difference between emacsclient.exe and emacsclientw.exe,
btw?  Does one pop up a cmd window and one not?  Yep, emacsclientw.exe
does (probably) not open a cmd window if I interpret this correctly:
https://www.gnu.org/software/emacs/manual/html_node/emacs/Windows-Startup.html) 

I've created a c:\ProgramFiles\emacs-26.3-i686\bin\mailto-handler.bat
file, with the following contents:
C:\ProgramFiles\emacs-26.3-i686\bin\emacsclientw.exe -c --eval "(browse-url-mail \"%1\" nil)"

But testing it out turned to be harder.  Neither vivaldi nor chrome seem
to have a way of setting a handler right now.  There is no setting that
looks right and chrome://settings/handlers just opens a page where one
can switch off webpages offering to become handler.

Because appearently that's the preferred way to handle email these days:
webmail

Oh well!



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

* Re: Possible to make gnus handle mailto URLs with cc, subject and body?
  2020-06-07 10:43       ` Steinar Bang
@ 2020-06-07 11:03         ` Adam Sjøgren
  0 siblings, 0 replies; 6+ messages in thread
From: Adam Sjøgren @ 2020-06-07 11:03 UTC (permalink / raw)
  To: ding

Steinar writes:

> But now I have to figure out if an approach can be used in windows as
> well?  What happens when a mailto URL is clicked on window?

I don't use Microsoft Windows, so I don't know.

Doesn't Microsoft Windows have a GUI implementation of something similar
to xdg-mime, i.e. default mailto:-handler/mail-program?

I think I saw screenshots of that while I was searching for answers.


  Best regards,

    Adam

-- 
 "Din chance for at overleve er som at vinde i lotto        Adam Sjøgren
  For jeg er fucked up som nytårsaften med Darie       asjo@koldfront.dk
  Campeotto"



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

end of thread, other threads:[~2020-06-07 11:04 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-06 15:32 Possible to make gnus handle mailto URLs with cc, subject and body? Steinar Bang
2020-06-06 16:28 ` Adam Sjøgren
2020-06-06 16:35   ` Adam Sjøgren
2020-06-06 17:07     ` Adam Sjøgren
2020-06-07 10:43       ` Steinar Bang
2020-06-07 11:03         ` Adam Sjøgren

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