From 6f73e9aa2031de33eb48a05807295fdb7c3bb566 Mon Sep 17 00:00:00 2001 From: Leo Vivier Date: Wed, 6 Feb 2019 16:44:59 +0100 Subject: [PATCH 1/4] emacs: Implement notmuch-search-refine MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Refine the current query string. --- Filtering was already implemented with notmuch-search-filter, but there wasn’t any way to refine the current query. --- emacs/notmuch.el | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/emacs/notmuch.el b/emacs/notmuch.el index 804e78ab..8bbed17d 100644 --- a/emacs/notmuch.el +++ b/emacs/notmuch.el @@ -1070,6 +1070,27 @@ current search results AND the additional query string provided." (concat grouped-original-query " and " grouped-query)) notmuch-search-oldest-first))) +(defvar notmuch-search-refine-replace-buffer nil + "Should ‘not-much-refine’ replace the current search?") + +(defun notmuch-search-refine (query &optional replace) + "Refine the current query string. + +When REPLACE is non-nil, do not create another buffer. See also +‘notmuch-search-refine-replace-buffer’." + (interactive (list (minibuffer-with-setup-hook + (lambda () + (next-history-element 1) + (end-of-line) + (insert " ")) + (notmuch-read-query "Refine search: ")))) + (let ((grouped-query (notmuch-group-disjunctive-query-string + query))) + (when (or replace + notmuch-search-refine-replace-buffer) + (notmuch-bury-or-kill-this-buffer)) + (notmuch-search grouped-query notmuch-search-oldest-first))) + (defun notmuch-search-filter-by-tag (tag) "Filter the current search results based on a single tag. -- 2.20.1