[Top][All Lists]

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

Re: prefer application on Gnome Desktop

From: Teemu Likonen
Subject: Re: prefer application on Gnome Desktop
Date: Tue, 14 Jul 2009 20:36:10 +0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (gnu/linux)

On 2009-07-14 14:41 (+0900), Byung-Hee HWANG wrote:

> Hi, i use Emacs on Gnome Desktop (FreeBSD 7.2-RELEASE). In Gnome,
> there is the config named "prefer application" in which we can decide
> the best application for us such as mailer, webbrowser. The default
> value in mailer is "Evolution". By the way i would like to switch to
> Gnus from Evolution. So how can i change without any errors?

On 2009-07-14 11:05 (+0300), Teemu Likonen wrote:
> it's in my mental TODO list to make this work mostly inside Emacs.

OK, it turned out that all the parser functions already existed in Emacs
so the basic functionality was very easy to do. Here's a prototype.
First, have an executable shell script which takes mailto URL as its
argument and passes it to Emacs:

--8<---------------cut here---------------start------------->8---
# emacs-mailto-handler
# $1 = mailto URL

mailto=$(printf '%s\n' "$1" | sed -e 's/[\"]/\\&/g')
elisp_expr=$(printf '(mailto-compose-mail "%s")' "$mailto")
exec emacsclient -c -n -a '' --eval "$elisp_expr"
--8<---------------cut here---------------end--------------->8---

Configure the shell script to be your default email client and the
mailto hander of your web browsers. Then make this code available to
your Emacs:

--8<---------------cut here---------------start------------->8---
;;; mailto-compose-mail (2009-07-14)

(defun mailto-compose-mail (mailto-url)
  "Parse MAILTO-URL and go to compose mail."
  (require 'rfc2368)
  (require 'rfc2047)
  (require 'mailheader)

  (let ((header-alist (rfc2368-parse-mailto-url mailto-url))
        to subject)
      (dolist (hdr header-alist)
        (insert (concat (car hdr) ": " (cdr hdr) "\n")))
      (rfc2047-decode-region (point-min) (point-max))
      (goto-char (point-min))
      (setq header-alist (mail-header-extract-no-properties)))

    (setq to (or (cdr (assq 'to header-alist)) "")
          subject (or (cdr (assq 'subject header-alist)) "")
          header-alist (assq-delete-all 'to header-alist)
          header-alist (assq-delete-all 'subject header-alist)
          header-alist (assq-delete-all 'body header-alist))

    (compose-mail to subject header-alist)))
--8<---------------cut here---------------end--------------->8---

That's pretty much it, but note that this is a simple prototype without
error checking.

reply via email to

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