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