--- /dev/null
+Return-Path: <jrollins@finestructure.net>\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 64077431FD0\r
+ for <notmuch@notmuchmail.org>; Fri, 5 Aug 2011 14:07:42 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -2.3\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-2.3 tagged_above=-999 required=5\r
+ tests=[RCVD_IN_DNSWL_MED=-2.3] 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 RJgM7-H679Rt for <notmuch@notmuchmail.org>;\r
+ Fri, 5 Aug 2011 14:07:41 -0700 (PDT)\r
+Received: from outgoing-mail.its.caltech.edu (outgoing-mail.its.caltech.edu\r
+ [131.215.239.19])\r
+ by olra.theworths.org (Postfix) with ESMTP id CAE47431FB6\r
+ for <notmuch@notmuchmail.org>; Fri, 5 Aug 2011 14:07:41 -0700 (PDT)\r
+Received: from earth-doxen.imss.caltech.edu (localhost [127.0.0.1])\r
+ by earth-doxen-postvirus (Postfix) with ESMTP id EFCF866E01F2\r
+ for <notmuch@notmuchmail.org>; Fri, 5 Aug 2011 14:03:29 -0700 (PDT)\r
+X-Spam-Scanned: at Caltech-IMSS on earth-doxen by amavisd-new\r
+Received: from finestructure.net (gwave-176.ligo.caltech.edu\r
+ [131.215.114.176]) (Authenticated sender: jrollins) by earth-doxen-submit\r
+ (Postfix) with ESMTP id 26FEE66E0177 for <notmuch@notmuchmail.org>; Fri, 5\r
+ Aug 2011 14:03:28 -0700 (PDT)\r
+Received: by finestructure.net (Postfix, from userid 1000)\r
+ id 08A162F5; Fri, 5 Aug 2011 14:03:28 -0700 (PDT)\r
+From: Jameson Graef Rollins <jrollins@finestructure.net>\r
+To: Notmuch Mail <notmuch@notmuchmail.org>\r
+Subject: [PATCH] emacs: Tab completion for notmuch-search and\r
+ notmuch-search-filter\r
+Date: Fri, 5 Aug 2011 14:03:28 -0700\r
+Message-Id: <1312578208-16170-1-git-send-email-jrollins@finestructure.net>\r
+X-Mailer: git-send-email 1.7.5.4\r
+In-Reply-To: <87liv7r2u3.fsf@servo.factory.finestructure.net>\r
+References: <87liv7r2u3.fsf@servo.factory.finestructure.net>\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, 05 Aug 2011 21:07:42 -0000\r
+\r
+From: Daniel Schoepe <daniel.schoepe@googlemail.com>\r
+\r
+This patch adds completion with <tab> in the minibuffer for\r
+notmuch-search and notmuch-search-filter.\r
+---\r
+This is a slightly tweaked version of this original patch that removes\r
+an errant space and uses "search --output=tags" instead of the\r
+deprecated "search-tags".\r
+\r
+ emacs/notmuch.el | 33 +++++++++++++++++++++++++++++++--\r
+ 1 files changed, 31 insertions(+), 2 deletions(-)\r
+\r
+diff --git a/emacs/notmuch.el b/emacs/notmuch.el\r
+index 6bf42e8..053f0be 100644\r
+--- a/emacs/notmuch.el\r
++++ b/emacs/notmuch.el\r
+@@ -877,6 +877,35 @@ characters as well as `_.+-'.\r
+ (concat "*notmuch-search-" query "*"))\r
+ )))\r
+ \r
++(defun notmuch-read-query (prompt)\r
++ "Read a notmuch-query from the minibuffer with completion.\r
++\r
++PROMPT is the string to prompt with."\r
++ (lexical-let\r
++ ((completions\r
++ (append (list "folder:" "thread:" "id:" "date:" "from:" "to:"\r
++ "subject:" "attachment:")\r
++ (mapcar (lambda (tag)\r
++ (concat "tag:" tag))\r
++ (process-lines "notmuch" "search" "--output=tags" "*")))))\r
++ (let ((keymap (copy-keymap minibuffer-local-map))\r
++ (minibuffer-completion-table\r
++ (completion-table-dynamic\r
++ (lambda (string)\r
++ ;; generate a list of possible completions for the current input\r
++ (cond\r
++ ;; this ugly regexp is used to get the last word of the input\r
++ ;; possibly preceded by a '('\r
++ ((string-match "\\(^\\|.* (?\\)\\([^ ]*\\)$" string)\r
++ (mapcar (lambda (compl)\r
++ (concat (match-string-no-properties 1 string) compl))\r
++ (all-completions (match-string-no-properties 2 string)\r
++ completions)))\r
++ (t (list string)))))))\r
++ ;; this was simpler than convincing completing-read to accept spaces:\r
++ (define-key keymap (kbd "<tab>") 'minibuffer-complete)\r
++ (read-from-minibuffer prompt nil keymap nil minibuffer-history nil nil))))\r
++\r
+ ;;;###autoload\r
+ (defun notmuch-search (query &optional oldest-first target-thread target-line continuation)\r
+ "Run \"notmuch search\" with the given query string and display results.\r
+@@ -888,7 +917,7 @@ The optional parameters are used as follows:\r
+ current if it appears in the search results.\r
+ target-line: The line number to move to if the target thread does not\r
+ appear in the search results."\r
+- (interactive "sNotmuch search: ")\r
++ (interactive (list (notmuch-read-query "Notmuch search: ")))\r
+ (let ((buffer (get-buffer-create (notmuch-search-buffer-title query))))\r
+ (switch-to-buffer buffer)\r
+ (notmuch-search-mode)\r
+@@ -986,7 +1015,7 @@ search."\r
+ \r
+ Runs a new search matching only messages that match both the\r
+ current search results AND the additional query string provided."\r
+- (interactive "sFilter search: ")\r
++ (interactive (list (notmuch-read-query "Filter search: ")))\r
+ (let ((grouped-query (if (string-match-p notmuch-search-disjunctive-regexp query)\r
+ (concat "( " query " )")\r
+ query)))\r
+-- \r
+1.7.5.4\r
+\r