unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH v4 1/2] emacs: new command notmuch-tree-filter
@ 2021-08-22  0:50 jao
  2021-08-22  0:50 ` [PATCH v4 2/2] emacs: new command notmuch-tree-filter-by-tag jao
  2021-08-22  3:23 ` [PATCH v4 1/2] emacs: new command notmuch-tree-filter David Bremner
  0 siblings, 2 replies; 3+ messages in thread
From: jao @ 2021-08-22  0:50 UTC (permalink / raw)
  To: notmuch; +Cc: jao

This command is analogous to notmuch-filter, but is defined on tree
mode buffers.
---
 devel/emacs-keybindings.org |  2 +-
 doc/notmuch-emacs.rst       |  3 +++
 emacs/notmuch-tree.el       | 16 ++++++++++++++++
 3 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/devel/emacs-keybindings.org b/devel/emacs-keybindings.org
index f7df3040..0ff4fdf5 100644
--- a/devel/emacs-keybindings.org
+++ b/devel/emacs-keybindings.org
@@ -12,7 +12,7 @@
 | i         |                                        |                                                       |                                         |
 | j         | notmuch-jump-search                    | notmuch-jump-search                                   | notmuch-jump-search                     |
 | k         | notmuch-tag-jump                       | notmuch-tag-jump                                      | notmuch-tag-jump                        |
-| l         | notmuch-search-filter                  | notmuch-show-filter-thread                            |                                         |
+| l         | notmuch-search-filter                  | notmuch-show-filter-thread                            | notmuch-tree-filter                     |
 | m         | notmuch-mua-new-mail                   | notmuch-mua-new-mail                                  | notmuch-mua-new-mail                    |
 | n         | notmuch-search-next-thread             | notmuch-show-next-open-message                        | notmuch-tree-next-matching-message      |
 | o         | notmuch-search-toggle-order            |                                                       | notmuch-tree-toggle-order               |
diff --git a/doc/notmuch-emacs.rst b/doc/notmuch-emacs.rst
index 952fe2a5..5accfa60 100644
--- a/doc/notmuch-emacs.rst
+++ b/doc/notmuch-emacs.rst
@@ -302,6 +302,9 @@ tags.
 ``o`` ``notmuch-tree-toggle-order``
    |docstring::notmuch-tree-toggle-order|
 
+``l`` ``notmuch-tree-filter``
+   Filter or LIMIT the current search results based on an additional query string
+
 ``g`` ``=``
     Refresh the buffer
 
diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el
index ef1ca4c5..f2938330 100644
--- a/emacs/notmuch-tree.el
+++ b/emacs/notmuch-tree.el
@@ -349,6 +349,7 @@ then NAME behaves like CMD."
     (define-key map "r" 'notmuch-tree-reply-sender)
     (define-key map "R" 'notmuch-tree-reply)
     (define-key map "V" 'notmuch-tree-view-raw-message)
+    (define-key map "l" 'notmuch-tree-filter)
 
     ;; The main tree view bindings
     (define-key map (kbd "RET") 'notmuch-tree-show-message)
@@ -1168,6 +1169,21 @@ The arguments are:
   (interactive)
   (notmuch-tree query query-context target buffer-name open-target t))
 
+(defun notmuch-tree-filter (query)
+  "Filter or LIMIT the current search results based on an additional query string.
+
+Runs a new tree search matching only messages that match both the
+current search results AND the additional query string provided."
+  (interactive (list (notmuch-read-query "Filter search: ")))
+  (let ((notmuch-show-process-crypto (notmuch-tree--message-process-crypto))
+	(grouped-query (notmuch-group-disjunctive-query-string query))
+	(grouped-original-query (notmuch-group-disjunctive-query-string
+				 (notmuch-tree-get-query))))
+    (notmuch-tree-close-message-window)
+    (notmuch-tree (if (string= grouped-original-query "*")
+		      grouped-query
+		    (concat grouped-original-query " and " grouped-query)))))
+
 ;;; _
 
 (provide 'notmuch-tree)
-- 
2.33.0

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH v4 2/2] emacs: new command notmuch-tree-filter-by-tag
  2021-08-22  0:50 [PATCH v4 1/2] emacs: new command notmuch-tree-filter jao
@ 2021-08-22  0:50 ` jao
  2021-08-22  3:23 ` [PATCH v4 1/2] emacs: new command notmuch-tree-filter David Bremner
  1 sibling, 0 replies; 3+ messages in thread
From: jao @ 2021-08-22  0:50 UTC (permalink / raw)
  To: notmuch; +Cc: jao

This new command for notmuch-tree-mode is analogous to
notmuch-search-filter-by-tag, bound to "t" in notmuch-search-mode; it
gets therefore the same "t" keybinding in notmuch-tree-mode (replacing
the current assignment to notmuch-search-by-tag).
---
 devel/emacs-keybindings.org |  2 +-
 doc/notmuch-emacs.rst       |  4 ++++
 emacs/notmuch-tree.el       | 28 ++++++++++++++++++++++++----
 3 files changed, 29 insertions(+), 5 deletions(-)

diff --git a/devel/emacs-keybindings.org b/devel/emacs-keybindings.org
index 0ff4fdf5..2f73a198 100644
--- a/devel/emacs-keybindings.org
+++ b/devel/emacs-keybindings.org
@@ -20,7 +20,7 @@
 | q         | notmuch-bury-or-kill-this-buffer       | notmuch-bury-or-kill-this-buffer                      | notmuch-bury-or-kill-this-buffer        |
 | r         | notmuch-search-reply-to-thread-sender  | notmuch-show-reply-sender                             | notmuch-show-reply-sender               |
 | s         | notmuch-search                         | notmuch-search                                        | notmuch-search                          |
-| t         | notmuch-search-filter-by-tag           | toggle-truncate-lines                                 | notmuch-search-by-tag                   |
+| t         | notmuch-search-filter-by-tag           | toggle-truncate-lines                                 | notmuch-tree-filter-by-tag              |
 | u         |                                        |                                                       |                                         |
 | v         |                                        |                                                       | notmuch-show-view-all-mime-parts        |
 | w         |                                        | notmuch-show-save-attachments                         | notmuch-show-save-attachments           |
diff --git a/doc/notmuch-emacs.rst b/doc/notmuch-emacs.rst
index 5accfa60..36dcb116 100644
--- a/doc/notmuch-emacs.rst
+++ b/doc/notmuch-emacs.rst
@@ -305,6 +305,10 @@ tags.
 ``l`` ``notmuch-tree-filter``
    Filter or LIMIT the current search results based on an additional query string
 
+``t`` ``notmuch-tree-filter-by-tag``
+   Filter the current search results based on an additional tag
+
+
 ``g`` ``=``
     Refresh the buffer
 
diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el
index f2938330..01a77b71 100644
--- a/emacs/notmuch-tree.el
+++ b/emacs/notmuch-tree.el
@@ -321,10 +321,10 @@ then NAME behaves like CMD."
     ;; These bindings shadow common bindings with variants
     ;; that additionally close the message window.
     (define-key map [remap notmuch-bury-or-kill-this-buffer] 'notmuch-tree-quit)
-    (define-key map [remap notmuch-search]       'notmuch-tree-to-search)
-    (define-key map [remap notmuch-help]         'notmuch-tree-help)
-    (define-key map [remap notmuch-mua-new-mail] 'notmuch-tree-new-mail)
-    (define-key map [remap notmuch-jump-search]  'notmuch-tree-jump-search)
+    (define-key map [remap notmuch-search]        'notmuch-tree-to-search)
+    (define-key map [remap notmuch-help]          'notmuch-tree-help)
+    (define-key map [remap notmuch-mua-new-mail]  'notmuch-tree-new-mail)
+    (define-key map [remap notmuch-jump-search]   'notmuch-tree-jump-search)
 
     (define-key map "o" 'notmuch-tree-toggle-order)
     (define-key map "S" 'notmuch-search-from-tree-current-query)
@@ -350,6 +350,7 @@ then NAME behaves like CMD."
     (define-key map "R" 'notmuch-tree-reply)
     (define-key map "V" 'notmuch-tree-view-raw-message)
     (define-key map "l" 'notmuch-tree-filter)
+    (define-key map "t" 'notmuch-tree-filter-by-tag)
 
     ;; The main tree view bindings
     (define-key map (kbd "RET") 'notmuch-tree-show-message)
@@ -1184,6 +1185,25 @@ current search results AND the additional query string provided."
 		      grouped-query
 		    (concat grouped-original-query " and " grouped-query)))))
 
+(defun notmuch-tree-filter-by-tag (tag)
+  "Filter the current search results based on a single TAG.
+
+Run a new search matching only messages that match the current
+search results and that are also tagged with the given TAG."
+  (interactive
+   (list (notmuch-select-tag-with-completion "Filter by tag: "
+					     notmuch-tree-basic-query)))
+  (let ((notmuch-show-process-crypto (notmuch-tree--message-process-crypto)))
+    (notmuch-tree-close-message-window)
+    (notmuch-tree (concat notmuch-tree-basic-query " and tag:" tag)
+		  notmuch-tree-query-context
+		  nil
+		  nil
+		  nil
+		  notmuch-tree-unthreaded
+		  nil
+		  notmuch-search-oldest-first)))
+
 ;;; _
 
 (provide 'notmuch-tree)
-- 
2.33.0

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v4 1/2] emacs: new command notmuch-tree-filter
  2021-08-22  0:50 [PATCH v4 1/2] emacs: new command notmuch-tree-filter jao
  2021-08-22  0:50 ` [PATCH v4 2/2] emacs: new command notmuch-tree-filter-by-tag jao
@ 2021-08-22  3:23 ` David Bremner
  1 sibling, 0 replies; 3+ messages in thread
From: David Bremner @ 2021-08-22  3:23 UTC (permalink / raw)
  To: jao, notmuch; +Cc: jao

jao <jao@gnu.org> writes:

> This command is analogous to notmuch-filter, but is defined on tree
> mode buffers.

series applied to master.

d

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-08-22  3:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-22  0:50 [PATCH v4 1/2] emacs: new command notmuch-tree-filter jao
2021-08-22  0:50 ` [PATCH v4 2/2] emacs: new command notmuch-tree-filter-by-tag jao
2021-08-22  3:23 ` [PATCH v4 1/2] emacs: new command notmuch-tree-filter David Bremner

Code repositories for project(s) associated with this inbox:

	notmuch.git.git (no URL configured)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).