Package: notmuch-mutt
Version: 0.18.1-1
Severity: wishlist
Tags: patch

Thanks for maintaining notmuch!

I'm a long-time mutt user, but have been experimenting with the emacs client,
and found the option that returned the whole thread based on your search very
useful. The notmuch-mutt implementation seemed to lack this functionality, and
at least for the near future I'll probably want to stick with mutt.

I found the combination of using notmuch-mutt search FOO, selecting the message
I wanted to see the thread on, and then using notmuch-mutt thread to
reconstruct the thread for a single message didn't match my workflow well.

I've implemented a proof-of-concept patch that seems to do what I want. It
could probably be implemented a little cleaner as options to search or thread,
though I'll leave that to someone who knows their way around perl better.

Essentially, it does exactly what notmuch-mutt search does, but gets a list of
the thread ids of the search terms, and then passes the thread ids to the
search function, which then symlinks all the messages in relevent threads.

diff --git a/contrib/notmuch-mutt/notmuch-mutt 
b/contrib/notmuch-mutt/notmuch-mutt
index 4969e4b..3396198 100755
--- a/contrib/notmuch-mutt/notmuch-mutt
+++ b/contrib/notmuch-mutt/notmuch-mutt
@@ -94,6 +94,25 @@ sub search_action($$$@) {
     }
 }
 
+sub thread_search_action($$$@) {
+    my ($interactive, $results_dir, $remove_dups, @params) = @_;
+
+    if (! $interactive) {
+       my $search_cmd = 'notmuch search --output=threads ' . 
shell_quote(join(' ', @params));
+       my $query = `$search_cmd`;
+       chomp($query);
+       search($results_dir, $remove_dups, $query);
+    } else {
+       my $query = prompt("search ('?' for man): ", join(' ', @params));
+       my $search_cmd = 'notmuch search --output=threads ' . 
shell_quote("$query");
+       $query = `$search_cmd`;
+       chomp($query);
+       if ($query ne "") {
+           search($results_dir, $remove_dups, $query);
+       }
+    }
+}
+
 sub thread_action($$@) {
     my ($results_dir, $remove_dups, @params) = @_;
 
@@ -151,6 +170,8 @@ sub main() {
        search_action($interactive, $results_dir, $remove_dups, @params);
     } elsif ($action eq "thread") {
        thread_action($results_dir, $remove_dups, @params);
+    } elsif ($action eq "thread-search") {
+       thread_search_action($interactive, $results_dir, $remove_dups, @params);
     } elsif ($action eq "tag") {
        tag_action(@params);
     } else {
@@ -172,6 +193,8 @@ notmuch-mutt - notmuch (of a) helper for Mutt
 
 =item B<notmuch-mutt> [I<OPTION>]... search [I<SEARCH-TERM>]...
 
+=item B<notmuch-mutt> [I<OPTION>]... thread-search [I<SEARCH-TERM>]...
+
 =item B<notmuch-mutt> [I<OPTION>]... thread < I<MAIL>
 
 =item B<notmuch-mutt> [I<OPTION>]... tag [I<TAGS>]... < I<MAIL>


live well,
  vagrant

-- System Information:
Debian Release: jessie/sid
  APT prefers testing
  APT policy: (500, 'testing'), (120, 'unstable')
Architecture: amd64 (x86_64)
Foreign Architectures: i386
armhf

Kernel: Linux 3.14-1-amd64 (SMP w/4 CPU cores)
Locale: LANG=en_US.utf8, LC_CTYPE=en_US.utf8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages notmuch-mutt depends on:
ii  libmail-box-perl           2.115-1
ii  libmailtools-perl          2.12-1
ii  libstring-shellquote-perl  1.03-1
ii  libterm-readline-gnu-perl  1.24-2
ii  notmuch                    0.18.1-1

Versions of packages notmuch-mutt recommends:
ii  mutt  1.5.23-1

notmuch-mutt suggests no packages.

-- no debconf information

Attachment: signature.asc
Description: Digital signature

Reply via email to