1 Return-Path: <jrollins@finestructure.net>
\r
2 X-Original-To: notmuch@notmuchmail.org
\r
3 Delivered-To: notmuch@notmuchmail.org
\r
4 Received: from localhost (localhost [127.0.0.1])
\r
5 by olra.theworths.org (Postfix) with ESMTP id CBFB2429E25
\r
6 for <notmuch@notmuchmail.org>; Sat, 14 Apr 2012 14:27:54 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-2.3 tagged_above=-999 required=5
\r
12 tests=[RCVD_IN_DNSWL_MED=-2.3] autolearn=disabled
\r
13 Received: from olra.theworths.org ([127.0.0.1])
\r
14 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
15 with ESMTP id jLhXEnOyG-Hn for <notmuch@notmuchmail.org>;
\r
16 Sat, 14 Apr 2012 14:27:52 -0700 (PDT)
\r
17 Received: from outgoing-mail.its.caltech.edu (outgoing-mail.its.caltech.edu
\r
19 by olra.theworths.org (Postfix) with ESMTP id EBA8F431FAF
\r
20 for <notmuch@notmuchmail.org>; Sat, 14 Apr 2012 14:27:51 -0700 (PDT)
\r
21 Received: from earth-doxen.imss.caltech.edu (localhost [127.0.0.1])
\r
22 by earth-doxen-postvirus (Postfix) with ESMTP id BC32166E0123
\r
23 for <notmuch@notmuchmail.org>; Sat, 14 Apr 2012 14:27:51 -0700 (PDT)
\r
24 X-Spam-Scanned: at Caltech-IMSS on earth-doxen by amavisd-new
\r
25 Received: from finestructure.net (unknown [76.89.193.65])
\r
26 (Authenticated sender: jrollins)
\r
27 by earth-doxen-submit (Postfix) with ESMTP id 31E5866E0018
\r
28 for <notmuch@notmuchmail.org>; Sat, 14 Apr 2012 14:27:49 -0700 (PDT)
\r
29 Received: by finestructure.net (Postfix, from userid 1000)
\r
30 id E17F445D; Sat, 14 Apr 2012 14:27:48 -0700 (PDT)
\r
31 From: Jameson Graef Rollins <jrollins@finestructure.net>
\r
32 To: Notmuch Mail <notmuch@notmuchmail.org>
\r
33 Subject: [PATCH v2 2/2] emacs: new mua mailto: URI handler
\r
34 Date: Sat, 14 Apr 2012 14:27:48 -0700
\r
35 Message-Id: <1334438868-17168-1-git-send-email-jrollins@finestructure.net>
\r
36 X-Mailer: git-send-email 1.7.9.5
\r
37 In-Reply-To: <1327865624-7673-2-git-send-email-jrollins@finestructure.net>
\r
38 References: <1327865624-7673-2-git-send-email-jrollins@finestructure.net>
\r
39 X-BeenThere: notmuch@notmuchmail.org
\r
40 X-Mailman-Version: 2.1.13
\r
42 List-Id: "Use and development of the notmuch mail system."
\r
43 <notmuch.notmuchmail.org>
\r
44 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
45 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
46 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
47 List-Post: <mailto:notmuch@notmuchmail.org>
\r
48 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
49 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
50 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
51 X-List-Received-Date: Sat, 14 Apr 2012 21:27:55 -0000
\r
53 The new function 'notmuch-mua-mailto' provides an interactive handler
\r
54 for rfc6068 "mailto:" URIs. It attempts to implement the rfc6068
\r
55 specification: http://tools.ietf.org/html/rfc6068
\r
57 More decoding of the mailto string needs to be done, as is evident by
\r
58 the fact that the mailto test remains broken.
\r
60 Rebased against current master.
\r
62 emacs/notmuch-mua.el | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++
\r
63 1 file changed, 62 insertions(+)
\r
65 diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el
\r
66 index 87bd88d..59b4cf4 100644
\r
67 --- a/emacs/notmuch-mua.el
\r
68 +++ b/emacs/notmuch-mua.el
\r
70 (require 'notmuch-lib)
\r
71 (require 'notmuch-address)
\r
75 +(require 'mailheader)
\r
77 (eval-when-compile (require 'cl))
\r
80 @@ -198,6 +202,64 @@ list."
\r
84 +(defun notmuch-mua-mailto (mailto)
\r
85 + "Invoke the notmuch mail composition window for a `mailto:' URI."
\r
86 + ;; this should implement implement rfc6068: http://tools.ietf.org/html/rfc6068
\r
87 + ;; which obsoleted: http://tools.ietf.org/html/rfc2368
\r
88 + ;; this function is based on previous work: http://www.emacswiki.org/emacs/MailtoHandler
\r
90 + (when (and (stringp mailto)
\r
91 + (string-match "\\`mailto:" mailto))
\r
93 + ;; FIXME: need to decode all html encodings in uri.
\r
94 + (mailto (replace-regexp-in-string "&" "&" mailto))
\r
95 + (hdr-alist (rfc2368-parse-mailto-url mailto))
\r
96 + to subject other-headers body
\r
97 + (allowed-xtra-hdrs '(cc bcc in-reply-to)))
\r
100 + ;; extract body if it's defined
\r
101 + (when (assoc "Body" hdr-alist)
\r
102 + (dolist (hdr hdr-alist)
\r
103 + (when (equal "Body" (car hdr))
\r
104 + (insert (format "%s\n" (cdr hdr)))))
\r
105 + (rfc2047-decode-region (point-min) (point-max))
\r
106 + (setq body (buffer-substring-no-properties
\r
107 + (point-min) (point-max)))
\r
110 + ;; extract headers
\r
111 + (dolist (hdr hdr-alist)
\r
112 + (unless (equal "Body" (car hdr))
\r
113 + (insert (format "%s: %s\n" (car hdr) (cdr hdr)))))
\r
114 + (rfc2047-decode-region (point-min) (point-max))
\r
115 + (goto-char (point-min))
\r
116 + (setq hdr-alist (mail-header-extract-no-properties)))
\r
118 + (setq to (cdr (assoc 'to hdr-alist)))
\r
119 + (setq subject (cdr (assoc 'subject hdr-alist)))
\r
121 + ;; extract allowed other headers, taking only first defined
\r
123 + (dolist (hdr hdr-alist)
\r
124 + (if (and (member (car hdr) allowed-xtra-hdrs)
\r
125 + (not (assoc (car hdr) other-headers)))
\r
126 + (add-to-list 'other-headers hdr)))
\r
128 + (notmuch-mua-mail to subject other-headers)
\r
130 + ;; insert the message body - but put it in front of the signature
\r
131 + ;; if one is present
\r
132 + (goto-char (point-max))
\r
133 + (if (re-search-backward message-signature-separator nil t)
\r
134 + (forward-line -1)
\r
135 + (goto-char (point-max)))
\r
138 + (set-buffer-modified-p nil)
\r
140 + (message-goto-body)))
\r
142 (defun notmuch-mua-mail (&optional to subject other-headers &rest other-args)
\r
143 "Invoke the notmuch mail composition window.
\r