[PATCH v3] emacs: Add new option notmuch-search-hide-excluded

2024-03-10 Thread mohkale
From: Mohsin Kaleem 

The new notmuch-search-hide-excluded option allows users to configure whether
to show or hide excluded messages (as determined by search.exclude_tags
in the local notmuch config file). It defaults to true for now to maintain
backwards-compatibility with how notmuch-{search,tree} already worked.

New commands notmuch-search-toggle-hide-excluded and
notmuch-tree-toggle-exclude have also been added. They toggle the value
of notmuch-search-hide-excluded 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

A new test file for Emacs has been added which covers the usage of the
new `notmuch-search-hide-excluded' option and interactively hiding or
showing mail with excluded tags. These test cover the basic usage of
the `notmuch-search-toggle-hide-excluded' command in notmuch-search,
notmuch-tree and notmuch-unthreaded searches. These tests also cover
the persistence of the current value of the hide-excluded mail option
as a user switches from between these different search commands.

[1]: id:87ilxlxsng@kisara.moe
---
 devel/emacs-keybindings.org   |   2 +-
 doc/notmuch-emacs.rst |   7 +
 emacs/notmuch-hello.el|  40 ++--
 emacs/notmuch-jump.el |  14 +-
 emacs/notmuch-lib.el  |  10 +
 emacs/notmuch-tree.el |  60 --
 emacs/notmuch.el  |  52 +++--
 test/T310-emacs.sh|   2 +-
 test/T460-emacs-tree.sh   |   2 +-
 test/T461-emacs-search-exclude.sh | 185 ++
 .../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 +
 ...notmuch-unthreaded-tag-inbox-with-excluded |  53 +
 ...much-unthreaded-tag-inbox-without-excluded |  49 +
 .../notmuch-tree-tag-inbox-oldest-first   |  53 +
 17 files changed, 632 insertions(+), 45 deletions(-)
 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
 create mode 100644 
test/emacs-exclude.expected-output/notmuch-unthreaded-tag-inbox-with-excluded
 create mode 100644 
test/emacs-exclude.expected-output/notmuch-unthreaded-tag-inbox-without-excluded
 create mode 100644 
test/emacs-tree.expected-output/notmuch-tree-tag-inbox-oldest-first

diff --git a/devel/emacs-keybindings.org b/devel/emacs-keybindings.org
index ad7f72ef..218677c2 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-hide-excluded|  
 | notmuch-tree-toggle-hide-excluded   |
 | 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 7dff7d64..91af6d14 100644
--- a/doc/notmuch-emacs.rst
+++ b/doc/notmuch-emacs.rst
@@ -232,6 +232,10 @@ menu of results that the user can explore further by 
pressing
 
 Refresh the buffer
 
+.. el:define-key:: i

Re: [PATCH v2 2/3] emacs: Allow notmuch-saved-searches to hide excluded messages

2024-03-10 Thread Mohsin Kaleem
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