[PATCH 02/13] test: split header for lib-message tests.

2020-07-26 Thread David Bremner
This allows finer control over when to close the database. --- test/T566-lib-message.sh | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/test/T566-lib-message.sh b/test/T566-lib-message.sh index 4c9fc0df..7e8f8959 100755 --- a/test/T566-lib-message.sh +++

[PATCH 03/13] test: regression test for n_m_get_filenames

2020-07-26 Thread David Bremner
Closing the database after the iterator is created is not a problem. --- test/T566-lib-message.sh | 23 +++ 1 file changed, 23 insertions(+) diff --git a/test/T566-lib-message.sh b/test/T566-lib-message.sh index 7e8f8959..d3765220 100755 --- a/test/T566-lib-message.sh +++

[PATCH 04/13] test: add known broken test for n_directory_get_child_directories

2020-07-26 Thread David Bremner
The error message here may need adjusting. --- test/T563-lib-directory.sh | 61 ++ 1 file changed, 61 insertions(+) create mode 100755 test/T563-lib-directory.sh diff --git a/test/T563-lib-directory.sh b/test/T563-lib-directory.sh new file mode 100755 index

[PATCH 10/13] test: regression test for n_d_get_config_list on closed db.

2020-07-26 Thread David Bremner
Exception is caught. --- test/T590-libconfig.sh | 15 +++ 1 file changed, 15 insertions(+) diff --git a/test/T590-libconfig.sh b/test/T590-libconfig.sh index 46f3a76d..602fad0b 100755 --- a/test/T590-libconfig.sh +++ b/test/T590-libconfig.sh @@ -61,6 +61,21 @@ valid = 0 EOF

[PATCH 08/13] test: regression test for n_directory_delete with closed db.

2020-07-26 Thread David Bremner
To the best of my current understanding, it's a bug in Xapian that no exception is thrown here. The test should pass in either case. --- test/T563-lib-directory.sh | 19 ++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/test/T563-lib-directory.sh

[PATCH 07/13] lib: catch exceptions in n_directory_get_child_files

2020-07-26 Thread David Bremner
Also clarify API in error case. --- lib/directory.cc | 12 lib/notmuch.h | 2 ++ test/T563-lib-directory.sh | 1 - 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/directory.cc b/lib/directory.cc index eb59d24d..044cd680 100644 ---

[PATCH 11/13] test: regression test for traversing config list with closed db

2020-07-26 Thread David Bremner
Also mention error return in API docs --- lib/notmuch.h | 1 + test/T590-libconfig.sh | 22 ++ 2 files changed, 23 insertions(+) diff --git a/lib/notmuch.h b/lib/notmuch.h index d52fa976..1fe62914 100644 --- a/lib/notmuch.h +++ b/lib/notmuch.h @@ -2291,6 +2291,7 @@

final(?) batch of api cleanup for exception handling

2020-07-26 Thread David Bremner
Hopefully this covers completely the current API for error handling on closed databases. For the most part, it's not that I care about supporting operations on closed databases, but rather it provides a good opportunity to make sure exceptions are being caught at the the boundary of libnotmuch.

[PATCH 01/13] test: add regression test for n_messages_collect_tags

2020-07-26 Thread David Bremner
Also test n_messages_destroy. --- test/T568-lib-thread.sh | 31 +++ 1 file changed, 31 insertions(+) diff --git a/test/T568-lib-thread.sh b/test/T568-lib-thread.sh index 66066854..ac13d986 100755 --- a/test/T568-lib-thread.sh +++ b/test/T568-lib-thread.sh @@ -285,6

[PATCH 06/13] test: add known broken test for n_directory_get_child_files

2020-07-26 Thread David Bremner
This is a clone of the one for get_child_directories --- test/T563-lib-directory.sh | 18 ++ 1 file changed, 18 insertions(+) diff --git a/test/T563-lib-directory.sh b/test/T563-lib-directory.sh index 4d8b7e82..bbd12e12 100755 --- a/test/T563-lib-directory.sh +++

[PATCH 05/13] lib: catch exceptions in n_directory_get_child_directories

2020-07-26 Thread David Bremner
Also clarify API in error case. --- lib/directory.cc | 23 --- lib/notmuch.h | 2 ++ test/T563-lib-directory.sh | 1 - 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/lib/directory.cc b/lib/directory.cc index 09b49245..eb59d24d 100644

[PATCH 09/13] test: regression test for n_directory_{get,set}_mtime

2020-07-26 Thread David Bremner
The mtime is cached, so closing the db is not a problem. Writing the mtime throws an exception, which is caught. --- test/T563-lib-directory.sh | 18 ++ 1 file changed, 18 insertions(+) diff --git a/test/T563-lib-directory.sh b/test/T563-lib-directory.sh index 4de31078..c45bc5f8

[PATCH 13/13] lib: return NULL from n_d_get_default_indexopts on error

2020-07-26 Thread David Bremner
This is a rare and probably serious programming error, so better not to silently return a default value. --- lib/indexopts.c | 2 +- lib/notmuch.h | 1 + test/T562-lib-database.sh | 1 - 3 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/indexopts.c

[PATCH 12/13] test: regression tests for n_indexopts_{get,set}_decrypt_policy

2020-07-26 Thread David Bremner
The main criteria is that they don't crash. Working with a closed database is a bonus. --- test/T562-lib-database.sh | 39 +++ 1 file changed, 39 insertions(+) diff --git a/test/T562-lib-database.sh b/test/T562-lib-database.sh index 32fda72e..815c9856 100755

[PATCH 06/23] emacs: Use cl-incf where appropriate

2020-07-26 Thread Jonas Bernoulli
It's shorter. That's it pretty much. --- emacs/notmuch-hello.el | 2 +- emacs/notmuch-lib.el | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el index 89e03c36..1c084bf7 100644 --- a/emacs/notmuch-hello.el +++

[PATCH 05/23] emacs: Only set one variable per setq form

2020-07-26 Thread Jonas Bernoulli
It's a bit weird to avoid having to write the "(setq ... )" more than once, just because we can. In a language that uses '=' for the same purpose we also happily use that once per assignment. While there are no benefit to using just one 'setq' there are some drawbacks. It is not always clear on

[PATCH 01/23] emacs: Shorten long lines

2020-07-26 Thread Jonas Bernoulli
--- emacs/coolj.el | 2 +- emacs/notmuch-address.el | 38 +++-- emacs/notmuch-company.el | 17 -- emacs/notmuch-crypto.el | 16 +++--- emacs/notmuch-draft.el | 12 ++-- emacs/notmuch-hello.el | 43 ++- emacs/notmuch-jump.el

[PATCH 10/23] emacs: Use one or three lines for 'if' forms

2020-07-26 Thread Jonas Bernoulli
Putting the COND and THEN parts on the same line but ELSE on a separate line makes it harder to determine if there actually is an ELSE part. --- emacs/notmuch-lib.el | 6 -- emacs/notmuch-tag.el | 3 ++- emacs/notmuch-tree.el | 3 ++- 3 files changed, 8 insertions(+), 4 deletions(-) diff

[PATCH 03/23] emacs: Fix indentation

2020-07-26 Thread Jonas Bernoulli
--- emacs/coolj.el | 16 ++--- emacs/notmuch-address.el | 18 +++--- emacs/notmuch-compat.el| 86 - emacs/notmuch-draft.el | 18 +++--- emacs/notmuch-hello.el | 24 +++ emacs/notmuch-lib.el | 56

[PATCH 04/23] emacs: Closing parenthesis go on the same line

2020-07-26 Thread Jonas Bernoulli
--- emacs/notmuch-lib.el | 6 ++ emacs/notmuch-show.el | 19 --- emacs/notmuch-tree.el | 4 ++-- emacs/notmuch.el | 6 ++ 4 files changed, 14 insertions(+), 21 deletions(-) diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el index 7994d5ad..f8958a91 100644

[PATCH 00/23] A create number of cosmetic changes

2020-07-26 Thread Jonas Bernoulli
Hello, Please forgive me for this wall of unsolicited cleanup; I blame it on a mild form of ocd. I made most of these changes a few months ago when I was splitting the libraries into `outline-minor-mode' compatible sections. To do so I had to have some understanding of the code I was splitting

[PATCH 08/23] emacs: Use 'unless' instead of 'when' and 'not'

2020-07-26 Thread Jonas Bernoulli
Also use 'unless' in a few cases where previously 'if' was used with 'not' but without an ELSE part. --- emacs/notmuch-hello.el | 6 +++--- emacs/notmuch-mua.el| 4 ++-- emacs/notmuch-parser.el | 2 +- emacs/notmuch-show.el | 3 +-- emacs/notmuch-tag.el| 4 ++-- emacs/notmuch-tree.el

[PATCH 11/23] emacs: Extend face to window edge again

2020-07-26 Thread Jonas Bernoulli
Since Emacs 27 each face has to be explicitly configured to "extend to the edge of the window". Without doing that the face used for the newline character only has an effect that spans "one character" (i.e. it looks like there is a single trailing space character). We don't want that so extend

[PATCH 17/23] emacs: Autoload notmuch-jump-search only once

2020-07-26 Thread Jonas Bernoulli
This function is being autoloaded using an autoload cookie, so it shouldn't additionally be autoloaded using an `autoload' form. When building libraries we don't actually load the autoloads file and dropping the `autoload' form results in an error, which reveals a so far unspecified dependency:

[PATCH 13/23] emacs: No longer define notmuch-hello-mode-map as a function

2020-07-26 Thread Jonas Bernoulli
It was defined as such for a decade; ever since a56010ac8b89a2489eee5c78469f05cee85ec858 but there wasn't a reason to do that then nor is there now. --- emacs/notmuch-hello.el | 1 - 1 file changed, 1 deletion(-) diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el index

[PATCH 14/23] emacs: notmuch-poll: Let the user know we are polling

2020-07-26 Thread Jonas Bernoulli
It is done synchronously and it can take a while, so we should let the user know what is going on. --- emacs/notmuch-lib.el | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el index fc76fd67..069a19e9 100644 --- a/emacs/notmuch-lib.el

[PATCH 22/23] .dir-locals.el: Set variables for correct "shell" mode

2020-07-26 Thread Jonas Bernoulli
The major mode used for shell scripts is named 'sh-mode'. 'shell-mode' on the other hand implements an interactive shell in emacs-lisp. --- .dir-locals.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.dir-locals.el b/.dir-locals.el index fc75ae61..b3ddffe8 100644 ---

[PATCH 18/23] emacs: Autoload notmuch-jump using an autoload cookie

2020-07-26 Thread Jonas Bernoulli
Doing that is better than using an `autoload' form because the latter may result in dependencies getting hidden and indeed it turns out we have to declare `notmuch-jump' in "notmuch-tag.el". --- emacs/notmuch-jump.el | 1 + emacs/notmuch-tag.el | 3 +-- 2 files changed, 2 insertions(+), 2

[PATCH 02/23] emacs: Remove excess empty lines

2020-07-26 Thread Jonas Bernoulli
Most people who write lots of lisp tend to only sparsely use empty "separator" lines within forms. In lisp they feel unnecessary and since most files stick to this convention we get a bit confused when there are extra empty lines. It feels like the s-expressions are falling into pieces. All of

[PATCH 07/23] emacs: Use 'and' instead of 'when' when the return value matters

2020-07-26 Thread Jonas Bernoulli
Also do so for some 'if' forms that lack an ELSE part. Even go as far as using 'and' and 'not' instead of 'unless'. --- emacs/coolj.el | 12 +++--- emacs/notmuch-address.el | 72 ++-- emacs/notmuch-crypto.el | 2 +- emacs/notmuch-draft.el

[PATCH 21/23] Fix typos

2020-07-26 Thread Jonas Bernoulli
--- NEWS | 2 +- bindings/python-cffi/notmuch2/__init__.py | 2 +- bindings/python-cffi/notmuch2/_base.py | 6 +++--- bindings/python-cffi/notmuch2/_database.py | 8 bindings/python-cffi/notmuch2/_message.py | 4 ++--

[PATCH 23/23] test: Fix indentation

2020-07-26 Thread Jonas Bernoulli
Fix it to consistently match the style we have configured in ".dir-locals.el". --- test/test-lib.sh | 36 ++-- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/test/test-lib.sh b/test/test-lib.sh index 90e26639..a4058660 100644 --- a/test/test-lib.sh

[PATCH 09/23] emacs: Use 'when' instead of 'if' when there is no ELSE part

2020-07-26 Thread Jonas Bernoulli
--- emacs/notmuch-address.el | 8 ++-- emacs/notmuch-compat.el | 6 +-- emacs/notmuch-hello.el | 8 ++-- emacs/notmuch-jump.el| 54 ++--- emacs/notmuch-lib.el | 10 ++-- emacs/notmuch-mua.el | 24 +- emacs/notmuch-query.el | 4 +-

[PATCH 20/23] emacs: Increase consistency of library headers

2020-07-26 Thread Jonas Bernoulli
--- emacs/notmuch-company.el | 36 +++-- emacs/notmuch-compat.el | 15 ++ emacs/notmuch-crypto.el | 2 +- emacs/notmuch-lib.el | 2 -- emacs/notmuch-maildir-fcc.el | 39 ++-- emacs/notmuch-print.el

[PATCH 16/23] emacs: Improve doc-strings

2020-07-26 Thread Jonas Bernoulli
- The first sentence should fit on the first line in full. This is even the case when that causes the line to get a bit long. If it gets very long, then it should be made shorter. - Even even the second sentence would fit on the first line, if it just provides some details, then it

[PATCH 19/23] emacs: Various cosmetic changes

2020-07-26 Thread Jonas Bernoulli
--- emacs/make-deps.el | 3 ++- emacs/notmuch-lib.el| 8 +++- emacs/notmuch-parser.el | 9 +++-- emacs/notmuch-show.el | 18 +++--- emacs/rstdoc.el | 9 - test/test-lib.el| 31 +++ 6 files changed, 34

[PATCH 15/23] emacs: Use makefile-gmake-mode in Makefile*s

2020-07-26 Thread Jonas Bernoulli
Use `makefile-gmake-mode' instead of `makefile-mode' because the former also highlights ifdef et al. while the latter does not. "./Makefile.global" and one "Makefile.local" failed to specify any major mode at all but doing so is necessary because Emacs does not automatically figure out that these

[PATCH 12/23] emacs: Fix some function declarations

2020-07-26 Thread Jonas Bernoulli
--- emacs/notmuch-tag.el | 7 --- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/emacs/notmuch-tag.el b/emacs/notmuch-tag.el index e71de041..1cef17e1 100644 --- a/emacs/notmuch-tag.el +++ b/emacs/notmuch-tag.el @@ -32,9 +32,10 @@ (require 'crm) (require 'notmuch-lib)

[PATCH] lib: return NULL from n_d_get_default_indexopts on error

2020-07-26 Thread David Bremner
This is a rare and probably serious programming error, so better not to silently return a default value. --- lib/indexopts.c | 2 +- lib/notmuch.h | 1 + test/T562-lib-database.sh | 1 - 3 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/indexopts.c

[PATCH 0/3] Adjust test for changes in Emacs 27

2020-07-26 Thread Jonas Bernoulli
The first commit didn't do what the commit message claimed, as pointed out by David. I have fixed that, and also a second issue that I have missed because I still had some parts of 'mml-sec.el' commented out when testing the fixes to the tests... it was a long day. Jonas Bernoulli (3):

[PATCH 2/3] test: Deal with Emacs 27 switching to lexical scope by default

2020-07-26 Thread Jonas Bernoulli
Starting with Emacs 27 undeclared variables in evaluated interactive code uses lexical scope. This includes code passed with '--eval' as we do in the Emacs tests, which also happen to assume dynamic scope. This can affect variables defined by libraries that we use. We let- bind such variables

[PATCH 1/3] gitignore: Ignore generated sphinx.config

2020-07-26 Thread Jonas Bernoulli
--- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 1c8705ec..8f3ebec0 100644 --- a/.gitignore +++ b/.gitignore @@ -17,3 +17,4 @@ tags /.stamps *.stamp /bindings/python-cffi/build/ +/sphinx.config -- 2.26.0

[PATCH 3/3] test: Explicitly state that we want to sign with sender

2020-07-26 Thread Jonas Bernoulli
Since Emacs 27 'mml-secure-epg-sign' errors out if we don't opt-in to signing as the sender using 'mml-secure-openpgp-sign-with-sender'. --- test/test-lib.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/test-lib.sh b/test/test-lib.sh index 8c331b88..31c858d1 100644

[PATCH 3/3] lib: replace use of static_cast for writable databases

2020-07-26 Thread David Bremner
static_cast is a bit tricky to understand and error prone, so add a second pointer to (potentially the same) Xapian database object that we know has the right subclass. --- lib/add-message.cc | 13 +++-- lib/config.cc | 4 +--- lib/database-private.h | 2 +- lib/database.cc

[PATCH 2/3] lib: encapsulate the use of notmuch_database_t field 'mode'

2020-07-26 Thread David Bremner
The plan is to change the underlying representation. --- lib/database.cc | 18 -- lib/directory.cc | 2 +- lib/message.cc| 4 ++-- lib/notmuch-private.h | 3 +++ 4 files changed, 18 insertions(+), 9 deletions(-) diff --git a/lib/database.cc b/lib/database.cc

[PATCH 1/3] lib: drop two gratuitous assignments to database mode

2020-07-26 Thread David Bremner
I'm not sure what the point of modifying that right before destroying the object is. In a future commit I want to remove that element of the object, so simplify that task. --- lib/database.cc | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/database.cc b/lib/database.cc index

simplify handling of writable database modes

2020-07-26 Thread David Bremner
As the last commit message mentions, it is a bit hard to be sure one is using static_cast correctly, so this series eliminates the use of static_cast for Xapian database objects. As a bonus, it deletes more code than it adds. Based on a suggestion from Olly Betts.

[PATCH 2/2] lib: fix return value for n_directory_delete

2020-07-26 Thread David Bremner
Falling out of the catch meant the error return was lost --- lib/directory.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/directory.cc b/lib/directory.cc index 044cd680..37973c09 100644 --- a/lib/directory.cc +++ b/lib/directory.cc @@ -308,7 +308,7 @@

[PATCH 1/2] test: known broken test for n_directory_delete with closed db.

2020-07-26 Thread David Bremner
There is a return value bug in notmuch_directory_delete that is hiding the exception. --- Well that was embarrassing. Silly bug in notmuch code, nothing to do with Xapian. test/T563-lib-directory.sh | 38 +- 1 file changed, 37 insertions(+), 1 deletion(-)

Re: [PATCH 07/23] emacs: Use 'and' instead of 'when' when the return value matters

2020-07-26 Thread Sean Whitton
Hello, On Sun 26 Jul 2020 at 06:58PM +02, Jonas Bernoulli wrote: > Also do so for some 'if' forms that lack an ELSE part. > Even go as far as using 'and' and 'not' instead of 'unless'. I don't follow "when the return value matters", could you explain? Thanks. -- Sean Whitton

Re: [PATCH 07/23] emacs: Use 'and' instead of 'when' when the return value matters

2020-07-26 Thread Jonas Bernoulli
Sean Whitton writes: > On Sun 26 Jul 2020 at 06:58PM +02, Jonas Bernoulli wrote: > >> Also do so for some 'if' forms that lack an ELSE part. >> Even go as far as using 'and' and 'not' instead of 'unless'. > > I don't follow "when the return value matters", could you explain? As in "when the

Re: Trying to troubleshoot header index…

2020-07-26 Thread Sandra Snan
That is fantastic!♥ Yeah, I had written "headers" for both Blahonga and Xspam. To get the fixed version to work, I had to remove them from ~/.notmuch-config (not just edit them) and then re-add them via the CLI instead of by editing the file. But now works like a charm! David Bremner writes: