Announcements and discussions for Gnus, the GNU Emacs Usenet newsreader
 help / color / mirror / Atom feed
* Handling mailto in firefox/iceweasel with gnus on linux
@ 2009-08-24 19:01 Richard Riley
  2009-08-24 19:14 ` Richard Riley
  0 siblings, 1 reply; 2+ messages in thread
From: Richard Riley @ 2009-08-24 19:01 UTC (permalink / raw)
  To: info-gnus-english


(Debian Linux and Gnome btw)

I did some googling around for mailto solutions again recently from
firefox - there are a few different approaches that worked with varying
success on my setup (gnus-posting-styles). I think/hope I have cobbled
other peoples work together and added a little more in a way which might
help others too.

1) Install the mozex add on for firefox. Configure the mail handler with
something along the lines of:

,----
| /on/your/path/gnumail  %a %s
`----

2) create the script gnumail referenced above which takes the mailto and
extract the "to". Borrowed from
http://www.emacswiki.org/emacs/MailtoHandler

,----
| #!/bin/bash
| mailto=$(printf '%s\n' "$1" | sed -e 's/[\"]/\\&/g')
| elisp_expr=$(printf '(rgr/mailto "%s")' "$mailto")
| 
| emacsclient -c -n \
|         --eval "$elisp_expr" \
|         --eval '(set-window-dedicated-p (selected-window) t)'
| 
`----

3) Add the function to talk to gnus in your .emacs/wherever. This small
function borrowed the completing read from John Sullivan's mailto from a
while ago but also allows a pre-configured one with no prompt. It
detects if Gnus is running and starts it if not.

,----
|
|(setq gnus-default-mailto-group "INBOX.mail")
|
| (defun rgr/mailto (to)
|   "Send an email to 'to' but prompting for a posting style if not configured. Starts Gnus if not already running."
|   (unless gnus-active-hashtb (gnus)) ;; Better way??
|   (let ((gnus-newsgroup-name
|          (if gnus-default-mailto-group gnus-default-mailto-group (completing-read "Use posting style of group: "
|                           gnus-active-hashtb nil
|                           (gnus-read-active-file-p)))))
|     (compose-mail to)))
`----

And now with the wonders of emacs daemon (my "edit" function is simply
'emacsclient --alternate-editor="" -c $*') gnus pops up in a matter of
milliseconds when I click on a mailto in iceweasel!

cheers,

r.

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

* Re: Handling mailto in firefox/iceweasel with gnus on linux
  2009-08-24 19:01 Handling mailto in firefox/iceweasel with gnus on linux Richard Riley
@ 2009-08-24 19:14 ` Richard Riley
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Riley @ 2009-08-24 19:14 UTC (permalink / raw)
  To: info-gnus-english

Richard Riley <rileyrgdev@gmail.com> writes:

> (Debian Linux and Gnome btw)
>
> I did some googling around for mailto solutions again recently from
> firefox - there are a few different approaches that worked with varying
> success on my setup (gnus-posting-styles). I think/hope I have cobbled
> other peoples work together and added a little more in a way which might
> help others too.
>
> 1) Install the mozex add on for firefox. Configure the mail handler with
> something along the lines of:
>
> ,----
> | /on/your/path/gnumail  %a %s
> `----
>
> 2) create the script gnumail referenced above which takes the mailto and
> extract the "to". Borrowed from
> http://www.emacswiki.org/emacs/MailtoHandler
>

Better is:

,----
| #!/bin/bash
| mailto=$(printf '%s\n' "$1" | sed -e 's/[\"]/\\&/g')
| elisp_expr=$(printf '(rgr/mailto "%s")' "$mailto")
| 
| emacsclient --alternate-editor="" -c -n \
|         --eval "$elisp_expr" \
|         --eval '(set-window-dedicated-p (selected-window) t)'
`----


>
> 3) Add the function to talk to gnus in your .emacs/wherever. This small
> function borrowed the completing read from John Sullivan's mailto from a
> while ago but also allows a pre-configured one with no prompt. It
> detects if Gnus is running and starts it if not.

Slight improvement: ensure you add it to your .emacs and not your .gnus
init file or it might not work if gnus is autoloaded and you have not
already loaded gnus at least once. In addition, added the "require" to
pull in gnus.

,----
| (setq gnus-default-mailto-group "INBOX.mail")
| 
| (defun rgr/mailto (to)
|   "Send an email to 'to' but prompting for a posting style if not configured. Starts Gnus if not already running."
|   (require 'gnus)
|   (unless gnus-active-hashtb (gnus)) ;; Better way??
|   (let ((gnus-newsgroup-name
|          (if gnus-default-mailto-group gnus-default-mailto-group (completing-read "Use posting style of group: "
|                           gnus-active-hashtb nil
|                           (gnus-read-active-file-p)))))
|     (compose-mail to)))
| 
`----

>
> And now with the wonders of emacs daemon (my "edit" function is simply
> 'emacsclient --alternate-editor="" -c $*') gnus pops up in a matter of
> milliseconds when I click on a mailto in iceweasel!
>
> cheers,
>
> r.
>
>

-- 

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

end of thread, other threads:[~2009-08-24 19:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-08-24 19:01 Handling mailto in firefox/iceweasel with gnus on linux Richard Riley
2009-08-24 19:14 ` Richard Riley

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