[PATCH] Implement a simple read-eval-print loop.

Michal Sojka sojkam1 at fel.cvut.cz
Sun Nov 21 13:10:01 PST 2010


On Sun, 21 Nov 2010, Austin Clements wrote:
> Out of curiosity, why not simply use SSH control mastering? 

I use control mastering, but it still takes about five seconds to display
notmuch hello screen.

> You could even make that part of the "standard" remote notmuch script,
> without requiring the user to change anything in their ssh
> configuration. 

This is a great idea. Now I use this script to invoke notmuch remotely
and I don't have to create master connection manually.

#!/bin/bash
socket="$HOME/.ssh/notmuch-connection"
if [[ ! -S $socket ]]; then
    # Create master connection in background (the connection is closed
    # after 10 minutes)
    ssh -f -M -S $socket example.org sleep 600
fi
printf -v args "%q " "$@"
ssh -S $socket example.org notmuch $args

> This should be just as fast as a remote notmuch shell, but retains the
> ability to run multiple simultaneous operations and leverages all of
> the fancy session machinery already built in to ssh. It seems to me
> that ssh already does what you want, and I'm curious what the
> advantage is to reinventing the wheel.

You are probably right that notmuch shell would not help here. The big
delay in displaying notmuch-hello is mostly caused by ping delays which
add for each execution of notmuch count. So better then notmuch shell
might be a possibility to specify several commands at once and get all
the results together. Probably, the simplest thing would be to enhance
count subcommand so that it accepts multiple queries, possibly from
stdin.

Then we could use something like the following to determine the counts
of matched messages for saved searches:

$ (echo $query1; echo $query2; ...) | notmuch count --stdin
<count1>
<count2>
...

-Michal


More information about the notmuch mailing list