--- /dev/null
+Return-Path: <markwalters1009@gmail.com>\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 D54B6431FBD\r
+ for <notmuch@notmuchmail.org>; Wed, 16 Apr 2014 22:43:47 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0.201\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0.201 tagged_above=-999 required=5\r
+ tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
+ FREEMAIL_ENVFROM_END_DIGIT=1, FREEMAIL_FROM=0.001,\r
+ RCVD_IN_DNSWL_LOW=-0.7] 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 dUpC53z9soyC for <notmuch@notmuchmail.org>;\r
+ Wed, 16 Apr 2014 22:43:42 -0700 (PDT)\r
+Received: from mail-ee0-f53.google.com (mail-ee0-f53.google.com\r
+ [74.125.83.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client\r
+ certificate requested) by olra.theworths.org (Postfix) with ESMTPS id\r
+ EFB21431FAE for <notmuch@notmuchmail.org>; Wed, 16 Apr 2014 22:43:41 -0700\r
+ (PDT)\r
+Received: by mail-ee0-f53.google.com with SMTP id b57so181881eek.12\r
+ for <notmuch@notmuchmail.org>; Wed, 16 Apr 2014 22:43:39 -0700 (PDT)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
+ h=from:to:cc:subject:date:message-id;\r
+ bh=M/KzWWvPUNFru8WybAZAzsQknx9Hdretw7w6Qoihn/I=;\r
+ b=BFfvmYI+c7vIui8C9FeUles0euINikApww7RxpCywWBBbyMfdszozSgiZcx5uomf6r\r
+ KrKOI3tuAjgMQ/BfXzMSj64r2QMGISBQN14Si3rJKiFHCcjP3aSzdiR5ji/jGD2eBgTR\r
+ S+/AWlThvrtkExVKXepDlWxS69BX4lPqsUlMvuVIb739UeUfDtxhBYt96GkrzPnP3499\r
+ gDGTftg98W9BQ87csGADoXDGkR+ebLLJEtYMktucze4snDx+YUxIPU1JRPclvDvaamb3\r
+ YRlqUh1x7nEnFPXba1pd7nPv9ucyCz+03dtgY8b4tm/ePmptgqOatKEc7oS0VgVwWPJX\r
+ Ml5Q==\r
+X-Received: by 10.14.105.4 with SMTP id j4mr11204617eeg.41.1397713419529;\r
+ Wed, 16 Apr 2014 22:43:39 -0700 (PDT)\r
+Received: from localhost ([217.17.137.178]) by mx.google.com with ESMTPSA id\r
+ x45sm64077345eef.15.2014.04.16.22.43.38 for <multiple recipients>\r
+ (version=TLSv1.2 cipher=RC4-SHA bits=128/128);\r
+ Wed, 16 Apr 2014 22:43:38 -0700 (PDT)\r
+From: Mark Walters <markwalters1009@gmail.com>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH] emacs: search: edit current query\r
+Date: Thu, 17 Apr 2014 06:43:24 +0100\r
+Message-Id: <1397713404-3089-1-git-send-email-markwalters1009@gmail.com>\r
+X-Mailer: git-send-email 1.7.10.4\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: Thu, 17 Apr 2014 05:43:48 -0000\r
+\r
+This adds an option to edit the current query. It is bound to\r
+prefix-key f as it is a sort of inverse operation to filtering.\r
+---\r
+rlb asked for the option to modify the existing search query on\r
+irc. This implements that for the search view.\r
+\r
+Best wishes\r
+\r
+Mark \r
+\r
+\r
+\r
+\r
+\r
+ emacs/notmuch.el | 37 ++++++++++++++++++++++++++-----------\r
+ 1 file changed, 26 insertions(+), 11 deletions(-)\r
+\r
+diff --git a/emacs/notmuch.el b/emacs/notmuch.el\r
+index 6c0bc1b..b4408f1 100644\r
+--- a/emacs/notmuch.el\r
++++ b/emacs/notmuch.el\r
+@@ -848,7 +848,7 @@ See `notmuch-tag' for information on the format of TAG-CHANGES."\r
+ (concat "*notmuch-search-" query "*"))\r
+ )))\r
+ \r
+-(defun notmuch-read-query (prompt)\r
++(defun notmuch-read-query (prompt &optional initial-contents)\r
+ "Read a notmuch-query from the minibuffer with completion.\r
+ \r
+ PROMPT is the string to prompt with."\r
+@@ -876,7 +876,7 @@ PROMPT is the string to prompt with."\r
+ ;; this was simpler than convincing completing-read to accept spaces:\r
+ (define-key keymap (kbd "TAB") 'minibuffer-complete)\r
+ (let ((history-delete-duplicates t))\r
+- (read-from-minibuffer prompt nil keymap nil\r
++ (read-from-minibuffer prompt initial-contents keymap nil\r
+ 'notmuch-search-history nil nil)))))\r
+ \r
+ ;;;###autoload\r
+@@ -963,18 +963,33 @@ default sort order is defined by `notmuch-search-oldest-first'."\r
+ (set 'notmuch-search-oldest-first (not notmuch-search-oldest-first))\r
+ (notmuch-search-refresh-view))\r
+ \r
+-(defun notmuch-search-filter (query)\r
++(put 'notmuch-search-filter 'notmuch-doc\r
++ "Filter the current search results based on an additional query string.")\r
++(put 'notmuch-search-filter 'notmuch-prefix-doc\r
++ "Edit the current search query.")\r
++(defun notmuch-search-filter (modify query)\r
+ "Filter the current search results based on an additional query string.\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 (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
+- (notmuch-search (if (string= notmuch-search-query-string "*")\r
+- grouped-query\r
+- (concat notmuch-search-query-string " and " grouped-query)) notmuch-search-oldest-first)))\r
++current search results AND the additional query string provided.\r
++\r
++If called with a prefix-arg then present the user with the\r
++existing query string to allow the user to edit it."\r
++ (interactive (let ((query-string (if current-prefix-arg\r
++ "Modify Search: "\r
++ "Filter Search: "))\r
++ (initial-contents (if current-prefix-arg\r
++ notmuch-search-query-string\r
++ nil)))\r
++ (list current-prefix-arg (notmuch-read-query query-string initial-contents))))\r
++ (if modify\r
++ (notmuch-search query notmuch-search-oldest-first)\r
++ (let ((grouped-query (if (string-match-p notmuch-search-disjunctive-regexp query)\r
++ (concat "( " query " )")\r
++ query)))\r
++ (notmuch-search (if (string= notmuch-search-query-string "*")\r
++ grouped-query\r
++ (concat notmuch-search-query-string " and " grouped-query)) notmuch-search-oldest-first))))\r
+ \r
+ (defun notmuch-search-filter-by-tag (tag)\r
+ "Filter the current search results based on a single tag.\r
+-- \r
+1.7.10.4\r
+\r