patches to mutt-notmuch
authorScott Barker <scott@mostlylinux.ca>
Fri, 10 Feb 2012 21:58:35 +0000 (14:58 +1700)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:44:20 +0000 (09:44 -0800)
fb/cf6628fcc9f92bd12d6b11d2d4923e4f49acc3 [new file with mode: 0644]

diff --git a/fb/cf6628fcc9f92bd12d6b11d2d4923e4f49acc3 b/fb/cf6628fcc9f92bd12d6b11d2d4923e4f49acc3
new file mode 100644 (file)
index 0000000..c5be1ca
--- /dev/null
@@ -0,0 +1,185 @@
+Return-Path: <scott@mostlylinux.ca>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id 145E4431FB6\r
+       for <notmuch@notmuchmail.org>; Fri, 10 Feb 2012 14:08:04 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]\r
+       autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id U+f9ZAp7hrVa for <notmuch@notmuchmail.org>;\r
+       Fri, 10 Feb 2012 14:08:03 -0800 (PST)\r
+X-Greylist: delayed 567 seconds by postgrey-1.32 at olra;\r
+       Fri, 10 Feb 2012 14:08:03 PST\r
+Received: from aguila.mostlylinux.ca (aguila.ca [184.71.238.186])\r
+       by olra.theworths.org (Postfix) with ESMTP id 5740B431FAE\r
+       for <notmuch@notmuchmail.org>; Fri, 10 Feb 2012 14:08:03 -0800 (PST)\r
+Received: from mostlylinux.ca (unknown [10.0.0.128])\r
+       by aguila.mostlylinux.ca (Postfix) with ESMTPSA id 551B318C8045\r
+       for <notmuch@notmuchmail.org>; Fri, 10 Feb 2012 14:58:35 -0700 (MST)\r
+Date: Fri, 10 Feb 2012 14:58:35 -0700\r
+From: Scott Barker <scott@mostlylinux.ca>\r
+To: notmuch@notmuchmail.org\r
+Subject: patches to mutt-notmuch\r
+Message-ID: <20120210215835.GA8464@aguila.ca>\r
+MIME-Version: 1.0\r
+Content-Type: multipart/mixed; boundary="82I3+IH0IqGh5yIs"\r
+Content-Disposition: inline\r
+User-Agent: Mutt/1.5.21 (2010-09-15)\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Fri, 10 Feb 2012 22:08:04 -0000\r
+\r
+\r
+--82I3+IH0IqGh5yIs\r
+Content-Type: text/plain; charset=us-ascii\r
+Content-Disposition: inline\r
+\r
+I have recently switched from using mutt + maildir-utils (mu) for searching\r
+my email to using mutt + notmuch. I made use of the mutt-notmuch perl script\r
+by Stefano Zacchiroli to integrate mutt and notmuch. You can find it at:\r
+http://upsilon.cc/~zack/blog/posts/2011/01/how_to_use_Notmuch_with_Mutt\r
+\r
+I have written a few patches (attached to this email) to extend the\r
+functionality of Stefano's script, as follows:\r
+\r
+  mutt-notmuch-readline.diffs\r
+    This patch makes mutt-notmuch use Term::ReadLine::GNU instead of reading\r
+    directly from STDIN.\r
+\r
+  mutt-notmuch-prompt-and-commandline-search-params.diffs\r
+    This patch uses the readline PREPUT functionality to pre-populate the\r
+    readline string with any search terms from the command line.\r
+\r
+  mutt-notmuch-mutt-folder-cleanup.diffs\r
+    This patch just removes the "=" from folder names as used in mutt, so\r
+    that the following can be made to work:\r
+\r
+      folder-hook . 'set my_oldrecord=$record; set record=^; set my_folder=$record; set record=$my_oldrecord; macro index <F7> "<enter-command>unset wait_key<enter><shell-escape>~/bin/mutt-notmuch --prompt search folder:$my_folder<enter><change-folder-readonly>~/.cache/mutt_results<enter>" "search $my_folder (using notmuch)"'\r
+\r
+Hopefully other people will find these patches of use as well.\r
+\r
+PS - any word on whether mutt-notmuch will be included with notmuch, as\r
+mentioned in Debian bug # 628018?\r
+(see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=628018)\r
+\r
+-- \r
+Scott Barker\r
+Linux Consultant\r
+scott@mostlylinux.ca\r
+http://www.mostlylinux.ca\r
+\r
+--82I3+IH0IqGh5yIs\r
+Content-Type: text/plain; charset=us-ascii\r
+Content-Disposition: attachment; filename="mutt-notmuch-readline.diffs"\r
+\r
+--- mutt-notmuch.old   2012-02-10 13:45:42.519241832 -0700\r
++++ mutt-notmuch       2012-02-10 14:21:06.835802055 -0700\r
+@@ -16,6 +16,7 @@\r
+ use Mail::Internet;\r
+ use Mail::Box::Maildir;\r
+ use Pod::Usage;\r
++use Term::ReadLine;\r
\r
\r
+ # create an empty maildir (if missing) or empty an existing maildir"\r
+@@ -41,12 +42,24 @@\r
+ sub prompt($) {\r
+     my ($text) = @_;\r
+     my $query = "";\r
++    my $term = Term::ReadLine->new( "mutt-notmuch" );\r
++    $term->ornaments( 0 );\r
++    $term->unbind_key( ord( "\t" ) );\r
++    $term->MinLine( 3 );\r
++    if ($ENV{MUTT_NOTMUCH_HISTFILE} && -r "$ENV{MUTT_NOTMUCH_HISTFILE}") {\r
++      $term->ReadHistory("$ENV{MUTT_NOTMUCH_HISTFILE}");\r
++    } elsif (-r "$ENV{HOME}/.mutt-notmuch.history") {\r
++      $term->ReadHistory("$ENV{HOME}/.mutt-notmuch.history");\r
++    }\r
+     while (1) {\r
+-      print $text;\r
+-      chomp($query = <STDIN>);\r
++      chomp($query = $term->readline($text));\r
+       if ($query eq "?") {\r
+           system("man notmuch");\r
+       } else {\r
++       if (!$ENV{MUTT_NOTMUCH_HISTFILE} ||\r
++           !$term->WriteHistory("$ENV{MUTT_NOTMUCH_HISTFILE}")) {\r
++         $term->WriteHistory("$ENV{HOME}/.mutt-notmuch.history");\r
++       }\r
+           return $query;\r
+       }\r
+     }\r
+\r
+--82I3+IH0IqGh5yIs\r
+Content-Type: text/plain; charset=us-ascii\r
+Content-Disposition: attachment;\r
+ filename="mutt-notmuch-prompt-and-commandline-search-params.diffs"\r
+\r
+--- mutt-notmuch       2012-02-10 14:21:06.835802055 -0700\r
++++ mutt-notmuch.new   2012-02-10 14:20:49.732441826 -0700\r
+@@ -39,8 +39,8 @@\r
+          . " | xargs --no-run-if-empty ln -s -t $maildir/cur/");\r
+ }\r
\r
+-sub prompt($) {\r
+-    my ($text) = @_;\r
++sub prompt($$) {\r
++    my ($text, $default) = @_;\r
+     my $query = "";\r
+     my $term = Term::ReadLine->new( "mutt-notmuch" );\r
+     $term->ornaments( 0 );\r
+@@ -52,7 +52,7 @@\r
+       $term->ReadHistory("$ENV{HOME}/.mutt-notmuch.history");\r
+     }\r
+     while (1) {\r
+-      chomp($query = $term->readline($text));\r
++      chomp($query = $term->readline($text, $default));\r
+       if ($query eq "?") {\r
+           system("man notmuch");\r
+       } else {\r
+@@ -77,7 +77,7 @@\r
+     if (! $interactive) {\r
+       search($results_dir, join(' ', @params));\r
+     } else {\r
+-      my $query = prompt("search ('?' for man): ");\r
++      my $query = prompt("search ('?' for man): ", join(' ', @params));\r
+       if ($query ne "") {\r
+           search($results_dir,$query);\r
+       }\r
+\r
+--82I3+IH0IqGh5yIs\r
+Content-Type: text/plain; charset=us-ascii\r
+Content-Disposition: attachment;\r
+ filename="mutt-notmuch-mutt-folder-cleanup.diffs"\r
+\r
+--- mutt-notmuch       2012-02-10 14:21:06.835802055 -0700\r
++++ mutt-notmuch.new   2012-02-10 14:20:49.732441826 -0700\r
+@@ -117,6 +117,10 @@\r
+     if (! $getopt || $#ARGV < 0) { die_usage() };\r
+     my ($action, @params) = ($ARGV[0], @ARGV[1..$#ARGV]);\r
\r
++    foreach my $param (@params) {\r
++      $param =~ s/folder:=/folder:/g;\r
++    }\r
++\r
+     if ($help_needed) {\r
+       die_usage();\r
+     } elsif ($action eq "search" && $#ARGV == 0 && ! $interactive) {\r
+\r
+--82I3+IH0IqGh5yIs--\r