[PATCH] emacs: Add notmuch-address.el for address completion using notmuch

2010-04-26 Thread David Edmondson
On Mon, 26 Apr 2010 11:03:36 -0700, Carl Worth  wrote:
> Thanks. I've pushed this. Bonus points to someone who fixes it to avoid
> printing "1 matches".

It shouldn't do that:

  (let* (...
 (num-options (length options))
 (chosen (if (eq num-options 1)
 (car options)
   (completing-read (format "Address (%s matches): " 
num-options)
(cdr options) nil nil (car options)
'notmuch-address-history

Does it?

More interesting is the zero matches case...

dme.
-- 
David Edmondson, http://dme.org
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: 



[PATCH] emacs: Add notmuch-address.el for address completion using notmuch

2010-04-26 Thread David Edmondson

   To: David Edmondson , notmuch at notmuchmail.org, dirk at 
yoom.home.cworth.org
   Cc: carl at ut.hh.sledj.net
   Date: Mon, 26 Apr 2010 08:21:51 -0700

Something interesting is happening here :-)

dme.
-- 
David Edmondson, http://dme.org
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: 



[PATCH] emacs: Add notmuch-address.el for address completion using notmuch

2010-04-26 Thread David Edmondson
On Mon, 26 Apr 2010 08:21:51 -0700, Carl Worth  wrote:
> > > Finally, though, I haven't figured out how to get more than a single
> > > match from this. If the first match isn't what I want, how do I see and
> > > choose later matches?
> > 
> > M-n to move forward in the list, M-p to move backwards (including into
> > any history you have accrued).
> 
> Ah-hah! Thanks for filling me in. I'm glad to finally have usable
> notmuch-based address completion now.
> 
>  Perhaps we could add a hint in the minibuffer prompt?
> 
>   Address (+6 more): Name Here 

Patch is sent for this, though given that it's not easy to change the
prompt as you step through, it says:

Address (7 match): Name Here 

> I'd like to come up with something more specific in that hint, but it
> gets a little long:
> 
>   Address (Use M-n/M-p or arrow keys for 6 more):

Moving through potential completions is pretty standard Emacs UI stuff,
so I'm not sure if it's necessary to explain? (Of course, that you had
to ask suggests otherwise...)

> I don't suppose it would be feasible to make Space and DEL navigate
> through the list as well would it?

Not with `completing-read', but I'll look at it after 0.3.

dme.
-- 
David Edmondson, http://dme.org
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: 



[PATCH] emacs: Add notmuch-address.el for address completion using notmuch

2010-04-26 Thread Sebastian Spaeth
On 2010-04-26, David Edmondson wrote:
> M-n to move forward in the list, M-p to move backwards (including into
> any history you have accrued).

Alternatively, some of us have that weird new invention on their
keyboards called "arrow keys" ;-)


[PATCH] emacs: Add notmuch-address.el for address completion using notmuch

2010-04-26 Thread David Edmondson
On Mon, 26 Apr 2010 13:29:42 +0200, "Sebastian Spaeth"  wrote:
> On 2010-04-26, David Edmondson wrote:
> > M-n to move forward in the list, M-p to move backwards (including into
> > any history you have accrued).
> 
> Alternatively, some of us have that weird new invention on their
> keyboards called "arrow keys" ;-)

New-fangled nonsense!

> Cc: carl at ut.hh.sledj.net

Gosh, where did that come from? Looks as though I generated it
(ut.hh.sledj.net is my desktop machine)...

dme.
-- 
David Edmondson, http://dme.org


[PATCH] emacs: Add notmuch-address.el for address completion using notmuch

2010-04-26 Thread David Edmondson
On Fri, 23 Apr 2010 17:49:38 -0700, Carl Worth  wrote:
> I finally hit on doing (require 'notmuch-address) in .emacs. As noted
> previously, can we please make (require 'notmuch) pull in all notmuch
> functionality rather than having it separated like this?

Patch sent.

> Finally, though, I haven't figured out how to get more than a single
> match from this. If the first match isn't what I want, how do I see and
> choose later matches?

M-n to move forward in the list, M-p to move backwards (including into
any history you have accrued).

dme.
-- 
David Edmondson, http://dme.org


[PATCH] emacs: Add notmuch-address.el for address completion using notmuch

2010-04-26 Thread Carl Worth
carl.d.worth at intel.com
On Mon, 26 Apr 2010 19:20:04 +0100, David Edmondson  wrote:
> On Mon, 26 Apr 2010 11:03:36 -0700, Carl Worth  wrote:
> > Thanks. I've pushed this. Bonus points to someone who fixes it to avoid
> > printing "1 matches".
> 
> It shouldn't do that:
...
> Does it?

Bah. My fault for glancing at the code (incorrectly) rather than running
it.

Move along, nothing to see here...

-Carl
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: 



[PATCH] emacs: Add notmuch-address.el for address completion using notmuch

2010-04-26 Thread Carl Worth
On Mon, 26 Apr 2010 17:28:47 +0100, David Edmondson  wrote:
> 
>To: David Edmondson , notmuch at notmuchmail.org, dirk at 
> yoom.home.cworth.org
>Cc: carl at ut.hh.sledj.net
>Date: Mon, 26 Apr 2010 08:21:51 -0700
> 
> Something interesting is happening here :-)

Dirk wasn't involved in the original message I was replying to at all.

And I can confirm that "notmuch reply id:87k4ru5vzp.fsf at ut.hh.sledj.net"
isn't inserting "dirk" anywhere.

But this is an address-completion thread, and I did test that
functionality by typing "dirk[TAB]". I would have thought that I had
deleted the results of any expansion, (or left the expanded results).

David, you seem to be having the problem with carl at ut.hh.sledj.net more
frequently, so perhaps you can identify the trigger.

-Carl
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: 



[PATCH] emacs: Add notmuch-address.el for address completion using notmuch

2010-04-26 Thread Carl Worth
On Mon, 26 Apr 2010 17:27:38 +0100, David Edmondson  wrote:
> Patch is sent for this, though given that it's not easy to change the
> prompt as you step through, it says:
> 
>   Address (7 match): Name Here 

Thanks. I've pushed this. Bonus points to someone who fixes it to avoid
printing "1 matches".

> Moving through potential completions is pretty standard Emacs UI stuff,
> so I'm not sure if it's necessary to explain? (Of course, that you had
> to ask suggests otherwise...)

It is funny that I've used emacs for all these years without learning
this.

But in general, I have been trying to keep the notmuch interface fairly
self-explanatory. I know that some people that have never used emacs at
all are giving notmuch a try, just to see what it's like. And I'd like
to help them have as positive experience as possible.

> > I don't suppose it would be feasible to make Space and DEL navigate
> > through the list as well would it?
> 
> Not with `completing-read', but I'll look at it after 0.3.

That's what I'd assumed. If we end up doing our own thing here, I'd even
have a few more things on my wishlist. I think I'd like for matching
addresses to start appearing in the minibuffer as I started typing,
(even before hitting TAB).

Of course, for that we're going to need a faster address completer,
which will mean getting the actual addresses into the database. So I'll
add that to my list of the many things I want to fix in the great
database-schema-rewrite that's coming soon.

-Carl

-- 
carl.d.worth at intel.com
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: 



[PATCH] emacs: Add notmuch-address.el for address completion using notmuch

2010-04-26 Thread Dirk Hohndel
On Mon, 26 Apr 2010 17:28:47 +0100, David Edmondson  wrote:
> 
>To: David Edmondson , notmuch at notmuchmail.org, dirk at 
> yoom.home.cworth.org

Looks like I now have an account on Carl's machine

>Cc: carl at ut.hh.sledj.net

Which is only fair, given that he has gotten himself an account
somewhere else as well :-)

> Something interesting is happening here :-)

Looks to me like some mail address line damage - and local domain
expansion with unqualified email addresses

/D

-- 
Dirk Hohndel
Intel Open Source Technology Center


[PATCH] emacs: Add notmuch-address.el for address completion using notmuch

2010-04-26 Thread Carl Worth
On Mon, 26 Apr 2010 11:49:46 +0100, David Edmondson  wrote:
> On Fri, 23 Apr 2010 17:49:38 -0700, Carl Worth  wrote:
> > I finally hit on doing (require 'notmuch-address) in .emacs. As noted
> > previously, can we please make (require 'notmuch) pull in all notmuch
> > functionality rather than having it separated like this?
> 
> Patch sent.

Pushed.

> > Finally, though, I haven't figured out how to get more than a single
> > match from this. If the first match isn't what I want, how do I see and
> > choose later matches?
> 
> M-n to move forward in the list, M-p to move backwards (including into
> any history you have accrued).

Ah-hah! Thanks for filling me in. I'm glad to finally have usable
notmuch-based address completion now.

 Perhaps we could add a hint in the minibuffer prompt?

Address (+6 more): Name Here 

I'd like to come up with something more specific in that hint, but it
gets a little long:

Address (Use M-n/M-p or arrow keys for 6 more):

:-P

I don't suppose it would be feasible to make Space and DEL navigate
through the list as well would it?

-Carl

-- 
carl.d.worth at intel.com
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: 



Re: [PATCH] emacs: Add notmuch-address.el for address completion using notmuch

2010-04-26 Thread David Edmondson
On Fri, 23 Apr 2010 17:49:38 -0700, Carl Worth cwo...@cworth.org wrote:
 I finally hit on doing (require 'notmuch-address) in .emacs. As noted
 previously, can we please make (require 'notmuch) pull in all notmuch
 functionality rather than having it separated like this?

Patch sent.

 Finally, though, I haven't figured out how to get more than a single
 match from this. If the first match isn't what I want, how do I see and
 choose later matches?

M-n to move forward in the list, M-p to move backwards (including into
any history you have accrued).

dme.
-- 
David Edmondson, http://dme.org
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH] emacs: Add notmuch-address.el for address completion using notmuch

2010-04-26 Thread Sebastian Spaeth
On 2010-04-26, David Edmondson wrote:
 M-n to move forward in the list, M-p to move backwards (including into
 any history you have accrued).

Alternatively, some of us have that weird new invention on their
keyboards called arrow keys ;-)
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH] emacs: Add notmuch-address.el for address completion using notmuch

2010-04-26 Thread Carl Worth
On Mon, 26 Apr 2010 11:49:46 +0100, David Edmondson d...@dme.org wrote:
 On Fri, 23 Apr 2010 17:49:38 -0700, Carl Worth cwo...@cworth.org wrote:
  I finally hit on doing (require 'notmuch-address) in .emacs. As noted
  previously, can we please make (require 'notmuch) pull in all notmuch
  functionality rather than having it separated like this?
 
 Patch sent.

Pushed.

  Finally, though, I haven't figured out how to get more than a single
  match from this. If the first match isn't what I want, how do I see and
  choose later matches?
 
 M-n to move forward in the list, M-p to move backwards (including into
 any history you have accrued).

Ah-hah! Thanks for filling me in. I'm glad to finally have usable
notmuch-based address completion now.

 Perhaps we could add a hint in the minibuffer prompt?

Address (+6 more): Name Here addr...@example.com

I'd like to come up with something more specific in that hint, but it
gets a little long:

Address (Use M-n/M-p or arrow keys for 6 more):

:-P

I don't suppose it would be feasible to make Space and DEL navigate
through the list as well would it?

-Carl

-- 
carl.d.wo...@intel.com


pgpSJBQtnbFZG.pgp
Description: PGP signature
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH] emacs: Add notmuch-address.el for address completion using notmuch

2010-04-26 Thread David Edmondson

   To: David Edmondson d...@dme.org, notmuch@notmuchmail.org, 
d...@yoom.home.cworth.org
   Cc: c...@ut.hh.sledj.net
   Date: Mon, 26 Apr 2010 08:21:51 -0700

Something interesting is happening here :-)

dme.
-- 
David Edmondson, http://dme.org


pgpgH6xAit11l.pgp
Description: PGP signature
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH] emacs: Add notmuch-address.el for address completion using notmuch

2010-04-26 Thread Carl Worth
On Mon, 26 Apr 2010 17:27:38 +0100, David Edmondson d...@dme.org wrote:
 Patch is sent for this, though given that it's not easy to change the
 prompt as you step through, it says:
 
   Address (7 match): Name Here addr...@example.com

Thanks. I've pushed this. Bonus points to someone who fixes it to avoid
printing 1 matches.

 Moving through potential completions is pretty standard Emacs UI stuff,
 so I'm not sure if it's necessary to explain? (Of course, that you had
 to ask suggests otherwise...)

It is funny that I've used emacs for all these years without learning
this.

But in general, I have been trying to keep the notmuch interface fairly
self-explanatory. I know that some people that have never used emacs at
all are giving notmuch a try, just to see what it's like. And I'd like
to help them have as positive experience as possible.

  I don't suppose it would be feasible to make Space and DEL navigate
  through the list as well would it?
 
 Not with `completing-read', but I'll look at it after 0.3.

That's what I'd assumed. If we end up doing our own thing here, I'd even
have a few more things on my wishlist. I think I'd like for matching
addresses to start appearing in the minibuffer as I started typing,
(even before hitting TAB).

Of course, for that we're going to need a faster address completer,
which will mean getting the actual addresses into the database. So I'll
add that to my list of the many things I want to fix in the great
database-schema-rewrite that's coming soon.

-Carl

-- 
carl.d.wo...@intel.com


pgprS3DefQ77I.pgp
Description: PGP signature
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH] emacs: Add notmuch-address.el for address completion using notmuch

2010-04-26 Thread Carl Worth
On Mon, 26 Apr 2010 17:28:47 +0100, David Edmondson d...@dme.org wrote:
 
To: David Edmondson d...@dme.org, notmuch@notmuchmail.org, 
 d...@yoom.home.cworth.org
Cc: c...@ut.hh.sledj.net
Date: Mon, 26 Apr 2010 08:21:51 -0700
 
 Something interesting is happening here :-)

Dirk wasn't involved in the original message I was replying to at all.

And I can confirm that notmuch reply id:87k4ru5vzp@ut.hh.sledj.net
isn't inserting dirk anywhere.

But this is an address-completion thread, and I did test that
functionality by typing dirk[TAB]. I would have thought that I had
deleted the results of any expansion, (or left the expanded results).

David, you seem to be having the problem with c...@ut.hh.sledj.net more
frequently, so perhaps you can identify the trigger.

-Carl


pgpDAIJebpwuY.pgp
Description: PGP signature
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH] emacs: Add notmuch-address.el for address completion using notmuch

2010-04-26 Thread Carl Worth
carl.d.wo...@intel.com
On Mon, 26 Apr 2010 19:20:04 +0100, David Edmondson d...@dme.org wrote:
 On Mon, 26 Apr 2010 11:03:36 -0700, Carl Worth cwo...@cworth.org wrote:
  Thanks. I've pushed this. Bonus points to someone who fixes it to avoid
  printing 1 matches.
 
 It shouldn't do that:
...
 Does it?

Bah. My fault for glancing at the code (incorrectly) rather than running
it.

Move along, nothing to see here...

-Carl


pgpPBuxY81ky8.pgp
Description: PGP signature
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH] emacs: Add notmuch-address.el for address completion using notmuch

2010-04-23 Thread Carl Worth
On Thu, 22 Apr 2010 10:03:43 +0100, David Edmondson  wrote:
> A tool `notmuch-addresses' is required to produce addresses which
> match a query string. An example of a suitable script can be found in
> the git repository at
> http://jkr.acm.jhu.edu/git/notmuch_addresses.git
> There are no doubt others.

I applied this, but I've had some difficulty figuring out how to use it
given just the above instructions.

I did install the above-referenced python script[*] as notmuch-addresses
on my path. And I tested it at the command line and it seemed to act
reasonably.

But hitting TAB in message-mode continued to frobnicate BBDB instead.

I finally hit on doing (require 'notmuch-address) in .emacs. As noted
previously, can we please make (require 'notmuch) pull in all notmuch
functionality rather than having it separated like this?

Finally, though, I haven't figured out how to get more than a single
match from this. If the first match isn't what I want, how do I see and
choose later matches?

In the meantime, I've pushed this already.

-Carl

[*] Which also made me figure out how to install our python bindings. I
found "sudo python ./setup.py install" eventually, but it would be quite
nice if "sudo make install" took care of that.
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: 



[PATCH] emacs: Add notmuch-address.el for address completion using notmuch

2010-04-22 Thread Sebastian Spaeth
On 2010-04-22, David Edmondson wrote:
> A tool `notmuch-addresses' is required to produce addresses which
> match a query string. An example of a suitable script can be found in
> the git repository at
> http://jkr.acm.jhu.edu/git/notmuch_addresses.git
> There are no doubt others.

no doubt :-).

This works great, the only "disadvantage" is that it will disable bbdb
and eudc by default if a notmuch-addresses binary is available. I think
that is a reasonable assumption.

Is it really necessary to try to append ".exe"? Even Windows users
should be able to provide the full binary name if asked for it
(especially when using emacs on Windows).

in any case:

Signed-off: Sebastian Spaeth 


[PATCH] emacs: Add notmuch-address.el for address completion using notmuch

2010-04-22 Thread David Edmondson
A tool `notmuch-addresses' is required to produce addresses which
match a query string. An example of a suitable script can be found in
the git repository at
http://jkr.acm.jhu.edu/git/notmuch_addresses.git
There are no doubt others.
---
 emacs/Makefile.local |3 +-
 emacs/notmuch-address.el |   91 ++
 2 files changed, 93 insertions(+), 1 deletions(-)
 create mode 100644 emacs/notmuch-address.el

diff --git a/emacs/Makefile.local b/emacs/Makefile.local
index e5013b3..7537c3d 100644
--- a/emacs/Makefile.local
+++ b/emacs/Makefile.local
@@ -8,7 +8,8 @@ emacs_sources := \
$(dir)/notmuch-show.el \
$(dir)/notmuch-wash.el \
$(dir)/notmuch-hello.el \
-   $(dir)/notmuch-mua.el
+   $(dir)/notmuch-mua.el \
+   $(dir)/notmuch-address.el

 emacs_images := \
$(dir)/notmuch-logo.png
diff --git a/emacs/notmuch-address.el b/emacs/notmuch-address.el
new file mode 100644
index 000..69a52a2
--- /dev/null
+++ b/emacs/notmuch-address.el
@@ -0,0 +1,91 @@
+;; notmuch-address.el --- address completion with notmuch
+;;
+;; Copyright ?? David Edmondson
+;;
+;; This file is part of Notmuch.
+;;
+;; Notmuch is free software: you can redistribute it and/or modify it
+;; under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+;;
+;; Notmuch is distributed in the hope that it will be useful, but
+;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+;; General Public License for more details.
+;;
+;; You should have received a copy of the GNU General Public License
+;; along with Notmuch.  If not, see .
+;;
+;; Authors: David Edmondson 
+
+(require 'message)
+
+;;
+
+(defcustom notmuch-address-command "notmuch-addresses"
+  "The command which generates possible addresses. It must take a
+single argument and output a list of possible matches, one per
+line."
+  :type 'string
+  :group 'notmuch)
+
+(defvar notmuch-address-message-alist-member
+  
'("^\\(Resent-\\)?\\(To\\|B?Cc\\|Reply-To\\|From\\|Mail-Followup-To\\|Mail-Copies-To\\):"
+ . notmuch-address-expand-name))
+
+(defvar notmuch-address-history nil)
+
+(defun notmuch-address-message-insinuate ()
+  (if (not (memq notmuch-address-message-alist-member 
message-completion-alist))
+  (setq message-completion-alist
+   (push notmuch-address-message-alist-member 
message-completion-alist
+
+(defun notmuch-address-options (original)
+  (process-lines notmuch-address-command original))
+
+(defun notmuch-address-expand-name ()
+  (let* ((end (point))
+(beg (save-excursion
+   (re-search-backward "\\(\\`\\|[\n:,]\\)[ \t]*")
+   (goto-char (match-end 0))
+   (point)))
+(orig (buffer-substring-no-properties beg end))
+(completion-ignore-case t)
+(options (notmuch-address-options orig))
+(chosen (if (eq (length options) 1)
+(car options)
+  (completing-read "Address: " (cdr options) nil nil (car 
options)
+   'notmuch-address-history
+(when chosen
+  (push chosen notmuch-address-history)
+  (delete-region beg end)
+  (insert chosen
+
+;; Copied from `w3m-which-command'.
+(defun notmuch-address-locate-command (command)
+  "Return non-nil if `command' is an executable either on
+`exec-path' or an absolute pathname."
+  (when (stringp command)
+(if (and (file-name-absolute-p command)
+(file-executable-p command))
+   command
+  (setq command (file-name-nondirectory command))
+  (catch 'found-command
+   (let (bin)
+ (dolist (dir exec-path)
+   (setq bin (expand-file-name command dir))
+   (when (or (and (file-executable-p bin)
+  (not (file-directory-p bin)))
+ (and (file-executable-p (setq bin (concat bin ".exe")))
+  (not (file-directory-p bin
+ (throw 'found-command bin
+
+;; If we can find the program specified by `notmuch-address-command',
+;; insinuate ourselves into `message-mode'.
+(when (notmuch-address-locate-command notmuch-address-command)
+  (notmuch-address-message-insinuate))
+
+;;
+
+(provide 'notmuch-address)
-- 
1.7.0



[PATCH] emacs: Add notmuch-address.el for address completion using notmuch

2010-04-22 Thread Dirk Hohndel
On Thu, 22 Apr 2010 10:03:43 +0100, David Edmondson  wrote:
> A tool `notmuch-addresses' is required to produce addresses which
> match a query string. An example of a suitable script can be found in
> the git repository at
> http://jkr.acm.jhu.edu/git/notmuch_addresses.git
> There are no doubt others.

+1 on getting this into 0.3

/D

-- 
Dirk Hohndel
Intel Open Source Technology Center


[PATCH] emacs: Add notmuch-address.el for address completion using notmuch

2010-04-22 Thread David Edmondson
A tool `notmuch-addresses' is required to produce addresses which
match a query string. An example of a suitable script can be found in
the git repository at
http://jkr.acm.jhu.edu/git/notmuch_addresses.git
There are no doubt others.
---
 emacs/Makefile.local |3 +-
 emacs/notmuch-address.el |   91 ++
 2 files changed, 93 insertions(+), 1 deletions(-)
 create mode 100644 emacs/notmuch-address.el

diff --git a/emacs/Makefile.local b/emacs/Makefile.local
index e5013b3..7537c3d 100644
--- a/emacs/Makefile.local
+++ b/emacs/Makefile.local
@@ -8,7 +8,8 @@ emacs_sources := \
$(dir)/notmuch-show.el \
$(dir)/notmuch-wash.el \
$(dir)/notmuch-hello.el \
-   $(dir)/notmuch-mua.el
+   $(dir)/notmuch-mua.el \
+   $(dir)/notmuch-address.el
 
 emacs_images := \
$(dir)/notmuch-logo.png
diff --git a/emacs/notmuch-address.el b/emacs/notmuch-address.el
new file mode 100644
index 000..69a52a2
--- /dev/null
+++ b/emacs/notmuch-address.el
@@ -0,0 +1,91 @@
+;; notmuch-address.el --- address completion with notmuch
+;;
+;; Copyright © David Edmondson
+;;
+;; This file is part of Notmuch.
+;;
+;; Notmuch is free software: you can redistribute it and/or modify it
+;; under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+;;
+;; Notmuch is distributed in the hope that it will be useful, but
+;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+;; General Public License for more details.
+;;
+;; You should have received a copy of the GNU General Public License
+;; along with Notmuch.  If not, see http://www.gnu.org/licenses/.
+;;
+;; Authors: David Edmondson d...@dme.org
+
+(require 'message)
+
+;;
+
+(defcustom notmuch-address-command notmuch-addresses
+  The command which generates possible addresses. It must take a
+single argument and output a list of possible matches, one per
+line.
+  :type 'string
+  :group 'notmuch)
+
+(defvar notmuch-address-message-alist-member
+  
'(^\\(Resent-\\)?\\(To\\|B?Cc\\|Reply-To\\|From\\|Mail-Followup-To\\|Mail-Copies-To\\):
+ . notmuch-address-expand-name))
+
+(defvar notmuch-address-history nil)
+
+(defun notmuch-address-message-insinuate ()
+  (if (not (memq notmuch-address-message-alist-member 
message-completion-alist))
+  (setq message-completion-alist
+   (push notmuch-address-message-alist-member 
message-completion-alist
+
+(defun notmuch-address-options (original)
+  (process-lines notmuch-address-command original))
+
+(defun notmuch-address-expand-name ()
+  (let* ((end (point))
+(beg (save-excursion
+   (re-search-backward \\(\\`\\|[\n:,]\\)[ \t]*)
+   (goto-char (match-end 0))
+   (point)))
+(orig (buffer-substring-no-properties beg end))
+(completion-ignore-case t)
+(options (notmuch-address-options orig))
+(chosen (if (eq (length options) 1)
+(car options)
+  (completing-read Address:  (cdr options) nil nil (car 
options)
+   'notmuch-address-history
+(when chosen
+  (push chosen notmuch-address-history)
+  (delete-region beg end)
+  (insert chosen
+
+;; Copied from `w3m-which-command'.
+(defun notmuch-address-locate-command (command)
+  Return non-nil if `command' is an executable either on
+`exec-path' or an absolute pathname.
+  (when (stringp command)
+(if (and (file-name-absolute-p command)
+(file-executable-p command))
+   command
+  (setq command (file-name-nondirectory command))
+  (catch 'found-command
+   (let (bin)
+ (dolist (dir exec-path)
+   (setq bin (expand-file-name command dir))
+   (when (or (and (file-executable-p bin)
+  (not (file-directory-p bin)))
+ (and (file-executable-p (setq bin (concat bin .exe)))
+  (not (file-directory-p bin
+ (throw 'found-command bin
+
+;; If we can find the program specified by `notmuch-address-command',
+;; insinuate ourselves into `message-mode'.
+(when (notmuch-address-locate-command notmuch-address-command)
+  (notmuch-address-message-insinuate))
+
+;;
+
+(provide 'notmuch-address)
-- 
1.7.0

___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH] emacs: Add notmuch-address.el for address completion using notmuch

2010-04-22 Thread Sebastian Spaeth
On 2010-04-22, David Edmondson wrote:
 A tool `notmuch-addresses' is required to produce addresses which
 match a query string. An example of a suitable script can be found in
 the git repository at
 http://jkr.acm.jhu.edu/git/notmuch_addresses.git
 There are no doubt others.

no doubt :-).

This works great, the only disadvantage is that it will disable bbdb
and eudc by default if a notmuch-addresses binary is available. I think
that is a reasonable assumption.

Is it really necessary to try to append .exe? Even Windows users
should be able to provide the full binary name if asked for it
(especially when using emacs on Windows).

in any case:

Signed-off: Sebastian Spaeth sebast...@sspaeth.de
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH] emacs: Add notmuch-address.el for address completion using notmuch

2010-04-22 Thread Dirk Hohndel
On Thu, 22 Apr 2010 10:03:43 +0100, David Edmondson d...@dme.org wrote:
 A tool `notmuch-addresses' is required to produce addresses which
 match a query string. An example of a suitable script can be found in
 the git repository at
 http://jkr.acm.jhu.edu/git/notmuch_addresses.git
 There are no doubt others.

+1 on getting this into 0.3

/D

-- 
Dirk Hohndel
Intel Open Source Technology Center
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch