Hi gregor!

On Wed, 26 Mar 2025, gregor herrmann wrote:

> Here's a module I'm using locally since quite some time, in addition
> to other modules, and which might be useful for other notmuch users
> as well:
> 
> #v+
> % cat /home/gregoa/.lbdb/modules/m_notmuch_addrlookup
> #!/bin/sh
> 
> m_notmuch_addrlookup_query() {
>       NM=/usr/bin/notmuch-addrlookup
> 
>       if [ -x "$NM" ]; then
>               $NM --format=mutt "$@" | tail -n +2 | sed -e 's/"//g'
>       fi
> }
> #v-
> 
> notmuch-addrlookup retrieves email addresses from the notmuch
> database, the `tail' is because its output has a header:
> 
> #v+
> % /usr/bin/notmuch-addrlookup --format=mutt Roland
> Searching database ... 5 matching entries:
> rol...@debian.org     Roland Rosenfeld
> …
> #v-
> 
> and the `sed' because emails sometimes have names under quotation
> marks in their headers.

Many thanks for your contribution!

I fear that this won't make it into trixi since I try to start with
some test cases before I add new modules to lbdb in the meantime.
I did some early tests with notmuch-addrlookup and noted some (for me)
unexpected effects like looking up "example" returns only two lines
(with "example.org"), while looking up "example.com" returns 15 lines
with the same test database and config.
In contrast to this "notmuch address" returns 15 lines for
"example.com" and 16 lines for "example".
Seems that this needs some deeper digging including the question
whether to use "notmuch address" vs." notmuch-addrlookup".
Maybe this will result in some bug report against notmuch-addrlookup
(after I understand the root cause).

Then there's also the question of how to handle special cases of
empty or strangely quoted real names and mail addresses.  Here the
"--format=mutt" (since 0.10 or "--mutt" until version 0.9) option may
of notmuch-addrlookup may have some benefits, but with some sed voodoo
also "notmuch address" output may be possible.

Hopefully my test suite developed for m_mu (mailutils) can be
reused here to result in a robust implementation.

This said, it may take some time, but it pushes notmuch some lines up
in the TODO- and priority-list (where it was added in 2017).

Greetings
Roland

Reply via email to