help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Open mailto links


From: Richard G Riley
Subject: Re: Open mailto links
Date: Fri, 05 Sep 2008 21:57:47 +0200
User-agent: Emacs 22.2.1/No Gnus v0.11

henry atting <nospam@literaturlatenight.de> writes:

> Within iceweasel I open mailto links with this small script:
>
>
> #!/bin/sh
> /usr/bin/emacsclient -e "(message-mail \"$1\")"
>

I use te following in the application path for mailto URLs in Firefox:

,----
| gnus-mailto.sh
`----

where gnus-mailto.sh is the following on my path:

,----
| #!/bin/sh
| # gnus-mailto.sh
| wmctrl -a emacs22
| source ~/bin/emacs.bash
| edit --eval "(progn (johnsu01/mailto \"$1\"))" 
`----

(wmctrl brings emacs into focus on linux/X)

and edit is defined in emacs.bash which ships with emacs 22:

,----
| function edit ()
| {
|  local windowsys="${WINDOW_PARENT+sun}"
| 
|  windowsys="${windowsys:-${DISPLAY+x}}"
| 
|  if [ -n "${windowsys:+set}" ]; then
|     # Do not just test if these files are sockets.  On some systems
|     # ordinary files or fifos are used instead.  Just see if they exist.
|     if [ -e "${HOME}/.emacs_server" -o -e "/tmp/emacs${UID}/server" ]; then
|        emacsclient "$@"
|        return $?
|     else
|        echo "edit: starting emacs in background..." 1>&2
|     fi
| 
|     case "${windowsys}" in
|       x ) (emacs "$@" &) ;;
|       sun ) (emacstool "$@" &) ;;
|     esac
|  else
|     if jobs %emacs 2> /dev/null ; then
|        echo "$(pwd)" "$@" >| ${HOME}/.emacs_args && fg %emacs
|     else
|        emacs "$@"
|     fi
|  fi
| }
`----


John Sullivans code is the following in my .emacs:

,----
| (defun johnsu01/mailto (url)
|   "Follow a mailto URL as passed from Iceweasel, prompting for a posting 
style."
|   (unless(gnus-alive-p)
|     (gnus))
| 
|   (message "Url is : %s" url)
| 
|   (let ((gnus-newsgroup-name
|          (completing-read "Use posting style of group: "
|                           gnus-active-hashtb nil
|                           (gnuOBs-read-active-file-p) "rileyrg")))
|     (setq url (url-unhex-string url))
|     (browse-url-mail url))
|   ;; message-mail does not do anything with the body argument, so we have to.
|   (if (string-match (regexp-quote "?") url)
|       (let* ((start (match-end 0))
|              (args (url-parse-query-string
|                     (substring url start nil)))
|              (body (cadr (assoc-string "body" args t))))
|         (when body
|           (switch-to-buffer (car (message-buffers)))
|           (save-excursion
|             (message-goto-body)
|             (insert body)))))
|   )
`----

And this prompts you for which gnus-posting-style to use.

Works really well if you have multiple posting styles.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]