unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* Using notmuch as an address book for tab-completion
@ 2010-03-21  2:35 Jesse Rosenthal
  2010-03-21  2:41 ` Jesse Rosenthal
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Jesse Rosenthal @ 2010-03-21  2:35 UTC (permalink / raw
  To: notmuch

Dear All,

There was some talk on IRC ages ago about using notmuch as an
address-book for tab-completion in emacs message mode. Thanks to some
great recent work (Ingmar Vanhassel's shared lib and Sebastians's
cnotmuch python lib) I have been able to take a first step in that
direction. I've written a python script (with some help and suggestions
from spaetz) which can perform the address-book functionality, and a
backend for emacs's EUDC address-lookup functionality to access the
script.

They are available by the following commands:

git clone http://jkr.acm.jhu.edu/git/notmuch_addresses.git
git clone http://jkr.acm.jhu.edu/git/notmuch_eudc.git

Remember, neither of these will do you much good with the shared lib and
cnotmuch installed.

At the moment, the script works by search addresses that you have
written to (or CC'd or BCC'd) in the past. This seems like a good
utility-speed tradeoff, but it would be easy to hack the script to
search a different set of messages. Give three letters (it looks through
first names, last names, and email addresses) it returns results from my
12K messages in well under a second. 

The responses are sorted by frequency, and each email address is
associated with the most frequently used real name (null real-names are
avoided, unless they're the only option).

The script can be run from the command line by:
$ python notmuch_addresses.py query

To get tab completion from emacs, you have to install the script into
your path, make it executable, and then put my eudcb-notmuch.el file
into your load path (you should byte-compile it too). DON'T CHANGE THE
TITLE OF THE .EL FILE! EUDC looks for a specific title based on
protocol.

Then add the following to your .emacs:

(eudc-set-server "localhost" 'notmuch t)
(setq eudc-server-hotlist '(("localhost" . notmuch)))
(setq eudc-inline-expansion-servers 'hotlist)

if you wish to use BBDB too (likely before you use notmuch), then
you should use something like this:

(eudc-set-server "localhost" 'bbdb t)
(eudc-protocol-set 'eudc-inline-expansion-format 
		   '("%s %s <%s>" firstname lastname net)
		   'bbdb)
(eudc-set-server "localhost" 'notmuch t)
(setq eudc-server-hotlist '(("localhost" . bbdb)
			    ("localhost" . notmuch)))
(setq eudc-inline-expansion-servers 'hotlist)

That should do it. Please let me know if it works for you.

(For those of you who care, eudcb-notmuch.el has a few hacky bits to
hide the fact that notmuch really isn't an address book. That is, it
doesn't know the difference between names and email addresses. So
everything you enter just goes in as one string, which I call "name."
Back-end stuff, but if you're looking through the code, that might make
a few things clearer.)

Best,
Jesse

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Using notmuch as an address book for tab-completion
  2010-03-21  2:35 Using notmuch as an address book for tab-completion Jesse Rosenthal
@ 2010-03-21  2:41 ` Jesse Rosenthal
  2010-03-21 20:18 ` Sebastian Spaeth
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 9+ messages in thread
From: Jesse Rosenthal @ 2010-03-21  2:41 UTC (permalink / raw
  To: notmuch

Normally, I wouldn't respond to myself to fix a typo, but this seemed
important.

> Remember, neither of these will do you much good with the shared lib and
> cnotmuch installed.

I meant, of course, that neither would do you much good *WITHOUT* the
shared lib and cnotmuch installed.

Apologies,
Jesse

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Using notmuch as an address book for tab-completion
  2010-03-21  2:35 Using notmuch as an address book for tab-completion Jesse Rosenthal
  2010-03-21  2:41 ` Jesse Rosenthal
@ 2010-03-21 20:18 ` Sebastian Spaeth
  2010-03-21 20:30   ` Sandra Snan
  2010-03-21 23:13   ` Michal Sojka
  2010-03-22 10:14 ` Ruben Pollan
  2010-03-23 12:37 ` Sebastian Spaeth
  3 siblings, 2 replies; 9+ messages in thread
From: Sebastian Spaeth @ 2010-03-21 20:18 UTC (permalink / raw
  To: notmuch

On Sat, 20 Mar 2010 22:35:42 -0400, Jesse Rosenthal <jrosenthal@jhu.edu> wrote:
> I've written a python script (with some help and suggestions
> from spaetz) which can perform the address-book functionality, and a
> backend for emacs's EUDC address-lookup functionality to access the
> script.

Thanks for sharing, I am very much looking forward to using that. This
is one more selling point for notmuch :-). Glad the python bindings were
of some use and I am willing to take improvement requests, if you find
some peculiarities in them.

I really look forward to integrate bbdb and notmuch addresses...

> Remember, neither of these will do you much good with the shared lib and
> cnotmuch installed.

That reminds me that there is still no installation tool for cnotmuch at
all. I'll have to have a look into that.
 
> To get tab completion from emacs, you have to install the script into
> your path, make it executable, and then put my eudcb-notmuch.el file
> into your load path (you should byte-compile it too). DON'T CHANGE THE
> TITLE OF THE .EL FILE! EUDC looks for a specific title based on
> protocol.

Silly question: How do I byte-compile stuff for emacs? I am a helpless noob when there
is no make install-emacs command. :-)

Will report back if it works. If yes, this is definitely stuff for the
notmuch help wiki.

Sebastian

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Using notmuch as an address book for tab-completion
  2010-03-21 20:18 ` Sebastian Spaeth
@ 2010-03-21 20:30   ` Sandra Snan
  2010-03-21 23:13   ` Michal Sojka
  1 sibling, 0 replies; 9+ messages in thread
From: Sandra Snan @ 2010-03-21 20:30 UTC (permalink / raw
  To: Sebastian Spaeth, notmuch

On Sun, 21 Mar 2010 21:18:12 +0100, "Sebastian Spaeth" <Sebastian@SSpaeth.de> wrote:
> Silly question: How do I byte-compile stuff for emacs? I am a helpless noob when there
> is no make install-emacs command. :-)

Sure, here’s how:

M-x byte-compile-file
type path to file
RET

Good luck!

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Using notmuch as an address book for tab-completion
  2010-03-21 20:18 ` Sebastian Spaeth
  2010-03-21 20:30   ` Sandra Snan
@ 2010-03-21 23:13   ` Michal Sojka
  2010-03-22  9:04     ` Sebastian Spaeth
  1 sibling, 1 reply; 9+ messages in thread
From: Michal Sojka @ 2010-03-21 23:13 UTC (permalink / raw
  To: Sebastian Spaeth, notmuch

On Sun, 21 Mar 2010, Sebastian Spaeth wrote:
> That reminds me that there is still no installation tool for cnotmuch at
> all. I'll have to have a look into that.

Hi, I have also a silly question :) Why did you call it cnotmuch? I'd
expect such a thing to be called pynotmuch or similar. When I saw
cnotmuch here I had to search other emails to find what it really is.
Fortunately, with notmuch, I found it very quickly :-D.

M.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Using notmuch as an address book for tab-completion
  2010-03-21 23:13   ` Michal Sojka
@ 2010-03-22  9:04     ` Sebastian Spaeth
  0 siblings, 0 replies; 9+ messages in thread
From: Sebastian Spaeth @ 2010-03-22  9:04 UTC (permalink / raw
  To: Michal Sojka, notmuch

On Mon, 22 Mar 2010 00:13:57 +0100, Michal Sojka <sojkam1@fel.cvut.cz> wrote:
> On Sun, 21 Mar 2010, Sebastian Spaeth wrote:
> > That reminds me that there is still no installation tool for cnotmuch at
> > all. I'll have to have a look into that.
> 
> Hi, I have also a silly question :) Why did you call it cnotmuch? I'd
> expect such a thing to be called pynotmuch or similar. When I saw
> cnotmuch here I had to search other emails to find what it really is.
> Fortunately, with notmuch, I found it very quickly :-D.

Hi Michal,

no silly question at all ;). I found pynotmuch a bit predictive and
boring, and as this is the notmuch bindings to the C-library notmuch, I
just called it 'cnotmuch'. A "pynotmuch" would be a pure python
re-implementation in my mindset...

Just like the c-version of the StringIO module is called cStringIO. etc,
so I am not completely off the track here.

Having that said, I am not particularly attached to that name and can
easily change it. I am in the process of uploading it to pypi.python.org
though, so it will soon be available for a simple local install with
"easy_install cnotmuch".

Next to finding it, the only reference a user will usually only need is
"from cnotmuch import notmuch", the rest is just "notmuch" stuff.

Sebastian

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Using notmuch as an address book for tab-completion
  2010-03-21  2:35 Using notmuch as an address book for tab-completion Jesse Rosenthal
  2010-03-21  2:41 ` Jesse Rosenthal
  2010-03-21 20:18 ` Sebastian Spaeth
@ 2010-03-22 10:14 ` Ruben Pollan
  2010-03-22 12:40   ` Sebastian Spaeth
  2010-03-23 12:37 ` Sebastian Spaeth
  3 siblings, 1 reply; 9+ messages in thread
From: Ruben Pollan @ 2010-03-22 10:14 UTC (permalink / raw
  To: Jesse Rosenthal; +Cc: notmuch

[-- Attachment #1: Type: text/plain, Size: 939 bytes --]

On 22:35, Sat 20 Mar 10, Jesse Rosenthal wrote:
> There was some talk on IRC ages ago about using notmuch as an
> address-book for tab-completion in emacs message mode. Thanks to some
> great recent work (Ingmar Vanhassel's shared lib and Sebastians's
> cnotmuch python lib) I have been able to take a first step in that
> direction. I've written a python script (with some help and suggestions
> from spaetz) which can perform the address-book functionality, and a
> backend for emacs's EUDC address-lookup functionality to access the
> script.

Nice feature. I think it should be implemented in the library. There is already
a function notmuch_database_get_all_tags, will be nice to have a function
notmuch_database_get_all_addresses. And make it somehow accessible from the
notmuch cli.

-- 
Rubén Pollán  | jabber:meskio@jabber.org
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Sed realistas, exigid lo imposible.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Using notmuch as an address book for tab-completion
  2010-03-22 10:14 ` Ruben Pollan
@ 2010-03-22 12:40   ` Sebastian Spaeth
  0 siblings, 0 replies; 9+ messages in thread
From: Sebastian Spaeth @ 2010-03-22 12:40 UTC (permalink / raw
  To: notmuch

On Mon, 22 Mar 2010 11:14:22 +0100, Ruben Pollan <meskio@sindominio.net> wrote:
> Nice feature. I think it should be implemented in the library. There is already
> a function notmuch_database_get_all_tags, will be nice to have a function
> notmuch_database_get_all_addresses.

Actually, i don't think it's necessary to extend the library to get all
addresses, it is really trivial to get them, using the current API. As
to whether to extend the notmuch binary as to output all addresses, I
think this will be taken care of the output filtering once
implemented. e.g. get all addresses with:

notmuch show --format=json --output:to,cc,bcc ''

Sebastian

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Using notmuch as an address book for tab-completion
  2010-03-21  2:35 Using notmuch as an address book for tab-completion Jesse Rosenthal
                   ` (2 preceding siblings ...)
  2010-03-22 10:14 ` Ruben Pollan
@ 2010-03-23 12:37 ` Sebastian Spaeth
  3 siblings, 0 replies; 9+ messages in thread
From: Sebastian Spaeth @ 2010-03-23 12:37 UTC (permalink / raw
  To: Jesse Rosenthal, notmuch

On Sat, 20 Mar 2010 22:35:42 -0400, Jesse Rosenthal <jrosenthal@jhu.edu> wrote:
> There was some talk on IRC ages ago about using notmuch as an
> address-book for tab-completion in emacs message mode. Thanks to some
> great recent work (Ingmar Vanhassel's shared lib and Sebastians's
> cnotmuch python lib) I have been able to take a first step in that
> direction. I've written a python script (with some help and suggestions
> from spaetz) which can perform the address-book functionality, and a
> backend for emacs's EUDC address-lookup functionality to access the
> script.

Just testing the integration. First comment:
When I search for "Seb", the first 2 hits, I get are:

Sebastian Spaeth <Sebastian@SSpaeth.de>
Sebastian Spaeth <sebastian@sspaeth.de>

I think the version I sent you, lower-cased all email addresses. Is it
intentional to have these as 2 separate email addresses?

Sebastian

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2010-03-23 12:37 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-21  2:35 Using notmuch as an address book for tab-completion Jesse Rosenthal
2010-03-21  2:41 ` Jesse Rosenthal
2010-03-21 20:18 ` Sebastian Spaeth
2010-03-21 20:30   ` Sandra Snan
2010-03-21 23:13   ` Michal Sojka
2010-03-22  9:04     ` Sebastian Spaeth
2010-03-22 10:14 ` Ruben Pollan
2010-03-22 12:40   ` Sebastian Spaeth
2010-03-23 12:37 ` Sebastian Spaeth

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).