1 Return-Path: <dme@dme.org>
\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 7858E4196F3
\r
6 for <notmuch@notmuchmail.org>; Thu, 22 Apr 2010 02:03:52 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-1.9 tagged_above=-999 required=5
\r
12 tests=[BAYES_00=-1.9] autolearn=ham
\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 uaFygYGFVtdA for <notmuch@notmuchmail.org>;
\r
16 Thu, 22 Apr 2010 02:03:51 -0700 (PDT)
\r
17 Received: from mail-ww0-f53.google.com (mail-ww0-f53.google.com
\r
18 [74.125.82.53]) by olra.theworths.org (Postfix) with ESMTP id 56A424196F2 for
\r
19 <notmuch@notmuchmail.org>; Thu, 22 Apr 2010 02:03:51 -0700 (PDT)
\r
20 Received: by wwb28 with SMTP id 28so2069847wwb.26
\r
21 for <notmuch@notmuchmail.org>; Thu, 22 Apr 2010 02:03:50 -0700 (PDT)
\r
22 Received: by 10.216.89.213 with SMTP id c63mr600716wef.8.1271927029702;
\r
23 Thu, 22 Apr 2010 02:03:49 -0700 (PDT)
\r
24 Received: from ut.hh.sledj.net (host83-217-165-81.dsl.vispa.com
\r
26 by mx.google.com with ESMTPS id x14sm16335152wbs.18.2010.04.22.02.03.47
\r
27 (version=TLSv1/SSLv3 cipher=RC4-MD5);
\r
28 Thu, 22 Apr 2010 02:03:48 -0700 (PDT)
\r
29 Received: by ut.hh.sledj.net (Postfix, from userid 1000)
\r
30 id 59E26594163; Thu, 22 Apr 2010 10:03:45 +0100 (BST)
\r
31 From: David Edmondson <dme@dme.org>
\r
32 To: notmuch@notmuchmail.org
\r
33 Subject: [PATCH] emacs: Add notmuch-address.el for address completion using
\r
35 Date: Thu, 22 Apr 2010 10:03:43 +0100
\r
36 Message-Id: <1271927023-10103-1-git-send-email-dme@dme.org>
\r
37 X-Mailer: git-send-email 1.7.0
\r
38 X-BeenThere: notmuch@notmuchmail.org
\r
39 X-Mailman-Version: 2.1.13
\r
41 List-Id: "Use and development of the notmuch mail system."
\r
42 <notmuch.notmuchmail.org>
\r
43 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
44 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
45 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
46 List-Post: <mailto:notmuch@notmuchmail.org>
\r
47 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
48 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
49 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
50 X-List-Received-Date: Thu, 22 Apr 2010 09:03:52 -0000
\r
52 A tool `notmuch-addresses' is required to produce addresses which
\r
53 match a query string. An example of a suitable script can be found in
\r
54 the git repository at
\r
55 http://jkr.acm.jhu.edu/git/notmuch_addresses.git
\r
56 There are no doubt others.
\r
58 emacs/Makefile.local | 3 +-
\r
59 emacs/notmuch-address.el | 91 ++++++++++++++++++++++++++++++++++++++++++++++
\r
60 2 files changed, 93 insertions(+), 1 deletions(-)
\r
61 create mode 100644 emacs/notmuch-address.el
\r
63 diff --git a/emacs/Makefile.local b/emacs/Makefile.local
\r
64 index e5013b3..7537c3d 100644
\r
65 --- a/emacs/Makefile.local
\r
66 +++ b/emacs/Makefile.local
\r
67 @@ -8,7 +8,8 @@ emacs_sources := \
\r
68 $(dir)/notmuch-show.el \
\r
69 $(dir)/notmuch-wash.el \
\r
70 $(dir)/notmuch-hello.el \
\r
71 - $(dir)/notmuch-mua.el
\r
72 + $(dir)/notmuch-mua.el \
\r
73 + $(dir)/notmuch-address.el
\r
76 $(dir)/notmuch-logo.png
\r
77 diff --git a/emacs/notmuch-address.el b/emacs/notmuch-address.el
\r
78 new file mode 100644
\r
79 index 0000000..69a52a2
\r
81 +++ b/emacs/notmuch-address.el
\r
83 +;; notmuch-address.el --- address completion with notmuch
\r
85 +;; Copyright © David Edmondson
\r
87 +;; This file is part of Notmuch.
\r
89 +;; Notmuch is free software: you can redistribute it and/or modify it
\r
90 +;; under the terms of the GNU General Public License as published by
\r
91 +;; the Free Software Foundation, either version 3 of the License, or
\r
92 +;; (at your option) any later version.
\r
94 +;; Notmuch is distributed in the hope that it will be useful, but
\r
95 +;; WITHOUT ANY WARRANTY; without even the implied warranty of
\r
96 +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
\r
97 +;; General Public License for more details.
\r
99 +;; You should have received a copy of the GNU General Public License
\r
100 +;; along with Notmuch. If not, see <http://www.gnu.org/licenses/>.
\r
102 +;; Authors: David Edmondson <dme@dme.org>
\r
104 +(require 'message)
\r
108 +(defcustom notmuch-address-command "notmuch-addresses"
\r
109 + "The command which generates possible addresses. It must take a
\r
110 +single argument and output a list of possible matches, one per
\r
115 +(defvar notmuch-address-message-alist-member
\r
116 + '("^\\(Resent-\\)?\\(To\\|B?Cc\\|Reply-To\\|From\\|Mail-Followup-To\\|Mail-Copies-To\\):"
\r
117 + . notmuch-address-expand-name))
\r
119 +(defvar notmuch-address-history nil)
\r
121 +(defun notmuch-address-message-insinuate ()
\r
122 + (if (not (memq notmuch-address-message-alist-member message-completion-alist))
\r
123 + (setq message-completion-alist
\r
124 + (push notmuch-address-message-alist-member message-completion-alist))))
\r
126 +(defun notmuch-address-options (original)
\r
127 + (process-lines notmuch-address-command original))
\r
129 +(defun notmuch-address-expand-name ()
\r
130 + (let* ((end (point))
\r
131 + (beg (save-excursion
\r
132 + (re-search-backward "\\(\\`\\|[\n:,]\\)[ \t]*")
\r
133 + (goto-char (match-end 0))
\r
135 + (orig (buffer-substring-no-properties beg end))
\r
136 + (completion-ignore-case t)
\r
137 + (options (notmuch-address-options orig))
\r
138 + (chosen (if (eq (length options) 1)
\r
140 + (completing-read "Address: " (cdr options) nil nil (car options)
\r
141 + 'notmuch-address-history))))
\r
143 + (push chosen notmuch-address-history)
\r
144 + (delete-region beg end)
\r
145 + (insert chosen))))
\r
147 +;; Copied from `w3m-which-command'.
\r
148 +(defun notmuch-address-locate-command (command)
\r
149 + "Return non-nil if `command' is an executable either on
\r
150 +`exec-path' or an absolute pathname."
\r
151 + (when (stringp command)
\r
152 + (if (and (file-name-absolute-p command)
\r
153 + (file-executable-p command))
\r
155 + (setq command (file-name-nondirectory command))
\r
156 + (catch 'found-command
\r
158 + (dolist (dir exec-path)
\r
159 + (setq bin (expand-file-name command dir))
\r
160 + (when (or (and (file-executable-p bin)
\r
161 + (not (file-directory-p bin)))
\r
162 + (and (file-executable-p (setq bin (concat bin ".exe")))
\r
163 + (not (file-directory-p bin))))
\r
164 + (throw 'found-command bin))))))))
\r
166 +;; If we can find the program specified by `notmuch-address-command',
\r
167 +;; insinuate ourselves into `message-mode'.
\r
168 +(when (notmuch-address-locate-command notmuch-address-command)
\r
169 + (notmuch-address-message-insinuate))
\r
173 +(provide 'notmuch-address)
\r