Re: [PATCH v2 2/3] emacs: Allow notmuch-saved-searches to hide excluded messages
David Bremner writes: Hi, sorry, took me so long to get back to this XD. I've opted to squash the 3 separate commits in this patch series into one commit so that should address the commit message questions. > mohk...@kisara.moe writes: > >> + :excludedWhether to show mail with excluded tags in the >> + search. Possible values are `hide', `show', >> + or nil. Nil means use the default value of >> + `notmuch-search-hide-excluded'. > > So if I understand correctly, toggling excludes will not affect saved > searches with a :excluded key. Is this what we want? > > I guess the alternative is to AND notmuch-search-hide-excluded with the > value derived from the saved-search? I think this is the last pending question. This shouldn't be the case. When you open a search from notmuch saved searches it'll contain whatever value you specify in :excluded but you can interactively change that with the new toggle-exclude commands and the workflow should be as you expect. I did notice while testing this that notmuch-jump currently doesn't respect the exclude option you add to saved searches but I've addressed that in this next patch version. -- Mohsin Kaleem ___ notmuch mailing list -- notmuch@notmuchmail.org To unsubscribe send an email to notmuch-le...@notmuchmail.org
Re: [PATCH v2 1/3] emacs: Add new option notmuch-search-hide-excluded
David Bremner writes: >> diff --git a/test/T310-emacs.sh b/test/T310-emacs.sh >> index 9d0df187..b89a100e 100755 >> --- a/test/T310-emacs.sh >> +++ b/test/T310-emacs.sh >> @@ -1030,7 +1030,7 @@ End of search results. >> YYY/notmuch_fail exited with status 1 (see *Notmuch errors* for more >> details) >> === ERROR === >> YYY/notmuch_fail exited with status 1 >> -command: YYY/notmuch_fail search --format\=sexp --format-version\=5 >> --sort\=newest-first tag\:inbox >> +command: YYY/notmuch_fail search --format\=sexp --format-version\=5 >> --sort\=newest-first --exclude\=false tag\:inbox >> exit status: 1" >> > > I don't understand why --exclude is defaulting to 'false' here. Isn't > this a change in behaviour? You're correct. This is because the new options notmuch-search-hide-excluded and it defaults to t, but when we call (notmuch-search) the value used is nil because we didn't supply one for the search call. If you call notmuch-search interactively then this isn't an issue, the interactive spec will substitute the value of the hide-excluded option. This is why all the tests that use the hello buffer to select the inbox and open a search in it correctly use the notmuch-search-hide-excluded option. This test does not do this. We could workaround this by changing the semantics of the variable. Make it notmuch-search-show-excluded and default to nil so nothing has to be changed in existing functions that call notmuch-search. Or we could switch to using cl-defun and have the default value substituted in the parameter list. I've never used cl-defun with interactive functions but long term I think that's the saner solution. -- Mohsin Kaleem ___ notmuch mailing list -- notmuch@notmuchmail.org To unsubscribe send an email to notmuch-le...@notmuchmail.org
Re: [PATCH 6/9] test: Add test cases for new exclude option
Tomi Ollila writes: > It looks like tab width was not 8 when these (notmuch-search-toggle-exclude) > were added, accidentally indented w/ leading space, not tab ;/ > > (ditto for all other (notmuch-search-toggle-exclude), rest of the content > removed.) Ah, good job spotting this. My tab width defaults to 2 in sh-script files. I've fixed this now, but now sure what to do next. Should I generate a new patch series and send them all again, generate a new patch series and just send the modified patch, or is there some other convention for next steps? > Otherwise, in this large set of changes, I could not see anything alarming, > but I did not test (I even don't know how, as I don't have excludes...) An easy way to test would be to set some excluded tags :-). notmuch config set search.exclude_tags foo Then: 1. Go to your inbox in Emacs. 2. Tag some mail with foo. 3. Run `M-x notmuch-refresh-this-buffer` and the mail you tagged should no longer be shown. 4. Hit the i key and it will be shown again. 5. Hit i again and it will be hidden. 6. Hit i again to re-show it and go ahead and remove the foo tag 7. Run `M-x notmuch-refresh-this-buffer` or hit i as much as you like, the mail should now always be shown since its no longer excluded. -- Mohsin Kaleem ___ notmuch mailing list -- notmuch@notmuchmail.org To unsubscribe send an email to notmuch-le...@notmuchmail.org
Re: [PATCH] emacs: add new option notmuch-search-exclude
David Bremner writes: Hi, thanks for all the advice :-). I'm still quite unfamiliar with mailing-list based workflows so I keep developing like I'm on GitHub. > I think the patch series needs a bit of cleanup still. The first two > patches occur twice and then a later patch is reverted (so presumably > those two can be dropped as well). > > You may also want to rebase against master before resending, since I > have just a applied some changes to the emacs UI code that might collide > with yours. I'm not sure what you mean by the first two patches occur twice, could you clarify so I can fix the issue? I've dropped the reverted patch and rebased on top of master so you shouldn't have any issues applying the patch series now. > If possible, please use git send-email to send one-patch-per-message, it > makes reviewing in notmuch-emacs much easier for me. I just used git send-email to send the patch series (I assume it'll be sent separately). I'd like to ask: + How do you manage git and email workflows like this for reference? I haven't found any documentation about it when searching. + Is there a way to do this with notmuch involved (ideally through emacs and Magit)? -- Mohsin Kaleem ___ notmuch mailing list -- notmuch@notmuchmail.org To unsubscribe send an email to notmuch-le...@notmuchmail.org
[PATCH 9/9] build: Fix declare-function calls for updated functions
--- emacs/notmuch-hello.el | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el index 39ba2537..6d4197dd 100644 --- a/emacs/notmuch-hello.el +++ b/emacs/notmuch-hello.el @@ -33,10 +33,11 @@ (declare-function notmuch-poll "notmuch-lib" ()) (declare-function notmuch-tree "notmuch-tree" (&optional query query-context target buffer-name -open-target unthreaded parent-buffer oldest-first)) +open-target unthreaded parent-buffer +oldest-first hide-excluded)) (declare-function notmuch-unthreaded "notmuch-tree" (&optional query query-context target buffer-name -open-target)) +open-target oldest-first hide-excluded)) ;;; Options -- 2.37.1 ___ notmuch mailing list -- notmuch@notmuchmail.org To unsubscribe send an email to notmuch-le...@notmuchmail.org
[PATCH 8/9] review: Rename variables to better express intention
--- emacs/notmuch-hello.el | 18 +- emacs/notmuch-jump.el | 2 +- emacs/notmuch-lib.el | 4 ++-- emacs/notmuch-tree.el | 24 emacs/notmuch.el | 29 +++-- 5 files changed, 39 insertions(+), 38 deletions(-) diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el index 810f094e..39ba2537 100644 --- a/emacs/notmuch-hello.el +++ b/emacs/notmuch-hello.el @@ -143,10 +143,10 @@ a plist. Supported properties are :sort-order Specify the sort order to be used for the search. Possible values are `oldest-first', `newest-first' or nil. Nil means use the default sort order. - :excludedWhether to include mail with excluded tags in the - search. Possible values are `include', `exclude', + :excludedWhether to show mail with excluded tags in the + search. Possible values are `hide', `show', or nil. Nil means use the default value of - `notmuch-search-exclude'. + `notmuch-search-hide-excluded'. :search-type Specify whether to run the search in search-mode, tree mode or unthreaded mode. Set to `tree' to specify tree mode, 'unthreaded to specify @@ -490,7 +490,7 @@ diagonal." (defun notmuch-hello-widget-search (widget &rest _ignore) (let ((search-terms (widget-get widget :notmuch-search-terms)) (oldest-first (widget-get widget :notmuch-search-oldest-first)) - (exclude (widget-get widget :notmuch-search-exclude))) + (exclude (widget-get widget :notmuch-search-hide-excluded))) (cl-case (widget-get widget :notmuch-search-type) (tree (let ((n (notmuch-search-format-buffer-name (widget-value widget) "tree" t))) @@ -498,7 +498,7 @@ diagonal." (unthreaded (let ((n (notmuch-search-format-buffer-name (widget-value widget) "unthreaded" t))) -(notmuch-unthreaded search-terms nil nil n nil oldest-first search-exclude))) +(notmuch-unthreaded search-terms nil nil n nil oldest-first exclude))) (t (notmuch-search search-terms oldest-first exclude) @@ -648,9 +648,9 @@ with `notmuch-hello-query-counts'." (oldest-first t) (otherwise notmuch-search-oldest-first))) (exclude (cl-case (plist-get elem :excluded) - (exclude t) - (include nil) - (otherwise notmuch-search-exclude))) + (hide t) + (show nil) + (otherwise notmuch-search-hide-excluded))) (search-type (plist-get elem :search-type)) (msg-count (plist-get elem :count))) (widget-insert (format "%8s " @@ -660,7 +660,7 @@ with `notmuch-hello-query-counts'." :notmuch-search-terms query :notmuch-search-oldest-first oldest-first :notmuch-search-type search-type - :notmuch-search-exclude exclude + :notmuch-search-hide-excluded exclude name) (setq column-indent (1+ (max 0 (- column-width (length name))) diff --git a/emacs/notmuch-jump.el b/emacs/notmuch-jump.el index e98c9c1d..53496e5c 100644 --- a/emacs/notmuch-jump.el +++ b/emacs/notmuch-jump.el @@ -51,7 +51,7 @@ fast way to jump to a saved search from anywhere in Notmuch." (newest-first nil) (oldest-first t) (otherwise (default-value 'notmuch-search-oldest-first - (exclude (default-value 'notmuch-search-exclude))) + (exclude (default-value 'notmuch-search-hide-excluded))) (push (list key name (cond ((eq (plist-get saved-search :search-type) 'tree) diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el index 96795054..d0205d0e 100644 --- a/emacs/notmuch-lib.el +++ b/emacs/notmuch-lib.el @@ -105,7 +105,7 @@ search." :group 'notmuch-search) (make-variable-buffer-local 'notmuch-search-oldest-first) -(defcustom notmuch-search-exclude t +(defcustom notmuch-search-hide-excluded t "Hide mail tagged with a excluded tag. Excluded tags are defined in the users configuration file under @@ -113,7 +113,7 @@ the search section. When this variable is true, any mail with such a tag will not be shown in the search output." :type 'boolean :group 'notmuch-search) -(make-variable-buffer-local 'notmuch-search-exclude) +(make-variable-buffer-local 'notmuch-search-hide-excluded) (defcustom notmuch-poll-script nil "[Depreca
[PATCH 7/9] test: Fix Navigation of notmuch-hello to search results
The default value of oldest-first is true so the oldest mail is shown first by default. This test case used the tree-from-search function which now persists this value of true (previously always defaulting to nil in its place) which produced a different tree output where the oldest-mail is sorted first despite previously being sorted last. Fixed by adding in this output as a separate file and comparing against it instead. --- test/T460-emacs-tree.sh | 2 +- .../notmuch-tree-tag-inbox-oldest-first | 53 +++ 2 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 test/emacs-tree.expected-output/notmuch-tree-tag-inbox-oldest-first diff --git a/test/T460-emacs-tree.sh b/test/T460-emacs-tree.sh index 3a1c449e..b540c555 100755 --- a/test/T460-emacs-tree.sh +++ b/test/T460-emacs-tree.sh @@ -100,7 +100,7 @@ test_emacs '(notmuch-hello) (notmuch-test-wait) (test-output) (delete-other-windows)' -test_expect_equal_file $EXPECTED/notmuch-tree-tag-inbox OUTPUT +test_expect_equal_file $EXPECTED/notmuch-tree-tag-inbox-oldest-first OUTPUT test_begin_subtest "Tree view of a single thread (from search)" test_emacs '(notmuch-hello) diff --git a/test/emacs-tree.expected-output/notmuch-tree-tag-inbox-oldest-first b/test/emacs-tree.expected-output/notmuch-tree-tag-inbox-oldest-first new file mode 100644 index ..588fc583 --- /dev/null +++ b/test/emacs-tree.expected-output/notmuch-tree-tag-inbox-oldest-first @@ -0,0 +1,53 @@ + 2009-11-17 Mikhail Gusarov ┬►[notmuch] [PATCH 1/2] Close message file after parsing message headers (inbox unread) + 2009-11-17 Mikhail Gusarov ├─►[notmuch] [PATCH 2/2] Include to get uint32_t in C++ file with gcc 4.4 (inbox unread) + 2009-11-17 Carl Worth╰┬►[notmuch] [PATCH 1/2] Close message file after parsing message headers (inbox unread) + 2009-11-17 Keith Packard ╰┬► ... (inbox unread) + 2009-11-18 Carl Worth ╰─► ... (inbox unread) + 2009-11-17 Lars Kellogg-Stedman ┬►[notmuch] Working with Maildir storage? (inbox signed unread) + 2009-11-17 Mikhail Gusarov ├┬► ... (inbox signed unread) + 2009-11-17 Lars Kellogg-Stedman │╰┬► ... (inbox signed unread) + 2009-11-17 Mikhail Gusarov │ ├─► ... (inbox unread) + 2009-11-17 Keith Packard │ ╰┬► ... (inbox unread) + 2009-11-18 Lars Kellogg-Stedman │ ╰─► ... (inbox signed unread) + 2009-11-18 Carl Worth╰─► ... (inbox unread) + 2009-11-17 Alex Botero-Lowry ┬►[notmuch] preliminary FreeBSD support (attachment inbox unread) + 2009-11-17 Carl Worth╰─► ... (inbox unread) + 2009-11-17 Mikhail Gusarov ─►[notmuch] [PATCH] Handle rename of message file (inbox unread) + 2009-11-17 Keith Packard ┬►[notmuch] [PATCH] Make notmuch-show 'X' (and 'x') commands removeinbox (and unread) tags (inbox unread) + 2009-11-18 Carl Worth╰─►[notmuch] [PATCH] Make notmuch-show 'X' (and 'x') commands remove inbox (and unread) tags (inbox unread) + 2009-11-17 Jan Janak ┬►[notmuch] [PATCH] Older versions of install do not support -C. (inbox unread) + 2009-11-18 Carl Worth╰─► ... (inbox unread) + 2009-11-17 Jan Janak ┬►[notmuch] What a great idea! (inbox unread) + 2009-11-17 Jan Janak ├─► ... (inbox unread) + 2009-11-18 Carl Worth╰─► ... (inbox unread) + 2009-11-17 Israel Herraiz┬►[notmuch] New to the list (inbox unread) + 2009-11-18 Keith Packard ├─► ... (inbox unread) + 2009-11-18 Carl Worth╰─► ... (inbox unread) + 2009-11-17 Adrian Perez de Cast ┬►[notmuch] Introducing myself (inbox signed unread) + 2009-11-18 Keith Packard ├─► ... (inbox unread) + 2009-11-18 Carl Worth╰─► ... (inbox unread) + 2009-11-17 Aron Griffis ┬►[notmuch] archive (inbox unread) + 2009-11-18 Keith Packard ╰┬► ... (inbox unread) + 2009-11-18 Carl Worth ╰─► ...
[PATCH 6/9] test: Add test cases for new exclude option
--- test/T461-emacs-search-exclude.sh | 99 +++ .../notmuch-search-tag-inbox-with-excluded| 25 + .../notmuch-search-tag-inbox-without-excluded | 21 .../notmuch-tree-tag-inbox-with-excluded | 53 ++ .../notmuch-tree-tag-inbox-without-excluded | 49 + 5 files changed, 247 insertions(+) create mode 100755 test/T461-emacs-search-exclude.sh create mode 100644 test/emacs-exclude.expected-output/notmuch-search-tag-inbox-with-excluded create mode 100644 test/emacs-exclude.expected-output/notmuch-search-tag-inbox-without-excluded create mode 100644 test/emacs-exclude.expected-output/notmuch-tree-tag-inbox-with-excluded create mode 100644 test/emacs-exclude.expected-output/notmuch-tree-tag-inbox-without-excluded diff --git a/test/T461-emacs-search-exclude.sh b/test/T461-emacs-search-exclude.sh new file mode 100755 index ..bf558847 --- /dev/null +++ b/test/T461-emacs-search-exclude.sh @@ -0,0 +1,99 @@ +#!/usr/bin/env bash + +test_description="exclude options persist between Emacs search and tree modes" +. $(dirname "$0")/test-lib.sh || exit 1 +. $NOTMUCH_SRCDIR/test/test-lib-emacs.sh || exit 1 + +EXPECTED=$NOTMUCH_SRCDIR/test/emacs-exclude.expected-output + +test_require_emacs +add_email_corpus +notmuch config set search.exclude_tags deleted +notmuch tag +deleted -- 'from:"Stewart Smith"' or 'from:"Chris Wilson"' + +# Basic test cases just asserting exclude option is working and consistent. + +test_begin_subtest "Search doesn't contain excluded mail by default" +test_emacs '(notmuch-hello) + (goto-char (point-min)) + (re-search-forward "inbox") + (widget-button-press (1- (point))) + (notmuch-test-wait) + (test-output) + (delete-other-windows)' +test_expect_equal_file $EXPECTED/notmuch-search-tag-inbox-without-excluded OUTPUT + +test_begin_subtest "Toggling exclude in search will show excluded mail" +test_emacs '(notmuch-hello) + (goto-char (point-min)) + (re-search-forward "inbox") + (widget-button-press (1- (point))) + (notmuch-test-wait) + (notmuch-search-toggle-exclude) + (notmuch-test-wait) + (test-output) + (delete-other-windows)' +test_expect_equal_file $EXPECTED/notmuch-search-tag-inbox-with-excluded OUTPUT + +test_begin_subtest "Tree search doesn't contain excluded mail by default" +test_emacs '(notmuch-hello) + (goto-char (point-min)) + (re-search-forward "inbox") + (widget-button-press (1- (point))) + (notmuch-test-wait) + (notmuch-tree-from-search-current-query) + (notmuch-test-wait) + (test-output) + (delete-other-windows)' +test_expect_equal_file $EXPECTED/notmuch-tree-tag-inbox-without-excluded OUTPUT + +test_begin_subtest "Toggling exclude in tree search will show excluded mail" +test_emacs '(notmuch-hello) + (goto-char (point-min)) + (re-search-forward "inbox") + (widget-button-press (1- (point))) + (notmuch-test-wait) + (notmuch-tree-from-search-current-query) + (notmuch-test-wait) + (notmuch-tree-toggle-exclude) + (notmuch-test-wait) + (test-output) + (delete-other-windows)' +test_expect_equal_file $EXPECTED/notmuch-tree-tag-inbox-with-excluded OUTPUT + +# Choice of showing excluded mail persists when switching between tree and search +# buffers. + +test_begin_subtest "Value of exclude from search persists into tree search" +test_emacs '(notmuch-hello) + (goto-char (point-min)) + (re-search-forward "inbox") + (widget-button-press (1- (point))) + (notmuch-test-wait) + (notmuch-search-toggle-exclude) + (notmuch-test-wait) + (notmuch-tree-from-search-current-query) + (notmuch-test-wait) + (test-output) + (delete-other-windows)' +test_expect_equal_file $EXPECTED/notmuch-tree-tag-inbox-with-excluded OUTPUT + +test_begin_subtest "Value of exclude from tree persists into search search" +test_emacs '(notmuch-hello) + (goto-char (point-min)) + (re-search-forward "inbox") + (widget-button-press (1- (point))) + (notmuch-test-wait) + (notmuch-tree-from-search-current-query) + (notmuch-test-wait) + (notmuch-tree-toggle-exclude) + (notmuch-test-wait) + (notmuch-search-from-tree-current-query) + (notmuch-test-wait) + (test-output) + (delete-other-windows)' +test_expect_equal_file $EXPECTED/notmuch-search-tag-inbox-with-excluded OUTPUT + +# TODO: Add test cases for unthreaded conversions as well. + +test_done diff --git a/test/emacs-exclude.expected-output/notmuch-search-tag-inbox-with-excluded b/test/emacs-exclude.expected-output/notmuch-search-tag-inbox-with-excluded new file mode 100644 index ..ce1d7118 --
[PATCH 5/9] feat: Add more interactive specs
--- emacs/notmuch-tree.el | 20 ++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el index 9ed8a3d9..5f999424 100644 --- a/emacs/notmuch-tree.el +++ b/emacs/notmuch-tree.el @@ -1215,7 +1215,15 @@ The arguments are: it is nil \"*notmuch-tree\" followed by QUERY is used. OPEN-TARGET: If TRUE open the target message in the message pane. UNTHREADED: If TRUE only show matching messages in an unthreaded view." - (interactive) + (interactive + (list +;; Prompt for a query +nil +;; Fill other args with nil. +nil nil nil nil nil nil +;; Populate these from the default value of these options. +(default-value 'notmuch-search-oldest-first) +(default-value 'notmuch-search-exclude))) (unless query (setq query (notmuch-read-query (concat "Notmuch " (if unthreaded "unthreaded " "tree ") @@ -1239,7 +1247,15 @@ The arguments are: "Display threads matching QUERY in unthreaded view. See function NOTMUCH-TREE for documentation of the arguments" - (interactive) + (interactive + (list +;; Prompt for a query +nil +;; Fill other args with nil. +nil nil nil nil +;; Populate these from the default value of these options. +(default-value 'notmuch-search-oldest-first) +(default-value 'notmuch-search-exclude))) (notmuch-tree query query-context target buffer-name open-target t nil oldest-first exclude)) -- 2.37.1 ___ notmuch mailing list -- notmuch@notmuchmail.org To unsubscribe send an email to notmuch-le...@notmuchmail.org
[PATCH 1/9] emacs: add new option notmuch-search-exclude
The new notmuch-search-exclude option allows users to configure whether to show or hide excluded messages (as determined by search.exclude_tags in the local config file). It defaults to true for now to maintain backwards-compatibility with how notmuch-{search,tree} already worked. New commands notmuch-search-toggle-exclude and notmuch-tree-toggle-exclude have also been added that toggle the value of notmuch-search-exclude for the search in the current search or tree buffer. It's bound to "i" in the respective keymaps for these modes. Lastly I've amended some calls to notmuch-tree and notmuch-unthreaded which didn't pass through the buffer local value of notmuch-search-oldest-first (and now notmuch-search-exclude). Examples of where I've done this + include notmuch-jump-search + notmuch-tree-from-search-current-query + notmuch-unthreaded-from-search-current-query + notmuch-tree-from-search-thread If there was a reasoning behind these not persisting the value of these variables then we should revert it before merging and discuss whether it's worth persisting notmuch-search-exclude. [1]: id:87ilxlxsng@kisara.moe --- emacs/notmuch-jump.el | 11 ++ emacs/notmuch-lib.el | 10 + emacs/notmuch-tree.el | 40 - emacs/notmuch.el | 51 +-- 4 files changed, 87 insertions(+), 25 deletions(-) diff --git a/emacs/notmuch-jump.el b/emacs/notmuch-jump.el index 6a276928..e98c9c1d 100644 --- a/emacs/notmuch-jump.el +++ b/emacs/notmuch-jump.el @@ -50,15 +50,18 @@ fast way to jump to a saved search from anywhere in Notmuch." (cl-case (plist-get saved-search :sort-order) (newest-first nil) (oldest-first t) - (otherwise (default-value 'notmuch-search-oldest-first) + (otherwise (default-value 'notmuch-search-oldest-first + (exclude (default-value 'notmuch-search-exclude))) (push (list key name (cond ((eq (plist-get saved-search :search-type) 'tree) - (lambda () (notmuch-tree query))) + (lambda () (notmuch-tree query nil nil nil nil nil nil + oldest-first exclude))) ((eq (plist-get saved-search :search-type) 'unthreaded) - (lambda () (notmuch-unthreaded query))) + (lambda () (notmuch-unthreaded query nil nil nil nil + oldest-first exclude))) (t - (lambda () (notmuch-search query oldest-first) + (lambda () (notmuch-search query oldest-first exclude) action-map) (setq action-map (nreverse action-map)) (if action-map diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el index 84ba8c5e..96795054 100644 --- a/emacs/notmuch-lib.el +++ b/emacs/notmuch-lib.el @@ -105,6 +105,16 @@ search." :group 'notmuch-search) (make-variable-buffer-local 'notmuch-search-oldest-first) +(defcustom notmuch-search-exclude t + "Hide mail tagged with a excluded tag. + +Excluded tags are defined in the users configuration file under +the search section. When this variable is true, any mail with +such a tag will not be shown in the search output." + :type 'boolean + :group 'notmuch-search) +(make-variable-buffer-local 'notmuch-search-exclude) + (defcustom notmuch-poll-script nil "[Deprecated] Command to run to incorporate new mail into the notmuch database. diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el index f63ac9a5..9ed8a3d9 100644 --- a/emacs/notmuch-tree.el +++ b/emacs/notmuch-tree.el @@ -375,6 +375,7 @@ then NAME behaves like CMD." (define-key map [remap notmuch-jump-search] 'notmuch-tree-jump-search) (define-key map "o" 'notmuch-tree-toggle-order) +(define-key map "i" 'notmuch-tree-toggle-exclude) (define-key map "S" 'notmuch-search-from-tree-current-query) (define-key map "U" 'notmuch-unthreaded-from-tree-current-query) (define-key map "Z" 'notmuch-tree-from-unthreaded-current-query) @@ -590,7 +591,9 @@ NOT change the database." "Call notmuch search with the current query." (interactive) (notmuch-tree-close-message-window) - (notmuch-search (notmuch-tree-get-query))) + (notmuch-search (notmuch-tree-get-query) + notmuch-search-oldest-first + notmuch-search-exclude)) (defun notmuch-tree-message-window-kill-hook () "Close the message pane when exiting the show buffer." @@ -803,7 +806,8 @@ nil otherwise." target nil unthreaded -notmuch-search-oldest-first))) +notmuch-search-oldest-first +notmuch-search
[PATCH 2/9] docs: Update with notmuch-*-toggle-exclude
--- devel/emacs-keybindings.org | 2 +- doc/notmuch-emacs.rst | 5 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/devel/emacs-keybindings.org b/devel/emacs-keybindings.org index ad7f72ef..be6b2481 100644 --- a/devel/emacs-keybindings.org +++ b/devel/emacs-keybindings.org @@ -9,7 +9,7 @@ | f|| notmuch-show-forward-message | notmuch-show-forward-message| | g|| | | | h|| notmuch-show-toggle-visibility-headers| | -| i|| | | +| i| notmuch-search-toggle-exclude | | notmuch-tree-toggle-exclude | | 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| notmuch-tree-filter | diff --git a/doc/notmuch-emacs.rst b/doc/notmuch-emacs.rst index e69bd23d..647e0c40 100644 --- a/doc/notmuch-emacs.rst +++ b/doc/notmuch-emacs.rst @@ -212,6 +212,9 @@ menu of results that the user can explore further by pressing ``g`` ``=`` Refresh the buffer +``i`` +Toggle whether to show messages with excluded tags in search results. + ``?`` Display full set of key bindings @@ -468,6 +471,8 @@ tags. ``t`` ``notmuch-tree-filter-by-tag`` Filter the current search results based on an additional tag +``i`` +Toggle whether to show messages with excluded tags in search results. ``g`` ``=`` Refresh the buffer -- 2.37.1 ___ notmuch mailing list -- notmuch@notmuchmail.org To unsubscribe send an email to notmuch-le...@notmuchmail.org
[PATCH 3/9] test: Fix Search handles subprocess error exit codes
Add in a new option --exclude which wasn't previously passed to the subprocess. --- test/T310-emacs.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/T310-emacs.sh b/test/T310-emacs.sh index 9d0df187..b89a100e 100755 --- a/test/T310-emacs.sh +++ b/test/T310-emacs.sh @@ -1030,7 +1030,7 @@ End of search results. YYY/notmuch_fail exited with status 1 (see *Notmuch errors* for more details) === ERROR === YYY/notmuch_fail exited with status 1 -command: YYY/notmuch_fail search --format\=sexp --format-version\=5 --sort\=newest-first tag\:inbox +command: YYY/notmuch_fail search --format\=sexp --format-version\=5 --sort\=newest-first --exclude\=false tag\:inbox exit status: 1" test_begin_subtest "Search handles subprocess warnings" -- 2.37.1 ___ notmuch mailing list -- notmuch@notmuchmail.org To unsubscribe send an email to notmuch-le...@notmuchmail.org
[PATCH 4/9] feat: Allow :exclude configuration in notmuch-hello
--- emacs/notmuch-hello.el | 35 ++- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el index 4662e704..810f094e 100644 --- a/emacs/notmuch-hello.el +++ b/emacs/notmuch-hello.el @@ -143,6 +143,10 @@ a plist. Supported properties are :sort-order Specify the sort order to be used for the search. Possible values are `oldest-first', `newest-first' or nil. Nil means use the default sort order. + :excludedWhether to include mail with excluded tags in the + search. Possible values are `include', `exclude', + or nil. Nil means use the default value of + `notmuch-search-exclude'. :search-type Specify whether to run the search in search-mode, tree mode or unthreaded mode. Set to `tree' to specify tree mode, 'unthreaded to specify @@ -484,19 +488,19 @@ diagonal." append (notmuch-hello-reflect-generate-row ncols nrows row list (defun notmuch-hello-widget-search (widget &rest _ignore) - (cl-case (widget-get widget :notmuch-search-type) - (tree -(let ((n (notmuch-search-format-buffer-name (widget-value widget) "tree" t))) - (notmuch-tree (widget-get widget :notmuch-search-terms) - nil nil n nil nil nil - (widget-get widget :notmuch-search-oldest-first - (unthreaded -(let ((n (notmuch-search-format-buffer-name (widget-value widget) - "unthreaded" t))) - (notmuch-unthreaded (widget-get widget :notmuch-search-terms) nil nil n))) - (t -(notmuch-search (widget-get widget :notmuch-search-terms) - (widget-get widget :notmuch-search-oldest-first) + (let ((search-terms (widget-get widget :notmuch-search-terms)) + (oldest-first (widget-get widget :notmuch-search-oldest-first)) + (exclude (widget-get widget :notmuch-search-exclude))) +(cl-case (widget-get widget :notmuch-search-type) + (tree + (let ((n (notmuch-search-format-buffer-name (widget-value widget) "tree" t))) +(notmuch-tree search-terms nil nil n nil nil nil oldest-first exclude))) + (unthreaded + (let ((n (notmuch-search-format-buffer-name (widget-value widget) + "unthreaded" t))) +(notmuch-unthreaded search-terms nil nil n nil oldest-first search-exclude))) + (t + (notmuch-search search-terms oldest-first exclude) (defun notmuch-saved-search-count (search) (car (notmuch--process-lines notmuch-command "count" search))) @@ -643,6 +647,10 @@ with `notmuch-hello-query-counts'." (newest-first nil) (oldest-first t) (otherwise notmuch-search-oldest-first))) +(exclude (cl-case (plist-get elem :excluded) + (exclude t) + (include nil) + (otherwise notmuch-search-exclude))) (search-type (plist-get elem :search-type)) (msg-count (plist-get elem :count))) (widget-insert (format "%8s " @@ -652,6 +660,7 @@ with `notmuch-hello-query-counts'." :notmuch-search-terms query :notmuch-search-oldest-first oldest-first :notmuch-search-type search-type + :notmuch-search-exclude exclude name) (setq column-indent (1+ (max 0 (- column-width (length name))) -- 2.37.1 ___ notmuch mailing list -- notmuch@notmuchmail.org To unsubscribe send an email to notmuch-le...@notmuchmail.org
Re: [PATCH] emacs: add new option notmuch-search-exclude
David Bremner writes: Hi, firstly sorry for taking so long to come back to this. I honestly have tried to fix this multiple times since my last message but kept getting confused or misdirected by how the tests are setup so I gave up and decided to come back to it later. Today I finally just sped through everything and think I have everything ready. > So does "python3 -m pytest" work for you? Assuming yes, is there some > special environment needed? We don't explicitly unset PYTHONPATH in > T391, so in if you need PYTHONPATH to locate pytest, that should work > here as well. What output do you get from "python3 -c 'import pytest; > print(pytest.__file__)'" I ended up just installing pytest with my system package manager. I have no idea why but notmuch could not use the pytest installation under my home directory. To briefly summarize the changes since my last message: * I've added notmuch-hello support as well. Basically just added a new configurable option to `notmuch-saved-searches` for configuring the exclude value. This involved some mild refactoring of notmuch-hello-widget-search. * Updated the interactive spec of `notmuch-tree` and `notmuch-unthreaded` so it sources the default value of `notmuch-search-oldest-first` and `notmuch-search-exclude`. The `notmuch-search` command respected these variables already but these commands didn't (not sure why). * I fixed 2 broken test-cases. These were T310-emacs.60 and T460-emacs-tree.11. The former just didn't include the new option in the expected argv list. The later was because we now persist the value of notmuch-search-oldest-first where previously we defaulted it to nil when switching from a search to tree buffer. The ordering of the messages has changes so the test failed. I added a new expected-output file with the new ordering and everything is fixed now. * I added a new test suite test/T461-emacs-search-exclude.sh which contains test cases for the new features. Note this only extends to the exclude option and it persisting between switches between the different view types. I initially wanted to keep the existing suites like T310 and add some deleted messages to the corpora but because of the way the existing tests were setup they could or could not ended up outputting the deleted messages and having to recalculate the expected-output for them proved too much of a hassle. The new test suite is designed from the outset with some deleted and non-deleted messages and covers how their inclusion in the output changes in a few different scenarios. Note: this suite isn't fully comprehensive. It doesn't cover any of the unthreaded commands, or configuring notmuch-hello with entries deviating from the default. It does cover the core functionality of not showing excluded mail, toggling the inclusion of such mail and switching between notmuch-search and notmuch-tree buffers (and vice versa). I've left the remaining tests as something to come back to later but would prefer leaving them as something to add in a follow up PR if possible. Note: Some of the test cases are still failing: Specifically 4 of them, but their failing on the master branch as well so I believe their unrelated to this PR. >From 1872120821ccad5d23ab48d128d8d77efd85055d Mon Sep 17 00:00:00 2001 From: Mohsin Kaleem Date: Sat, 27 Nov 2021 18:58:43 + Subject: [PATCH 01/11] emacs: add new option notmuch-search-exclude The new notmuch-search-exclude option allows users to configure whether to show or hide excluded messages (as determined by search.exclude_tags in the local config file). It defaults to true for now to maintain backwards-compatibility with how notmuch-{search,tree} already worked. New commands notmuch-search-toggle-exclude and notmuch-tree-toggle-exclude have also been added that toggle the value of notmuch-search-exclude for the search in the current search or tree buffer. It's bound to "i" in the respective keymaps for these modes. Lastly I've amended some calls to notmuch-tree and notmuch-unthreaded which didn't pass through the buffer local value of notmuch-search-oldest-first (and now notmuch-search-exclude). Examples of where I've done this + include notmuch-jump-search + notmuch-tree-from-search-current-query + notmuch-unthreaded-from-search-current-query + notmuch-tree-from-search-thread If there was a reasoning behind these not persisting the value of these variables then we should revert it before merging and discuss whether it's worth persisting notmuch-search-exclude. [1]: id:87ilxlxsng@kisara.moe --- emacs/notmuch-jump.el | 11 ++ emacs/notmuch-lib.el | 10 + emacs/notmuch-tree.el | 40 - emacs/notmuch.el | 51 +-- 4 files changed, 87 insertions(+), 25 deletions(-) diff --git a/emacs/notmuch-jump.el b/emacs/notmuch-jump.el index
Re: [PATCH] emacs: add new option notmuch-search-exclude
are/notmuch/default: No such file or directory. T592-thread-breakage: Testing thread breakage during reindexing BROKEN No ghosts should remain after deletion of second message missing prerequisites: dtach(1) SKIP all tests in T630-emacs-draft T670-duplicate-mid: Testing duplicate message ids BROKEN First subject preserved in notmuch-show (json) BROKEN Regexp search for second subject missing prerequisites: dtach(1) SKIP all tests in T720-emacs-attachment-warnings missing prerequisites: dtach(1) SKIP all tests in T730-emacs-forwarding Notmuch test suite complete. 1362/1379 tests passed. 7 broken tests failed as expected. 4 tests failed. 6 tests skipped. All tests in 18 files skipped. ERROR: parallel test suite returned error code 2 -- Mohsin Kaleem ___ notmuch mailing list -- notmuch@notmuchmail.org To unsubscribe send an email to notmuch-le...@notmuchmail.org
Re: [PATCH] emacs: add new option notmuch-search-exclude
David Bremner writes: > It's just a guess, but do you by chance override XDG_DATA_HOME? I can > imagine that causing problems for the test suite. I do export an environment variable $XDG_DATA_HOME, but it points to the default location "/home/mohkale/.local/share" so I'm not sure why that would be causing this to fail. I tried running `XDG_DATA_HOME= make test` and it's still failing. I also tried moving my notmuch repository copy outside of any XDG* directories but the tests are still failing :-(. -- Mohsin Kaleem ___ notmuch mailing list -- notmuch@notmuchmail.org To unsubscribe send an email to notmuch-le...@notmuchmail.org
Re: [PATCH] emacs: add new option notmuch-search-exclude
.NotmuchError(ret, msg) notmuch2.NoDatabaseError: Error: could not locate database. FAIL Set shadowed config value in database (XDG+profile) --- T055-path-config.71.expected2022-03-22 19:30:35.261534466 + +++ T055-path-config.71.output 2022-03-22 19:30:35.261534466 + @@ -1 +1 @@ -17086+ ++ notmuch config: Illegal argument for function Cannot reopen closed or nonexistent database notmuch config: Illegal argument for function Cannot reopen closed or nonexistent database FAIL 'to' header does not crash (python-cffi) (XDG+profile) --- T055-path-config.72.EXPECTED2022-03-22 19:30:35.364870706 + +++ T055-path-config.72.OUTPUT 2022-03-22 19:30:35.368204134 + @@ -1 +0,0 @@ -notmuch@notmuchmail.org Traceback (most recent call last): File "", line 2, in File "/home/mohkale/.cache/emacs/straight/repos/notmuch/bindings/python-cffi/build/stage/notmuch2/_database.py", line 160, in __init__ raise errors.NotmuchError(ret, msg) notmuch2.NoDatabaseError: Error: could not locate database. missing prerequisites: dtach(1) SKIP all tests in T350-crypto missing prerequisites: dtach(1) SKIP all tests in T320-emacs-large-search-buffer missing prerequisites: dtach(1) SKIP all tests in T355-smime missing prerequisites: dtach(1) SKIP all tests in T357-index-decryption missing prerequisites: dtach(1) SKIP all tests in T358-emacs-protected-headers T391-python-cffi: Testing python bindings (pytest) FAIL python cffi tests (NOTMUCH_CONFIG set) (cd /home/mohkale/.cache/emacs/straight/repos/notmuch/bindings/python-cffi/build/stage && python3 -m pytest --verbose --log-file=/home/mohkale/.cache/emacs/straight/repos/notmuch/test/tmp.T391-python-cffi/test.output) /usr/bin/python3: No module named pytest FAIL python cffi tests (NOTMUCH_CONFIG unset) (cd /home/mohkale/.cache/emacs/straight/repos/notmuch/bindings/python-cffi/build/stage && python3 -m pytest --verbose --log-file=/home/mohkale/.cache/emacs/straight/repos/notmuch/test/tmp.T391-python-cffi/test.output) /usr/bin/python3: No module named pytest missing prerequisites: dtach(1) SKIP emacs test function sanity missing prerequisites: dtach(1) SKIP all tests in T430-emacs-address-cleaning missing prerequisites: dtach(1) SKIP all tests in T440-emacs-hello missing prerequisites: dtach(1) SKIP all tests in T450-emacs-show missing prerequisites: dtach(1) SKIP all tests in T455-emacs-charsets missing prerequisites: dtach(1) SKIP all tests in T460-emacs-tree missing prerequisites: dtach(1) SKIP all tests in T465-emacs-unthreaded missing prerequisites: dtach(1) SKIP reply to ghost (tree view) missing prerequisites: dtach(1) SKIP reply to ghost (RT/tree view) missing prerequisites: dtach(1) SKIP trusting reply-to (tree view) T560-lib-error: Testing error reporting for library FAIL Open null pointer --- T560-lib-error.2.EXPECTED 2022-03-22 19:30:49.525269225 + +++ T560-lib-error.2.OUTPUT 2022-03-22 19:30:49.528602652 + @@ -1,3 +1,2 @@ == stdout == == stderr == -Error: could not locate database. test1.c: In function 'main': test1.c:7:5: warning: 'notmuch_database_open' is deprecated: function deprecated as of libnotmuch 5.4 [-Wdeprecated-declarations] 7 | stat = notmuch_database_open (NULL, 0, 0); | ^~~~ In file included from test1.c:2: /home/mohkale/.cache/emacs/straight/repos/notmuch/lib/notmuch.h:332:1: note: declared here 332 | notmuch_database_open (const char *path, | ^ FAIL create NULL path --- T560-lib-error.6.EXPECTED 2022-03-22 19:30:50.155286965 + +++ T560-lib-error.6.OUTPUT 2022-03-22 19:30:50.155286965 + @@ -1,3 +1,3 @@ == stdout == == stderr == -Error: could not locate database. +Error: Cannot open database at /home/mohkale/.local/share/notmuch/default: No such file or directory. T592-thread-breakage: Testing thread breakage during reindexing BROKEN No ghosts should remain after deletion of second message missing prerequisites: dtach(1) SKIP all tests in T630-emacs-draft T670-duplicate-mid: Testing duplicate message ids BROKEN First subject preserved in notmuch-show (json) BROKEN Regexp search for second subject missing prerequisites: dtach(1) SKIP all tests in T720-emacs-attachment-warnings missing prerequisites: dtach(1) SKIP all tests in T730-emacs-forwarding Notmuch test suite complete. 1324/1369 tests passed. 7 broken tests failed as expected. 42 tests failed. -4 tests skipped. All tests in 18 files skipped. ERROR: parallel test suite returned error code 3 -- Mohsin Kaleem ___ notmuch mailing list -- notmuch@notmuchmail.org To unsubscribe send an email to notmuch-le...@notmuchmail.org
Re: [PATCH] emacs: add new option notmuch-search-exclude
David Bremner writes: > Can you update the file devel/emacs-keybindings.org so we don't lose > track of the bindings. Also, per the contributing guide [1], please > add some brief documentation to the emacs docs in > doc/notmuch-emacs.rst Done. > Also, we need at least one new test (ideally one per mode). There should > be some tests you can crib from in T310-emacs.sh and T450-emacs-show.sh. I'm more than happy to add some new tests but at least for me the test suite appears to be failing on the master branch. I think it'd be easier to wait until the existing tests are fixed before adding or changing new ones. >From 1872120821ccad5d23ab48d128d8d77efd85055d Mon Sep 17 00:00:00 2001 From: Mohsin Kaleem Date: Sat, 27 Nov 2021 18:58:43 + Subject: [PATCH 1/2] emacs: add new option notmuch-search-exclude The new notmuch-search-exclude option allows users to configure whether to show or hide excluded messages (as determined by search.exclude_tags in the local config file). It defaults to true for now to maintain backwards-compatibility with how notmuch-{search,tree} already worked. New commands notmuch-search-toggle-exclude and notmuch-tree-toggle-exclude have also been added that toggle the value of notmuch-search-exclude for the search in the current search or tree buffer. It's bound to "i" in the respective keymaps for these modes. Lastly I've amended some calls to notmuch-tree and notmuch-unthreaded which didn't pass through the buffer local value of notmuch-search-oldest-first (and now notmuch-search-exclude). Examples of where I've done this + include notmuch-jump-search + notmuch-tree-from-search-current-query + notmuch-unthreaded-from-search-current-query + notmuch-tree-from-search-thread If there was a reasoning behind these not persisting the value of these variables then we should revert it before merging and discuss whether it's worth persisting notmuch-search-exclude. [1]: id:87ilxlxsng@kisara.moe --- emacs/notmuch-jump.el | 11 ++ emacs/notmuch-lib.el | 10 + emacs/notmuch-tree.el | 40 - emacs/notmuch.el | 51 +-- 4 files changed, 87 insertions(+), 25 deletions(-) diff --git a/emacs/notmuch-jump.el b/emacs/notmuch-jump.el index 6a276928..e98c9c1d 100644 --- a/emacs/notmuch-jump.el +++ b/emacs/notmuch-jump.el @@ -50,15 +50,18 @@ fast way to jump to a saved search from anywhere in Notmuch." (cl-case (plist-get saved-search :sort-order) (newest-first nil) (oldest-first t) - (otherwise (default-value 'notmuch-search-oldest-first) + (otherwise (default-value 'notmuch-search-oldest-first + (exclude (default-value 'notmuch-search-exclude))) (push (list key name (cond ((eq (plist-get saved-search :search-type) 'tree) - (lambda () (notmuch-tree query))) + (lambda () (notmuch-tree query nil nil nil nil nil nil + oldest-first exclude))) ((eq (plist-get saved-search :search-type) 'unthreaded) - (lambda () (notmuch-unthreaded query))) + (lambda () (notmuch-unthreaded query nil nil nil nil + oldest-first exclude))) (t - (lambda () (notmuch-search query oldest-first) + (lambda () (notmuch-search query oldest-first exclude) action-map) (setq action-map (nreverse action-map)) (if action-map diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el index 6fc71cc7..9a0e470e 100644 --- a/emacs/notmuch-lib.el +++ b/emacs/notmuch-lib.el @@ -105,6 +105,16 @@ search." :group 'notmuch-search) (make-variable-buffer-local 'notmuch-search-oldest-first) +(defcustom notmuch-search-exclude t + "Hide mail tagged with a excluded tag. + +Excluded tags are defined in the users configuration file under +the search section. When this variable is true, any mail with +such a tag will not be shown in the search output." + :type 'boolean + :group 'notmuch-search) +(make-variable-buffer-local 'notmuch-search-exclude) + (defcustom notmuch-poll-script nil "[Deprecated] Command to run to incorporate new mail into the notmuch database. diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el index 303c6fad..e4d9ae44 100644 --- a/emacs/notmuch-tree.el +++ b/emacs/notmuch-tree.el @@ -363,6 +363,7 @@ then NAME behaves like CMD." (define-key map [remap notmuch-jump-search] 'notmuch-tree-jump-search) (define-key map "o" 'notmuch-tree-toggle-order) +(define-key map "i" 'notmuch-tree-toggle-exclude) (define-key map "S" 'notmuch-search-from-tree-current-query) (define-key map "U" 'notmuch-unthreaded-from-tree-current-query) (define-key map "Z" 'notmuch-tree-from-unthreaded-current-query) @@ -578,7 +579,9 @@ NOT change the d
[PATCH] emacs: add new option notmuch-search-exclude
The new notmuch-search-exclude option allows users to configure whether to show or hide excluded messages (as determined by search.exclude_tags in the local config file). It defaults to true for now to maintain backwards-compatibility with how notmuch-{search,tree} already worked. New commands notmuch-search-toggle-exclude and notmuch-tree-toggle-exclude have also been added that toggle the value of notmuch-search-exclude for the search in the current search or tree buffer. It's bound to "i" in the respective keymaps for these modes. Lastly I've amended some calls to notmuch-tree and notmuch-unthreaded which didn't pass through the buffer local value of notmuch-search-oldest-first (and now notmuch-search-exclude). Examples of where I've done this + include notmuch-jump-search + notmuch-tree-from-search-current-query + notmuch-unthreaded-from-search-current-query + notmuch-tree-from-search-thread If there was a reasoning behind these not persisting the value of these variables then we should revert it before merging and discuss whether it's worth persisting notmuch-search-exclude. [1]: id:87ilxlxsng@kisara.moe --- emacs/notmuch-jump.el | 11 ++ emacs/notmuch-lib.el | 10 + emacs/notmuch-tree.el | 40 - emacs/notmuch.el | 51 +-- 4 files changed, 87 insertions(+), 25 deletions(-) diff --git a/emacs/notmuch-jump.el b/emacs/notmuch-jump.el index 6a276928..e98c9c1d 100644 --- a/emacs/notmuch-jump.el +++ b/emacs/notmuch-jump.el @@ -50,15 +50,18 @@ fast way to jump to a saved search from anywhere in Notmuch." (cl-case (plist-get saved-search :sort-order) (newest-first nil) (oldest-first t) - (otherwise (default-value 'notmuch-search-oldest-first) + (otherwise (default-value 'notmuch-search-oldest-first + (exclude (default-value 'notmuch-search-exclude))) (push (list key name (cond ((eq (plist-get saved-search :search-type) 'tree) - (lambda () (notmuch-tree query))) + (lambda () (notmuch-tree query nil nil nil nil nil nil + oldest-first exclude))) ((eq (plist-get saved-search :search-type) 'unthreaded) - (lambda () (notmuch-unthreaded query))) + (lambda () (notmuch-unthreaded query nil nil nil nil + oldest-first exclude))) (t - (lambda () (notmuch-search query oldest-first) + (lambda () (notmuch-search query oldest-first exclude) action-map) (setq action-map (nreverse action-map)) (if action-map diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el index 45817e13..a0b780fd 100644 --- a/emacs/notmuch-lib.el +++ b/emacs/notmuch-lib.el @@ -105,6 +105,16 @@ search." :group 'notmuch-search) (make-variable-buffer-local 'notmuch-search-oldest-first) +(defcustom notmuch-search-exclude t + "Hide mail tagged with a excluded tag. + +Excluded tags are defined in the users configuration file under +the search section. When this variable is true, any mail with +such a tag will not be shown in the search output." + :type 'boolean + :group 'notmuch-search) +(make-variable-buffer-local 'notmuch-search-exclude) + (defcustom notmuch-poll-script nil "[Deprecated] Command to run to incorporate new mail into the notmuch database. diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el index 7fa73d40..7e85dc51 100644 --- a/emacs/notmuch-tree.el +++ b/emacs/notmuch-tree.el @@ -363,6 +363,7 @@ then NAME behaves like CMD." (define-key map [remap notmuch-jump-search] 'notmuch-tree-jump-search) (define-key map "o" 'notmuch-tree-toggle-order) +(define-key map "i" 'notmuch-tree-toggle-exclude) (define-key map "S" 'notmuch-search-from-tree-current-query) (define-key map "U" 'notmuch-unthreaded-from-tree-current-query) (define-key map "Z" 'notmuch-tree-from-unthreaded-current-query) @@ -578,7 +579,9 @@ NOT change the database." "Call notmuch search with the current query." (interactive) (notmuch-tree-close-message-window) - (notmuch-search (notmuch-tree-get-query))) + (notmuch-search (notmuch-tree-get-query) + notmuch-search-oldest-first + notmuch-search-exclude)) (defun notmuch-tree-message-window-kill-hook () "Close the message pane when exiting the show buffer." @@ -791,7 +794,8 @@ nil otherwise." target nil unthreaded -notmuch-search-oldest-first))) +notmuch-search-oldest-first +notmuch-search
Re: notmuch-emacs: Add option to set -exclude=false in notmuch search/tree
David Bremner writes: > Unfortunately that list seems to grow rather than shrink over time... Hopefully it won't grow any larger due to this issue :-). I've implemented this in the patch attached to this email. The new option is notmuch-search-exclude, it defaults to true. There are new commands to toggle the value of this variable for the current search and these are bound to "i" in the respective mode maps. I've also changed whether or not notmuch-search-oldest-first and notmuch-search-exclude are persisted across some commands. For example switching from a regular search buffer to a tree buffer with notmuch-tree-from-search-current-query will make sure the value of both these variables is the same in both buffers. Similarly filtering an existing search such as notmuch-search-filter will also persist them, but starting a new search with notmuch-search will reset to the global default value of either of them. There were quite a lot of functions that I've modified or altered in some way with this PR. I've tested the ones I'm familliar with and everythings working the way I expect. If you have any issues please let me know. >From 9b11223c0162f8736dd27d6f1db3fadbd3b027e2 Mon Sep 17 00:00:00 2001 From: Mohsin Kaleem Date: Sat, 27 Nov 2021 18:58:43 + Subject: [PATCH] emacs: add new option notmuch-search-exclude The new notmuch-search-exclude option allows users to configure whether to show or hide excluded messages (as determined by search.exclude_tags in the local config file). It defaults to true for now to maintain backwards-compatibility with how notmuch-{search,tree} already worked. New commands notmuch-search-toggle-exclude and notmuch-tree-toggle-exclude have also been added that toggle the value of notmuch-search-exclude for the search in the current search or tree buffer. It's bound to "i" in the respective keymaps for these modes. Lastly I've amended some calls to notmuch-tree and notmuch-unthreaded which didn't pass through the buffer local value of notmuch-search-oldest-first (and now notmuch-search-exclude). Examples of where I've done this + include notmuch-jump-search + notmuch-tree-from-search-current-query + notmuch-unthreaded-from-search-current-query + notmuch-tree-from-search-thread If there was a reasoning behind these not persisting the value of these variables then we should revert it before merging and discuss whether it's worth persisting notmuch-search-exclude. [1]: id:87ilxlxsng@kisara.moe --- emacs/notmuch-jump.el | 11 ++ emacs/notmuch-lib.el | 10 + emacs/notmuch-tree.el | 40 +++- emacs/notmuch.el | 47 ++- 4 files changed, 84 insertions(+), 24 deletions(-) diff --git a/emacs/notmuch-jump.el b/emacs/notmuch-jump.el index 6a276928..e98c9c1d 100644 --- a/emacs/notmuch-jump.el +++ b/emacs/notmuch-jump.el @@ -50,15 +50,18 @@ fast way to jump to a saved search from anywhere in Notmuch." (cl-case (plist-get saved-search :sort-order) (newest-first nil) (oldest-first t) - (otherwise (default-value 'notmuch-search-oldest-first) + (otherwise (default-value 'notmuch-search-oldest-first + (exclude (default-value 'notmuch-search-exclude))) (push (list key name (cond ((eq (plist-get saved-search :search-type) 'tree) - (lambda () (notmuch-tree query))) + (lambda () (notmuch-tree query nil nil nil nil nil nil + oldest-first exclude))) ((eq (plist-get saved-search :search-type) 'unthreaded) - (lambda () (notmuch-unthreaded query))) + (lambda () (notmuch-unthreaded query nil nil nil nil + oldest-first exclude))) (t - (lambda () (notmuch-search query oldest-first) + (lambda () (notmuch-search query oldest-first exclude) action-map) (setq action-map (nreverse action-map)) (if action-map diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el index 45817e13..a0b780fd 100644 --- a/emacs/notmuch-lib.el +++ b/emacs/notmuch-lib.el @@ -105,6 +105,16 @@ search." :group 'notmuch-search) (make-variable-buffer-local 'notmuch-search-oldest-first) +(defcustom notmuch-search-exclude t + "Hide mail tagged with a excluded tag. + +Excluded tags are defined in the users configuration file under +the search section. When this variable is true, any mail with +such a tag will not be shown in the search output." + :type 'boolean + :group 'notmuch-search) +(make-variable-buffer-local 'notmuch-search-exclude) + (defcustom notmuch-poll-script nil "[Deprecated] Command to run to incorporate new mail into the notmuch database. diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el index 7fa73d40..7e85dc51 100644 --- a/emacs/notmuch-tree.el +++ b/emacs/notmuch-tree.el @@ -363,6 +363,7 @@ then
notmuch-emacs: Add option to set -exclude=false in notmuch search/tree
At the moment we always use the default value of exclude in calls to notmuch search and notmuch tree. If any of the searched mail is tagged with somethinh that is excluded it isn't shown and if we'd like to check whether this is the case we have to do an exhaustive search over all of our hidden tags to check whether the mail got ommited because it was tagged as such. I suggest we add a new option `notmuch-search-exclude`, which is used to set the default value of the exclude flag in both notmuch-search and notmuch-tree mode, and also to add a new command `notmuch-toggle-exclude` which toggles the value of `notmuch-search-exclude` for the current search. -- Mohsin Kaleem ___ notmuch mailing list -- notmuch@notmuchmail.org To unsubscribe send an email to notmuch-le...@notmuchmail.org