Notmuch scripts

Carl Worth cworth at cworth.org
Fri Jun 24 11:29:21 PDT 2011


On Fri, 24 Jun 2011 13:28:21 +0200, ccx at te2000.cz wrote:
> As some of you know I have written several scripts that aid using
> notmuch, including an alternative to the notmuch-mutt perl script.

Thanks for sharing these, Jan!

> Since Carl Worth consented to include them into official distribution
> I am now cleaning them up, writing docs and extending it so it covers
> all features notmuch-mutt currently has.
...
> Or you can browse the code at:
> 	http://webprojekty.cz/ccx/loggerhead/zmuch/files

It's been interesting for me to read through the README here.

So much of the new functionality here consists of things I'd love to
have implemented in the core command-line interface of notmuch, (I
always have wanted it to be useful for direct command-line interaction
by a human). Some of these features I think have even be implemented
previously by Austin through his custom query parser.

The features I see that I'd really like to see in the core notmuch
command-line tool are:

	* Configurable "saved searches", (a syntax for expanding aliases
          for often-repeated search specifications).

	  That's an idea we've had for a while. What's new with the
	  zmuch implementation is the proposal of ":alias" for the
	  syntax. I think I might like that quite a bit. It looks a bit
	  easier to read (and type) than the previously-proposed
	  "{alias}".

	* Delivery of search results to a maildir of symlinks

	  The zmuch implementation has this functionality intertwined
	  with something that also invokes mutt. Obviously, people using
	  other MUAs might like to access this feature independently.

	  I think I'd like to see this as:

		notmuch search --format=maildir:/path/to/directory

	* Operations on files matching search terms (move, remove,
          xargs)

	  This isn't an operation I'd previously considered including in
	  notmuch, but it does seem generally quite useful.

	  Should we consider doing something like git does and allow
	  something like "notmuch xargs" simply find and invoke a shell
	  script named notmuch-xargs?

	  Doing that could let us get a bunch of this functionality in
	  place in the "core" sooner than if we waited for it to be
	  re-implemented in C.

	  Though if we did this, I think I'd be highly inclined to port
	  the scripts from zsh to bash or even POSIX sh. How hard would
	  that be?

	* Better date syntax for search specifications

	  That's something that's obviously been missing from notmuch
	  core from the beginning. And there have been several proposals
	  with patches to do this in various ways.

	* Implicit concatenation of search terms with OR

	  This seems like something easy to do with a command-line
	  arguemnt. Perhaps "notmuch search --or ..." ?

If we got all that into the core, then what would be left here would be:

	notmuch-mailvars.sh
	notmuch-mutt.sh

		These would provide integration of notmuch with mutt.

	notmuch-spam.sh
	notmuch-unspam.sh

		These would provide integration of notmuch with
		bsfilter, (and perhaps should be named to make that more
		clear---or generalized to justify the current name).

	notmuch-pager.sh

		I haven't looked at this to see what the colorization
		actually looks like, (I'm not always a huge fan of lots
		of color in my terminals). It seems that this would be
		more cleanly implemented as notmuch-colorize.sh or so
		and leave the pagination separate.

If we had that, I'd feel really comfortable having each of those in
contrib. I think contrib should be restricted to things which provide
integration of notmuch with some external tool, (and should make that
obvious by having a name like notmuch-<tool> or notmuch-<tool>.sh or
whatever).

All in all, there's definitely some very interesting functionality here,
and I definitely appreciate you sharing it. Let's figure out the best
way to get it all integrated into notmuch.

Maybe in the meantime we throw everything into contrib even if some of
it is seen as just proposals for better interfaces in the core tool? I
don't know.

>   * Every application that does not act as a proxy should use
>     environment variable NOTMUCH to find the actual notmuch executable.
> 
>   * Every application that acts as a proxy should ignore the NOTMUCH
> 	variable

That sounds reasonable enough to me. Perhaps these rules could go into a
new contrib/README that would set out some guidelines for writing
contrib tools, (such as notmuch-<tool> which I mentioned above).

> Configuration and temporary files:
> I like XDG specification.

I'm missing some context to know what you're suggesting here.

> I think it's bit unnecessary to have to have
> config files that belong only to few scripts littered all around my
> homedir.

We should be able to put configuration for contrib tools into the main
notmuch configuration file. If your tools don't want to read that file
directly, they should be able to get by with the interfaces provided by
"notmuch config set" and "notmuch config get". Obviously, each tool
should create its own section in the configuration file.

Is that an insane plan?

>   * Spam filter. Do you guys use any? What does it's interface look like?
>     I currently use bsfilter which I've found does it's job pretty
>     well.

I've currently got amavis and spamassassin adding extra headers, (and
below a certain threshold I've got maildrop delivering detected spam to
a separate maildir).

Currently, notmuch never sees the detected spam. Ever since we got
folder: support I've been meaning to let notmuch see it so that I can
use notmuch to dig into my spam when I suspect something got
mis-detected.

I don't currently have any system for getting user-provided feedback
into my spam filtering. Do you get that with bsfilter?

>   * Colors. I use bright fg on dark bg, but I understand somebody won't
>     be happy with this choice.

I'm pretty-much black-on-white only. I really want a similar experience
with my computer that I get from books. (Though I'm still waiting for
much better contrast from my computer displays—e-ink definitely helps a
lot for the very static use cases).

>   * New message processing. Currently I check for spam and I mute
>     selected threads. I can see this can be made quite configurable.
> 	Maybe create procmail equivalent for notmuch? :-)

I think lots of us have various hand-written scripts that call out to
"notmuch tag" a bunch. It's definitely a common idiom to have "notmuch
new" add a new tag, have the new-mail-processing script operate on
tag:new, and then have that script remove tag:new from the things it
processed.

An alternative approach has been proposed to make "notmuch new" able to
act on specified messages, (and accept an explicit list of tags to
add). That would make it much easier to actually use existing tools like
procmail directly with notmuch. Some people are currently using the
notmuch-deliver.sh script in use cases like this. (And that script is
another existing candidate for contrib.)

-Carl

-- 
carl.d.worth at intel.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: <http://notmuchmail.org/pipermail/notmuch/attachments/20110624/2ae6ce5c/attachment.pgp>


More information about the notmuch mailing list