[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 @@ notmuch_directory_get_child_directories 
(notmuch_directory_t *directory)
 notmuch_status_t
 notmuch_directory_delete (notmuch_directory_t *directory)
 {
-notmuch_status_t status;
+notmuch_status_t status = NOTMUCH_STATUS_SUCCESS;
 Xapian::WritableDatabase *db;
 
 status = _notmuch_database_ensure_writable (directory->notmuch);
@@ -327,7 +327,7 @@ notmuch_directory_delete (notmuch_directory_t *directory)
 }
 notmuch_directory_destroy (directory);
 
-return NOTMUCH_STATUS_SUCCESS;
+return status;
 }
 
 void
-- 
2.27.0
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[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(-)

diff --git a/test/T563-lib-directory.sh b/test/T563-lib-directory.sh
index 739469a6..8777f62b 100755
--- a/test/T563-lib-directory.sh
+++ b/test/T563-lib-directory.sh
@@ -26,7 +26,7 @@ int main (int argc, char** argv)
  exit (1);
}
 
-   EXPECT0(notmuch_database_get_directory (db, "", ));
+   EXPECT0(notmuch_database_get_directory (db, "bar", ));
EXPECT0(notmuch_database_close (db));
 EOF
 
@@ -74,4 +74,40 @@ A Xapian exception occurred at lib/directory.cc:XXX: 
Database has been closed
 EOF
 test_expect_equal_file EXPECTED OUTPUT
 
+backup_database
+test_begin_subtest "delete directory document for a closed db"
+test_subtest_known_broken
+cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR}
+{
+stat = notmuch_directory_delete (dir);
+printf ("%d\n", stat == NOTMUCH_STATUS_XAPIAN_EXCEPTION);
+}
+EOF
+cat < EXPECTED
+== stdout ==
+1
+== stderr ==
+A Xapian exception occurred deleting directory entry: Database has been closed.
+EOF
+test_expect_equal_file EXPECTED OUTPUT
+restore_database
+
+backup_database
+test_begin_subtest "get/set mtime of directory for a closed db"
+cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR}
+{
+time_t stamp = notmuch_directory_get_mtime (dir);
+stat = notmuch_directory_set_mtime (dir, stamp);
+printf ("%d\n", stat == NOTMUCH_STATUS_XAPIAN_EXCEPTION);
+}
+EOF
+cat < EXPECTED
+== stdout ==
+1
+== stderr ==
+A Xapian exception occurred setting directory mtime: Database has been closed.
+EOF
+test_expect_equal_file EXPECTED OUTPUT
+restore_database
+
 test_done
-- 
2.27.0
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[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 2aff56be..b987cb42 100644
--- a/lib/database.cc
+++ b/lib/database.cc
@@ -994,7 +994,6 @@ notmuch_database_open_verbose (const char *path,
 "   has a newer database format 
version (%u) than supported by this\n"
 "   version of notmuch (%u).\n",
 notmuch_path, version, 
NOTMUCH_DATABASE_VERSION));
-   notmuch->mode = NOTMUCH_DATABASE_MODE_READ_ONLY;
notmuch_database_destroy (notmuch);
notmuch = NULL;
status = NOTMUCH_STATUS_FILE_ERROR;
@@ -1013,7 +1012,6 @@ notmuch_database_open_verbose (const char *path,
 "   requires features (%s)\n"
 "   not supported by this version of 
notmuch.\n",
 notmuch_path, incompat_features));
-   notmuch->mode = NOTMUCH_DATABASE_MODE_READ_ONLY;
notmuch_database_destroy (notmuch);
notmuch = NULL;
status = NOTMUCH_STATUS_FILE_ERROR;
-- 
2.27.0
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


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.


___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[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| 21 -
 lib/directory.cc   | 18 +++---
 lib/message.cc | 10 +++---
 6 files changed, 27 insertions(+), 41 deletions(-)

diff --git a/lib/add-message.cc b/lib/add-message.cc
index 9dd4b697..485debad 100644
--- a/lib/add-message.cc
+++ b/lib/add-message.cc
@@ -43,15 +43,12 @@ _notmuch_database_generate_thread_id (notmuch_database_t 
*notmuch)
 /* 16 bytes (+ terminator) for hexadecimal representation of
  * a 64-bit integer. */
 static char thread_id[17];
-Xapian::WritableDatabase *db;
-
-db = static_cast  (notmuch->xapian_db);
 
 notmuch->last_thread_id++;
 
 sprintf (thread_id, "%016" PRIx64, notmuch->last_thread_id);
 
-db->set_metadata ("last_thread_id", thread_id);
+notmuch->writable_xapian_db->set_metadata ("last_thread_id", thread_id);
 
 return thread_id;
 }
@@ -161,7 +158,7 @@ _resolve_message_id_to_thread_id_old (notmuch_database_t 
*notmuch,
  * can return the thread ID stored in the metadata. Otherwise, we
  * generate a new thread ID and store it there.
  */
-db = static_cast  (notmuch->xapian_db);
+db = notmuch->writable_xapian_db;
 metadata_key = _get_metadata_thread_id_key (ctx, message_id);
 thread_id_string = notmuch->xapian_db->get_metadata (metadata_key);
 
@@ -370,13 +367,9 @@ _consume_metadata_thread_id (void *ctx, notmuch_database_t 
*notmuch,
 if (stored_id.empty ()) {
return NULL;
 } else {
-   Xapian::WritableDatabase *db;
-
-   db = static_cast  (notmuch->xapian_db);
-
/* Clear the metadata for this message ID. We don't need it
 * anymore. */
-   db->set_metadata (metadata_key, "");
+   notmuch->writable_xapian_db->set_metadata (metadata_key, "");
 
return talloc_strdup (ctx, stored_id.c_str ());
 }
diff --git a/lib/config.cc b/lib/config.cc
index 20036471..dae0ff0e 100644
--- a/lib/config.cc
+++ b/lib/config.cc
@@ -45,15 +45,13 @@ notmuch_database_set_config (notmuch_database_t *notmuch,
 const char *value)
 {
 notmuch_status_t status;
-Xapian::WritableDatabase *db;
 
 status = _notmuch_database_ensure_writable (notmuch);
 if (status)
return status;
 
 try {
-   db = static_cast  (notmuch->xapian_db);
-   db->set_metadata (CONFIG_PREFIX + key, value);
+   notmuch->writable_xapian_db->set_metadata (CONFIG_PREFIX + key, value);
 } catch (const Xapian::Error ) {
status = NOTMUCH_STATUS_XAPIAN_EXCEPTION;
notmuch->exception_reported = true;
diff --git a/lib/database-private.h b/lib/database-private.h
index d2c25313..041602cd 100644
--- a/lib/database-private.h
+++ b/lib/database-private.h
@@ -189,11 +189,11 @@ struct _notmuch_database {
 
 char *path;
 
-notmuch_database_mode_t mode;
 int atomic_nesting;
 /* true if changes have been made in this atomic section */
 bool atomic_dirty;
 Xapian::Database *xapian_db;
+Xapian::WritableDatabase *writable_xapian_db;
 bool open;
 /* Bit mask of features used by this database.  This is a
  * bitwise-OR of NOTMUCH_FEATURE_* values (above). */
diff --git a/lib/database.cc b/lib/database.cc
index 08278235..75189685 100644
--- a/lib/database.cc
+++ b/lib/database.cc
@@ -72,7 +72,10 @@ _log_xapian_exception (const char *where, notmuch_database_t 
*notmuch,  const Xa
 notmuch_database_mode_t
 _notmuch_database_mode (notmuch_database_t *notmuch)
 {
-return notmuch->mode;
+if (notmuch->writable_xapian_db)
+   return NOTMUCH_DATABASE_MODE_READ_WRITE;
+else
+   return NOTMUCH_DATABASE_MODE_READ_ONLY;
 }
 
 /* Here's the current schema for our database (for NOTMUCH_DATABASE_VERSION):
@@ -976,7 +979,7 @@ notmuch_database_open_verbose (const char *path,
 
 strip_trailing (notmuch->path, '/');
 
-notmuch->mode = mode;
+notmuch->writable_xapian_db = NULL;
 notmuch->atomic_nesting = 0;
 notmuch->view = 1;
 try {
@@ -984,8 +987,9 @@ notmuch_database_open_verbose (const char *path,
string last_mod;
 
if (mode == NOTMUCH_DATABASE_MODE_READ_WRITE) {
-   notmuch->xapian_db = new Xapian::WritableDatabase (xapian_path,
-  DB_ACTION);
+   notmuch->writable_xapian_db = new Xapian::WritableDatabase 
(xapian_path,
+   
DB_ACTION);
+   notmuch->xapian_db = notmuch->writable_xapian_db;
} else {
notmuch->xapian_db = new Xapian::Database (xapian_path);
}
@@ -1115,8 +1119,7 @@ notmuch_database_close (notmuch_database_t *notmuch)
 

[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
index b987cb42..08278235 100644
--- a/lib/database.cc
+++ b/lib/database.cc
@@ -69,6 +69,12 @@ _log_xapian_exception (const char *where, notmuch_database_t 
*notmuch,  const Xa
 notmuch->exception_reported = true;
 }
 
+notmuch_database_mode_t
+_notmuch_database_mode (notmuch_database_t *notmuch)
+{
+return notmuch->mode;
+}
+
 /* Here's the current schema for our database (for NOTMUCH_DATABASE_VERSION):
  *
  * We currently have three different types of documents (mail, ghost,
@@ -783,7 +789,7 @@ notmuch_database_create_verbose (const char *path,
 notmuch_status_t
 _notmuch_database_ensure_writable (notmuch_database_t *notmuch)
 {
-if (notmuch->mode == NOTMUCH_DATABASE_MODE_READ_ONLY) {
+if (_notmuch_database_mode (notmuch) == NOTMUCH_DATABASE_MODE_READ_ONLY) {
_notmuch_database_log (notmuch, "Cannot write to a read-only 
database.\n");
return NOTMUCH_STATUS_READ_ONLY_DATABASE;
 }
@@ -1107,7 +1113,7 @@ notmuch_database_close (notmuch_database_t *notmuch)
 * that transaction, or may discard committed (but
 * unflushed) transactions.  To be certain, explicitly
 * cancel any outstanding transaction before closing. */
-   if (notmuch->mode == NOTMUCH_DATABASE_MODE_READ_WRITE &&
+   if (_notmuch_database_mode (notmuch) == 
NOTMUCH_DATABASE_MODE_READ_WRITE &&
notmuch->atomic_nesting)
(static_cast  (notmuch->xapian_db))
->cancel_transaction ();
@@ -1130,7 +1136,7 @@ notmuch_database_close (notmuch_database_t *notmuch)
 notmuch_status_t
 _notmuch_database_reopen (notmuch_database_t *notmuch)
 {
-if (notmuch->mode != NOTMUCH_DATABASE_MODE_READ_ONLY)
+if (_notmuch_database_mode (notmuch) != NOTMUCH_DATABASE_MODE_READ_ONLY)
return NOTMUCH_STATUS_UNSUPPORTED_OPERATION;
 
 try {
@@ -1395,7 +1401,7 @@ notmuch_database_needs_upgrade (notmuch_database_t 
*notmuch)
 {
 unsigned int version;
 
-if (notmuch->mode != NOTMUCH_DATABASE_MODE_READ_WRITE)
+if (_notmuch_database_mode (notmuch) != NOTMUCH_DATABASE_MODE_READ_WRITE)
return FALSE;
 
 if (NOTMUCH_FEATURES_CURRENT & ~notmuch->features)
@@ -1697,7 +1703,7 @@ notmuch_database_upgrade (notmuch_database_t *notmuch,
 notmuch_status_t
 notmuch_database_begin_atomic (notmuch_database_t *notmuch)
 {
-if (notmuch->mode == NOTMUCH_DATABASE_MODE_READ_ONLY ||
+if (_notmuch_database_mode (notmuch) == NOTMUCH_DATABASE_MODE_READ_ONLY ||
notmuch->atomic_nesting > 0)
goto DONE;
 
@@ -1726,7 +1732,7 @@ notmuch_database_end_atomic (notmuch_database_t *notmuch)
 if (notmuch->atomic_nesting == 0)
return NOTMUCH_STATUS_UNBALANCED_ATOMIC;
 
-if (notmuch->mode == NOTMUCH_DATABASE_MODE_READ_ONLY ||
+if (_notmuch_database_mode (notmuch) == NOTMUCH_DATABASE_MODE_READ_ONLY ||
notmuch->atomic_nesting > 1)
goto DONE;
 
diff --git a/lib/directory.cc b/lib/directory.cc
index 044cd680..9ad66e82 100644
--- a/lib/directory.cc
+++ b/lib/directory.cc
@@ -127,7 +127,7 @@ _notmuch_directory_find_or_create (notmuch_database_t 
*notmuch,
 
 path = _notmuch_database_relative_path (notmuch, path);
 
-if (create && notmuch->mode == NOTMUCH_DATABASE_MODE_READ_ONLY)
+if (create && _notmuch_database_mode (notmuch) == 
NOTMUCH_DATABASE_MODE_READ_ONLY)
INTERNAL_ERROR ("Failure to ensure database is writable");
 
 directory = talloc (notmuch, notmuch_directory_t);
diff --git a/lib/message.cc b/lib/message.cc
index 64798413..d23e64ab 100644
--- a/lib/message.cc
+++ b/lib/message.cc
@@ -275,7 +275,7 @@ _notmuch_message_create_for_message_id (notmuch_database_t 
*notmuch,
return NULL;
 }
 
-if (notmuch->mode == NOTMUCH_DATABASE_MODE_READ_ONLY)
+if (_notmuch_database_mode (notmuch) == NOTMUCH_DATABASE_MODE_READ_ONLY)
INTERNAL_ERROR ("Failure to ensure database is writable.");
 
 try {
@@ -1324,7 +1324,7 @@ _notmuch_message_sync (notmuch_message_t *message)
 {
 Xapian::WritableDatabase *db;
 
-if (message->notmuch->mode == NOTMUCH_DATABASE_MODE_READ_ONLY)
+if (_notmuch_database_mode (message->notmuch) == 
NOTMUCH_DATABASE_MODE_READ_ONLY)
return;
 
 if (! message->modified)
diff --git a/lib/notmuch-private.h b/lib/notmuch-private.h
index 2293..57ec7f72 100644
--- a/lib/notmuch-private.h
+++ b/lib/notmuch-private.h
@@ -259,6 +259,9 @@ _notmuch_directory_find_or_create (notmuch_database_t 
*notmuch,
 unsigned int
 _notmuch_directory_get_document_id (notmuch_directory_t *directory);
 
+notmuch_database_mode_t
+_notmuch_database_mode (notmuch_database_t *notmuch);
+
 /* message.cc */
 
 notmuch_message_t *
-- 
2.27.0

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 caller consumes the returned value".  The alternative
would be for the caller to not care about the value returned by the
callee and to instead call it for the side-effects only.

By using `and' we can signal that care about the return value and by
using `when' that we care about the side-effects instead.
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


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
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[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
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[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
--- a/test/test-lib.sh
+++ b/test/test-lib.sh
@@ -414,7 +414,9 @@ emacs_fcc_message ()
   (message-goto-body)
   (insert \"${body}\")
   $*
-  (notmuch-mua-send-and-exit))" || return 1
+  (let ((mml-secure-smime-sign-with-sender t)
+(mml-secure-openpgp-sign-with-sender t))
+(notmuch-mua-send-and-exit)))" || return 1
 notmuch new $nmn_args >/dev/null
 }
 
-- 
2.26.0
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[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):
  gitignore: Ignore generated sphinx.config
  test: Deal with Emacs 27 switching to lexical scope by default
  test: Explicitly state that we want to sign with sender

 .gitignore   | 1 +
 test/test-lib.el | 9 +
 test/test-lib.sh | 4 +++-
 3 files changed, 13 insertions(+), 1 deletion(-)

-- 
2.26.0
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[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 to change the behavior of functions which we then
call with these bindings in effect.  If these libraries are not loaded
beforehand, then the bindings are lexical and fail to have the effect
we intended.

At this time only 'smtpmail' has to be loaded explicitly (for the
variables let-bound in emacs_deliver_message and emacs_fcc_message).

'message' doesn't have to be loaded explicitly, because loading
'notmuch' (in 'run_emacs') already takes care of that, indirectly.

Our own testing-only variables also have to be declared explicitly.
We should have done that anyway, but because of how and where these
variables are used it was very easy to overlook that (i.e. it isn't
something the byte-compiler ever looks at).  Not so in Emacs 27
anymore; here this oversight caused four tests to fail.
---
 test/test-lib.el | 9 +
 1 file changed, 9 insertions(+)

diff --git a/test/test-lib.el b/test/test-lib.el
index b47b388e..579a20d5 100644
--- a/test/test-lib.el
+++ b/test/test-lib.el
@@ -22,6 +22,12 @@
 
 (require 'cl-lib)
 
+;; Ensure that the dynamic variables that are defined by this library
+;; are defined by the time that we let-bind them.  This is needed
+;; because starting with Emacs 27 undeclared variables in evaluated
+;; interactive code (such as our tests) use lexical scope.
+(require 'smtpmail)
+
 ;; `read-file-name' by default uses `completing-read' function to read
 ;; user input.  It does not respect `standard-input' variable which we
 ;; use in tests to provide user input.  So replace it with a plain
@@ -113,6 +119,9 @@ (defun add-hook-counter (hook)
 (add-hook-counter 'notmuch-hello-mode-hook)
 (add-hook-counter 'notmuch-hello-refresh-hook)
 
+(defvar notmuch-hello-mode-hook-counter -100)
+(defvar notmuch-hello-refresh-hook-counter -100)
+
 (defadvice notmuch-search-process-filter (around pessimal activate disable)
   "Feed notmuch-search-process-filter one character at a time."
   (let ((string (ad-get-arg 1)))
-- 
2.26.0
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[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 ++--
 bindings/python-cffi/notmuch2/_tags.py |  8 
 bindings/python-cffi/tests/conftest.py |  2 +-
 bindings/python/notmuch/database.py| 12 ++--
 bindings/python/notmuch/query.py   |  2 +-
 emacs/notmuch-crypto.el|  2 +-
 emacs/notmuch-lib.el   |  2 +-
 emacs/notmuch-mua.el   |  2 +-
 lib/notmuch.h  |  4 ++--
 tag-util.c |  2 +-
 tag-util.h |  2 +-
 test/T610-message-property.sh  |  2 +-
 test/T710-message-id.sh|  2 +-
 test/random-corpus.c   |  2 +-
 test/test-lib.el   |  2 +-
 19 files changed, 34 insertions(+), 34 deletions(-)

diff --git a/NEWS b/NEWS
index 0d8b930f..9f0db031 100644
--- a/NEWS
+++ b/NEWS
@@ -116,7 +116,7 @@ information about cryptographic protections for the Subject 
header.
 Emacs
 -
 
-Optionally check for missing attachements in outgoing messages (see
+Optionally check for missing attachments in outgoing messages (see
 function `notmuch-mua-attachment-check`).
 
 Bind `B` to browse URLs in current message.
diff --git a/bindings/python-cffi/notmuch2/__init__.py 
b/bindings/python-cffi/notmuch2/__init__.py
index 613317e0..f281edc1 100644
--- a/bindings/python-cffi/notmuch2/__init__.py
+++ b/bindings/python-cffi/notmuch2/__init__.py
@@ -10,7 +10,7 @@ should consider their signatures implementation details.
 Errors
 ==
 
-All errors occuring due to errors from the underlying notmuch database
+All errors occurring due to errors from the underlying notmuch database
 are subclasses of the :exc:`NotmuchError`.  Due to memory management
 it is possible to try and use an object after it has been freed.  In
 this case a :exc:`ObjectDestroyedError` will be raised.
diff --git a/bindings/python-cffi/notmuch2/_base.py 
b/bindings/python-cffi/notmuch2/_base.py
index 31258149..1cf03c88 100644
--- a/bindings/python-cffi/notmuch2/_base.py
+++ b/bindings/python-cffi/notmuch2/_base.py
@@ -29,7 +29,7 @@ class NotmuchObject(metaclass=abc.ABCMeta):
 However during some peculiar situations, e.g. interpreter
 shutdown, it is possible for the :meth:`__del__` method to have
 been called, whele there are still references to an object.  This
-could result in child objects asking their memeory to be freed
+could result in child objects asking their memory to be freed
 after the parent has already freed the memory, making things
 rather unhappy as double frees are not taken lightly in C.  To
 handle this case all objects need to follow the same protocol to
@@ -73,7 +73,7 @@ class NotmuchObject(metaclass=abc.ABCMeta):
 def _destroy(self):
 """Destroy the object, freeing all memory.
 
-This method needs to destory the object on the
+This method needs to destroy the object on the
 libnotmuch-level.  It must ensure it's not been destroyed by
 it's parent object yet before doing so.  It also must be
 idempotent.
@@ -134,7 +134,7 @@ class BinString(str):
 
 Most data in libnotmuch should be valid ASCII or valid UTF-8.
 However since it is a C library these are represented as
-bytestrings intead which means on an API level we can not
+bytestrings instead which means on an API level we can not
 guarantee that decoding this to UTF-8 will both succeed and be
 lossless.  This string type converts bytes to unicode in a lossy
 way, but also makes the raw bytes available.
diff --git a/bindings/python-cffi/notmuch2/_database.py 
b/bindings/python-cffi/notmuch2/_database.py
index 7db5a7f8..5ab0f20a 100644
--- a/bindings/python-cffi/notmuch2/_database.py
+++ b/bindings/python-cffi/notmuch2/_database.py
@@ -422,7 +422,7 @@ class Database(base.NotmuchObject):
of it as ``dup = db.remove_message(name); if dup: ...``.
 :rtype: bool
 
-:raises XapianError: A Xapian exception ocurred.
+:raises XapianError: A Xapian exception occurred.
 :raises ReadOnlyDatabaseError: The database is opened in
READ_ONLY mode.
 :raises UpgradeRequiredError: The database must be upgraded
@@ -458,7 +458,7 @@ class Database(base.NotmuchObject):
 :raises LookupError: If no message was found.
 :raises OutOfMemoryError: When there is no memory to allocate
the message instance.
-:raises XapianError: A Xapian exception ocurred.
+:raises XapianError: A Xapian exception occurred.
 :raises ObjectDestroyedError: if used after destroyed.
 """
 msg_pp = capi.ffi.new('notmuch_message_t **')
@@ 

[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
+++ b/test/test-lib.sh
@@ -136,16 +136,16 @@ add_gpgsm_home ()
 at_exit_function _gnupg_exit
 mkdir -p -m 0700 "$GNUPGHOME"
 openssl pkcs12 -export -passout pass: -inkey 
"$NOTMUCH_SRCDIR/test/smime/key+cert.pem" \
-< "$NOTMUCH_SRCDIR/test/smime/test.crt" | \
-gpgsm --batch --no-tty --no-common-certs-import 
--pinentry-mode=loopback --passphrase-fd 3 \
-  --disable-dirmngr --import  >"$GNUPGHOME"/import.log 2>&1 3<<<''
+   < "$NOTMUCH_SRCDIR/test/smime/test.crt" | \
+   gpgsm --batch --no-tty --no-common-certs-import 
--pinentry-mode=loopback --passphrase-fd 3 \
+ --disable-dirmngr --import  >"$GNUPGHOME"/import.log 2>&1 3<<<''
 fpr=$(gpgsm --batch --list-key test_su...@notmuchmail.org | sed -n 
's/.*fingerprint: //p')
 echo "$fpr S relax" >> "$GNUPGHOME/trustlist.txt"
 gpgsm --quiet --batch --no-tty --no-common-certs-import --disable-dirmngr 
--import < $NOTMUCH_SRCDIR/test/smime/ca.crt
 echo "4D:E0:FF:63:C0:E9:EC:01:29:11:C8:7A:EE:DA:3A:9A:7F:6E:C1:0D S" >> 
"$GNUPGHOME/trustlist.txt"
 printf '%s::1\n' include-certs disable-crl-checks | gpgconf --output 
/dev/null --change-options gpgsm
 gpgsm --batch --no-tty --no-common-certs-import --pinentry-mode=loopback 
--passphrase-fd 3 \
-  --disable-dirmngr --import "$NOTMUCH_SRCDIR/test/smime/bob.p12" 
>>"$GNUPGHOME"/import.log 2>&1 3<<<''
+ --disable-dirmngr --import "$NOTMUCH_SRCDIR/test/smime/bob.p12" 
>>"$GNUPGHOME"/import.log 2>&1 3<<<''
 test_debug "cat $GNUPGHOME/import.log"
 }
 
@@ -394,8 +394,8 @@ emacs_fcc_message ()
 local nmn_args subject body
 nmn_args=''
 while [[ "$1" =~ ^-- ]]; do
-nmn_args="$nmn_args $1"
-shift
+   nmn_args="$nmn_args $1"
+   shift
 done
 subject="$1"
 body="$2"
@@ -405,7 +405,7 @@ emacs_fcc_message ()
 
 test_emacs \
"(let ((message-send-mail-function (lambda () t))
-   (mail-host-address \"example.com\"))
+  (mail-host-address \"example.com\"))
   (notmuch-mua-mail)
   (message-goto-to)
   (insert \"test_su...@notmuchmail.org\nDate: 01 Jan 2000 12:00:00 
-\")
@@ -523,9 +523,9 @@ test_expect_equal_json () {
 # override Python's stdio encoding defaults.
 script='import json, sys; json.dump(json.load(sys.stdin), sys.stdout, 
sort_keys=True, indent=4)'
 output=$(echo "$1" | PYTHONIOENCODING=utf-8 $NOTMUCH_PYTHON -c "$script" \
-|| echo "$1")
+   || echo "$1")
 expected=$(echo "$2" | PYTHONIOENCODING=utf-8 $NOTMUCH_PYTHON -c "$script" 
\
-|| echo "$2")
+   || echo "$2")
 shift 2
 test_expect_equal "$output" "$expected" "$@"
 }
@@ -539,15 +539,15 @@ test_valid_json () {
 # Sort the top-level list of JSON data from stdin.
 test_sort_json () {
 PYTHONIOENCODING=utf-8 $NOTMUCH_PYTHON -c \
-"import sys, json; json.dump(sorted(json.load(sys.stdin)),sys.stdout)"
+   "import sys, json; json.dump(sorted(json.load(sys.stdin)),sys.stdout)"
 }
 
 # test for json objects:
 # read the source of test/json_check_nodes.py (or the output when
 # invoking it without arguments) for an explanation of the syntax.
 test_json_nodes () {
-local output
-exec 1>&6 2>&7 # Restore stdout and stderr
+   local output
+   exec 1>&6 2>&7  # Restore stdout and stderr
if [ -z "$inside_subtest" ]; then
error "bug in the test script: test_json_eval without 
test_begin_subtest"
fi
@@ -661,7 +661,7 @@ notmuch_json_show_sanitize ()
-e 's|"filename": "signature.asc",||g' \
-e 's|"filename": \["/[^"]*"\],|"filename": \["Y"\],|g' \
-e 's|"timestamp": 97...|"timestamp": 42|g' \
--e 's|"content-length": [1-9][0-9]*|"content-length": "NONZERO"|g'
+   -e 's|"content-length": [1-9][0-9]*|"content-length": "NONZERO"|g'
 }
 
 notmuch_emacs_error_sanitize ()
@@ -672,7 +672,7 @@ notmuch_emacs_error_sanitize ()
 for file in "$@"; do
echo "=== $file ==="
cat "$file"
-done | sed  \
+done | sed \
-e 's/^\[.*\]$/[XXX]/' \
-e "s|^\(command: \)\{0,1\}/.*/$command|\1YYY/$command|"
 }
@@ -928,8 +928,8 @@ test_expect_code () {
 # but is a prefix that can be used in the test script, like:
 #
 #  test_expect_success 'complain and die' '
-#   do something &&
-#   do something else &&
+#  do something &&
+#  do something else &&
 #  test_must_fail git checkout ../outerspace
 #  '
 #
@@ -1019,8 +1019,8 @@ export NOTMUCH_CONFIG=$NOTMUCH_CONFIG
 
 # Here's what we are using here:
 #
-# --quick  Use 

[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 insertions(+), 44 deletions(-)

diff --git a/emacs/make-deps.el b/emacs/make-deps.el
index dcac319c..91f4ef3d 100644
--- a/emacs/make-deps.el
+++ b/emacs/make-deps.el
@@ -36,7 +36,8 @@ (defun make-deps ( dir)
 This prints make dependencies to `standard-output' based on the
 top-level `require' expressions in the current buffer.  Paths in
 rules will be given relative to DIR, or `default-directory'."
-  (setq dir (or dir default-directory))
+  (unless dir
+(setq dir default-directory))
   (save-excursion
 (goto-char (point-min))
 (condition-case nil
diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index 549161f3..a057140f 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -53,9 +53,8 @@ (defgroup notmuch-show nil
 
 (defgroup notmuch-send nil
   "Sending messages from Notmuch."
-  :group 'notmuch)
-
-(custom-add-to-group 'notmuch-send 'message 'custom-group)
+  :group 'notmuch
+  :group 'message)
 
 (defgroup notmuch-tag nil
   "Tags and tagging in Notmuch."
@@ -782,8 +781,7 @@ (defun notmuch-logged-error (msg  extra)
(insert extra)
(unless (bolp)
  (newline)
-  (error "%s"
-(concat msg (and extra " (see *Notmuch errors* for more details)"
+  (error "%s%s" msg (if extra " (see *Notmuch errors* for more details)" "")))
 
 (defun notmuch-check-async-exit-status (proc msg  command err)
   "If PROC exited abnormally, pop up an error buffer and signal an error.
diff --git a/emacs/notmuch-parser.el b/emacs/notmuch-parser.el
index fbcfc2ef..3aa5bd8f 100644
--- a/emacs/notmuch-parser.el
+++ b/emacs/notmuch-parser.el
@@ -39,12 +39,9 @@ (defun notmuch-sexp-create-parser ()
 buffer.  Hence, the caller is allowed to delete any data before
 point and may resynchronize after an error by moving point."
   (vector 'notmuch-sexp-parser
- ;; List depth
- 0
- ;; Partial parse position marker
- nil
- ;; Partial parse state
- nil))
+ 0 ; List depth
+ nil   ; Partial parse position marker
+ nil)) ; Partial parse state
 
 (defmacro notmuch-sexp--depth (sp) `(aref ,sp 1))
 (defmacro notmuch-sexp--partial-pos (sp)   `(aref ,sp 2))
diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 015edb0c..5640346f 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -499,21 +499,17 @@ (define-button-type 'notmuch-show-part-button-type
 
 (defun notmuch-show-insert-part-header (nth content-type declared-type
 name comment)
-  (let ((button)
-   (base-label (concat (and name (concat name ": "))
+  (let ((base-label (concat (and name (concat name ": "))
declared-type
(and (not (string-equal declared-type content-type))
 (concat " (as " content-type ")"))
comment)))
-(setq button
- (insert-button
-  (concat "[ " base-label " ]")
-  :base-label base-label
-  :type 'notmuch-show-part-button-type
-  :notmuch-part-hidden nil))
-(insert "\n")
-;; return button
-button))
+(prog1 (insert-button
+   (concat "[ " base-label " ]")
+   :base-label base-label
+   :type 'notmuch-show-part-button-type
+   :notmuch-part-hidden nil)
+  (insert "\n"
 
 (defun notmuch-show-toggle-part-invisibility ( button)
   (interactive)
diff --git a/emacs/rstdoc.el b/emacs/rstdoc.el
index 92a337c8..41390bbe 100644
--- a/emacs/rstdoc.el
+++ b/emacs/rstdoc.el
@@ -24,7 +24,6 @@
 ;;
 
 ;;; Commentary:
-;;
 
 ;; Rstdoc provides a facility to extract all of the docstrings defined in
 ;; an elisp source file. Usage:
@@ -68,10 +67,10 @@ (defun rstdoc--insert-docstring (symbol docstring)
   (insert "\n"))
 
 (defvar rst--escape-alist
-  '( ("='" . "'")
- ("\\([^\\]\\)'" . "\\1`")
- ("^[[:space:]\t]*$" . "|br|")
- ("^[[:space:]\t]" . "|indent| "))
+  '(("='" . "'")
+("\\([^\\]\\)'" . "\\1`")
+("^[[:space:]\t]*$" . "|br|")
+("^[[:space:]\t]" . "|indent| "))
   "List of (regex . replacement) pairs.")
 
 (defun rstdoc--rst-quote-string (str)
diff --git a/test/test-lib.el b/test/test-lib.el
index 680a02ad..db31fac3 100644
--- a/test/test-lib.el
+++ b/test/test-lib.el
@@ -162,22 +162,21 @@ (defun notmuch-test-report-unexpected (output expected)
 
 (defun notmuch-test-expect-equal (output expected)
   "Compare OUTPUT with EXPECTED. Report any discrepencies."
-  (if (equal output expected)
-  t
-(cond
- ((and (listp output)
-  (listp expected))
-  ;; Reporting the difference between two lists is done by
-  

[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
+++ b/emacs/notmuch-lib.el
@@ -259,11 +259,13 @@ (defun notmuch-poll ()
 Invokes `notmuch-poll-script', \"notmuch new\", or does nothing
 depending on the value of `notmuch-poll-script'."
   (interactive)
+  (message "Polling mail...")
   (if (stringp notmuch-poll-script)
   (unless (string= notmuch-poll-script "")
(unless (equal (call-process notmuch-poll-script nil nil) 0)
  (error "Notmuch: poll script `%s' failed!" notmuch-poll-script)))
-(notmuch-call-notmuch-process "new")))
+(notmuch-call-notmuch-process "new"))
+  (message "Polling mail...done"))
 
 (defun notmuch-bury-or-kill-this-buffer ()
   "Undisplay the current buffer.
-- 
2.26.0
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[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
--- a/.dir-locals.el
+++ b/.dir-locals.el
@@ -15,7 +15,7 @@ ((c-mode
  (emacs-lisp-mode
   (indent-tabs-mode . t)
   (tab-width . 8))
- (shell-mode
+ (sh-mode
   (indent-tabs-mode . t)
   (tab-width . 8)
   (sh-basic-offset . 4)
-- 
2.26.0
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[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 deletions(-)

diff --git a/emacs/notmuch-jump.el b/emacs/notmuch-jump.el
index e302fe00..1e2d0497 100644
--- a/emacs/notmuch-jump.el
+++ b/emacs/notmuch-jump.el
@@ -73,6 +73,7 @@ (defun notmuch-jump-search ()
 
 (defvar notmuch-jump--action nil)
 
+;;;###autoload
 (defun notmuch-jump (action-map prompt)
   "Interactively prompt for one of the keys in ACTION-MAP.
 
diff --git a/emacs/notmuch-tag.el b/emacs/notmuch-tag.el
index 1cef17e1..ccc1321f 100644
--- a/emacs/notmuch-tag.el
+++ b/emacs/notmuch-tag.el
@@ -36,8 +36,7 @@ (declare-function notmuch-search-tag "notmuch"
  (tag-changes  beg end only-matched))
 (declare-function notmuch-show-tag "notmuch-show" (tag-changes))
 (declare-function notmuch-tree-tag "notmuch-tree" (tag-changes))
-
-(autoload 'notmuch-jump "notmuch-jump")
+(declare-function notmuch-jump "notmuch-jump" (action-map prompt))
 
 (define-widget 'notmuch-tag-key-type 'list
   "A single key tagging binding."
-- 
2.26.0
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[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 this is especially true between a function's doc-string and
body because the doc-string is colored differently, which visually
already separates it quite sufficiently from the code that follows.
---
 emacs/make-deps.el   |  2 -
 emacs/notmuch-address.el |  2 -
 emacs/notmuch-crypto.el  |  4 --
 emacs/notmuch-hello.el   | 18 -
 emacs/notmuch-jump.el|  5 ---
 emacs/notmuch-lib.el | 10 -
 emacs/notmuch-maildir-fcc.el |  7 
 emacs/notmuch-mua.el | 26 -
 emacs/notmuch-parser.el  |  5 ---
 emacs/notmuch-show.el| 75 ++--
 emacs/notmuch-tag.el |  3 --
 emacs/notmuch-tree.el|  9 -
 emacs/notmuch-wash.el| 18 +
 emacs/notmuch.el |  7 
 14 files changed, 5 insertions(+), 186 deletions(-)

diff --git a/emacs/make-deps.el b/emacs/make-deps.el
index 5b6db698..dcac319c 100644
--- a/emacs/make-deps.el
+++ b/emacs/make-deps.el
@@ -23,7 +23,6 @@
 
 (defun batch-make-deps ()
   "Invoke `make-deps' for each file on the command line."
-
   (setq debug-on-error t)
   (dolist (file command-line-args-left)
 (let ((default-directory command-line-default-directory))
@@ -37,7 +36,6 @@ (defun make-deps ( dir)
 This prints make dependencies to `standard-output' based on the
 top-level `require' expressions in the current buffer.  Paths in
 rules will be given relative to DIR, or `default-directory'."
-
   (setq dir (or dir default-directory))
   (save-excursion
 (goto-char (point-min))
diff --git a/emacs/notmuch-address.el b/emacs/notmuch-address.el
index 2a9c411a..ca4da3f3 100644
--- a/emacs/notmuch-address.el
+++ b/emacs/notmuch-address.el
@@ -302,7 +302,6 @@ (defun notmuch-address-harvest ( addr-prefix 
synchronous callback)
 Address harvesting may take some time so the address collection runs
 asynchronously unless SYNCHRONOUS is t. In case of asynchronous
 execution, CALLBACK is called when harvesting finishes."
-
   (let* ((sent (eq (car notmuch-address-internal-completion) 'sent))
 (config-query (cadr notmuch-address-internal-completion))
 (prefix-query (when addr-prefix
@@ -335,7 +334,6 @@ (defun notmuch-address-harvest ( addr-prefix 
synchronous callback)
;; Kill any existing process
(when current-proc
  (kill-buffer (process-buffer current-proc))) ; this also kills the 
process
-
(setq current-proc
  (apply 'notmuch-start-notmuch proc-name proc-buf
 callback   ; process sentinel
diff --git a/emacs/notmuch-crypto.el b/emacs/notmuch-crypto.el
index 2327ff1f..58947a20 100644
--- a/emacs/notmuch-crypto.el
+++ b/emacs/notmuch-crypto.el
@@ -123,17 +123,14 @@ (defun notmuch-crypto-insert-sigstatus-button (sigstatus 
from)
face 'notmuch-crypto-signature-good-key))
(setq button-action 'notmuch-crypto-sigstatus-good-callback
  help-msg (concat "Click to list key ID 0x" fingerprint "."
-
  ((string= status "error")
   (setq label (concat "Unknown key ID " keyid " or unsupported algorithm")
button-action 'notmuch-crypto-sigstatus-error-callback
help-msg (concat "Click to retrieve key ID " keyid
 " from keyserver.")))
-
  ((string= status "bad")
   (setq label (concat "Bad signature (claimed key ID " keyid ")")
face 'notmuch-crypto-signature-bad))
-
  (status
   (setq label (concat "Unknown signature status: " status)))
  (t
@@ -232,7 +229,6 @@ (defun notmuch-crypto-sigstatus-error-callback (button)
(process-put p :notmuch-show-buffer (current-buffer))
(process-put p :notmuch-show-point (point))
(message "Getting the GPG key %s asynchronously..." keyid)))
-
   (let ((window (display-buffer buffer)))
(with-selected-window window
  (with-current-buffer buffer
diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index 11c625ea..e71e55f3 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -150,7 +150,6 @@ (defcustom notmuch-saved-searches
 ;; The saved-search format is also used by the all-tags notmuch-hello
 ;; section. This section generates its own saved-search list in one of
 ;; the latter two forms.
-
   :get 'notmuch-hello--saved-searches-to-plist
   :type '(repeat notmuch-saved-search-plist)
   :tag "List of Saved Searches"
@@ -482,20 +481,17 @@ (defun notmuch-hello-tags-per-line (widest)
   ;; Count is 9 wide (8 digits plus space), 1 for the space
   ;; after the name.
   (+ 9 1 (max notmuch-column-control 

[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   |  2 +-
 emacs/notmuch-show.el|  2 +-
 emacs/notmuch-tree.el|  2 +-
 emacs/notmuch.el |  2 +-
 9 files changed, 60 insertions(+), 42 deletions(-)

diff --git a/emacs/notmuch-company.el b/emacs/notmuch-company.el
index c1f3594e..88b1c533 100644
--- a/emacs/notmuch-company.el
+++ b/emacs/notmuch-company.el
@@ -1,29 +1,35 @@
 ;;; notmuch-company.el --- Mail address completion for notmuch via 
company-mode  -*- lexical-binding: t -*-
 
-;; Authors: Trevor Jim 
-;; Michal Sojka 
+;; Copyright © Trevor Jim
+;; Copyright © Michal Sojka
 ;;
-;; Keywords: mail, completion
-
-;; This program is free software; you can redistribute it and/or modify
-;; it under the terms of the GNU General Public License as published by
+;; This file is part of Notmuch.
+;;
+;; Notmuch is free software: you can redistribute it and/or modify it
+;; under the terms of the GNU General Public License as published by
 ;; the Free Software Foundation, either version 3 of the License, or
 ;; (at your option) any later version.
-
-;; This program is distributed in the hope that it will be useful,
-;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-;; GNU General Public License for more details.
-
+;;
+;; Notmuch is distributed in the hope that it will be useful, but
+;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+;; General Public License for more details.
+;;
 ;; You should have received a copy of the GNU General Public License
-;; along with this program.  If not, see .
+;; along with Notmuch.  If not, see .
+;;
+;; Authors: Trevor Jim 
+;; Michal Sojka 
+;;
+;; Keywords: mail, completion
 
 ;;; Commentary:
 
-;; To enable this, install company mode (https://company-mode.github.io/)
+;; Mail address completion for notmuch via company-mode.  To enable
+;; this, install company mode from .
 ;;
 ;; NB company-minimum-prefix-length defaults to 3 so you don't get
-;; completion unless you type 3 characters
+;; completion unless you type 3 characters.
 
 ;;; Code:
 
diff --git a/emacs/notmuch-compat.el b/emacs/notmuch-compat.el
index 3340918f..43b60ae3 100644
--- a/emacs/notmuch-compat.el
+++ b/emacs/notmuch-compat.el
@@ -3,6 +3,21 @@
 ;; The functions in this file are copied from more modern versions of
 ;; emacs and are Copyright (C) 1985-1986, 1992, 1994-1995, 1999-2017
 ;; Free Software Foundation, Inc.
+;;
+;; This file is part of Notmuch.
+;;
+;; Notmuch is free software: you can redistribute it and/or modify it
+;; under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+;;
+;; Notmuch is distributed in the hope that it will be useful, but
+;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+;; General Public License for more details.
+;;
+;; You should have received a copy of the GNU General Public License
+;; along with Notmuch.  If not, see .
 
 
 ;; emacs master has a bugfix for folding long headers when sending
diff --git a/emacs/notmuch-crypto.el b/emacs/notmuch-crypto.el
index e6bf8339..6df1dd64 100644
--- a/emacs/notmuch-crypto.el
+++ b/emacs/notmuch-crypto.el
@@ -1,4 +1,4 @@
-;;; notmuch-crypto.el --- functions for handling display of cryptographic 
metadata.
+;;; notmuch-crypto.el --- functions for handling display of cryptographic 
metadata
 ;;
 ;; Copyright © Jameson Rollins
 ;;
diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index a057140f..dbdc99c1 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -19,8 +19,6 @@
 ;;
 ;; Authors: Carl Worth 
 
-;; This is an part of an emacs-based interface to the notmuch mail system.
-
 ;;; Code:
 
 (require 'cl-lib)
diff --git a/emacs/notmuch-maildir-fcc.el b/emacs/notmuch-maildir-fcc.el
index 1027e1a7..aa07b26a 100644
--- a/emacs/notmuch-maildir-fcc.el
+++ b/emacs/notmuch-maildir-fcc.el
@@ -1,24 +1,23 @@
-;;; notmuch-maildir-fcc.el ---
-
-;; This file is free software; you can redistribute it and/or modify
-;; it under the terms of the GNU General Public License as published
-;; by the Free Software Foundation; either version 2, or (at your
-;; option) any later version.
-
-;; This program is distributed in the hope that it will be useful,
-;; but WITHOUT ANY WARRANTY; 

[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 shouldn't be done.

- Symbols are quoted like `so'.

- There is no clear rule on how to (not) quote non-atomic
  s-expressions, but quoting like '(this) is definitely weird.

- It is a good idea to remember that \" becomes " and to take
  that in mind when adjusting the automatic filling by hand.

- Use the imperative form.

- Arguments are written in all uppercase.
---
 emacs/notmuch-address.el | 42 +---
 emacs/notmuch-query.el   | 19 +-
 emacs/notmuch-show.el|  4 ++--
 emacs/notmuch-tree.el|  5 +++--
 emacs/notmuch.el |  9 -
 emacs/rstdoc.el  |  6 +++---
 6 files changed, 43 insertions(+), 42 deletions(-)

diff --git a/emacs/notmuch-address.el b/emacs/notmuch-address.el
index 85531489..cd0ffb67 100644
--- a/emacs/notmuch-address.el
+++ b/emacs/notmuch-address.el
@@ -36,9 +36,9 @@ (defvar notmuch-address-completions (make-hash-table :test 
'equal)
 This variable is set by calling `notmuch-address-harvest'.")
 
 (defvar notmuch-address-full-harvest-finished nil
-  "t indicates that full completion address harvesting has been
-finished. Use notmuch-address--harvest-ready to access as that
-will load a saved hash if necessary (and available).")
+  "t indicates that full completion address harvesting has been finished.
+Use notmuch-address--harvest-ready to access as that will load a
+saved hash if necessary (and available).")
 
 (defun notmuch-address--harvest-ready ()
   "Return t if there is a full address hash available.
@@ -54,9 +54,9 @@ (defcustom notmuch-address-command 'internal
 which must take a single argument (searched string) and output a
 list of completion candidates, one per line.
 
-Alternatively, it can be the symbol 'internal, in which case
+Alternatively, it can be the symbol `internal', in which case
 internal completion is used; the variable
-`notmuch-address-internal-completion` can be used to customize
+`notmuch-address-internal-completion' can be used to customize
 this case.
 
 Finally, if this variable is nil then address completion is
@@ -72,12 +72,12 @@ (defcustom notmuch-address-command 'internal
 (defcustom notmuch-address-internal-completion '(sent nil)
   "Determines how internal address completion generates candidates.
 
-This should be a list of the form '(DIRECTION FILTER), where
+This should be a list of the form (DIRECTION FILTER), where
 DIRECTION is either sent or received and specifies whether the
 candidates are searched in messages sent by the user or received
 by the user (note received by is much faster), and FILTER is
-either nil or a filter-string, such as \"date:1y..\" to append
-to the query."
+either nil or a filter-string, such as \"date:1y..\" to append to
+the query."
   :type '(list :tag "Use internal address completion"
   (radio
:tag "Base completion on messages you have"
@@ -101,8 +101,8 @@ (defcustom notmuch-address-save-filename nil
   "Filename to save the cached completion addresses.
 
 All the addresses notmuch uses for address completion will be
-cached in this file. This has obvious privacy implications so you
-should make sure it is not somewhere publicly readable."
+cached in this file.  This has obvious privacy implications so
+you should make sure it is not somewhere publicly readable."
   :type '(choice (const :tag "Off" nil)
 (file :tag "Filename"))
   :group 'notmuch-send
@@ -110,12 +110,14 @@ (defcustom notmuch-address-save-filename nil
   :group 'notmuch-external)
 
 (defcustom notmuch-address-selection-function 
'notmuch-address-selection-function
-  "The function to select address from given list. The function is
-called with PROMPT, COLLECTION, and INITIAL-INPUT as arguments
-(subset of what `completing-read' can be called with).
-While executed the value of `completion-ignore-case' is t.
-See documentation of function `notmuch-address-selection-function'
-to know how address selection is made by default."
+  "The function to select address from given list.
+
+The function is called with PROMPT, COLLECTION, and INITIAL-INPUT
+as arguments (subset of what `completing-read' can be called
+with).  While executed the value of `completion-ignore-case'
+is t.  See documentation of function
+`notmuch-address-selection-function' to know how address
+selection is made by default."
   :type 'function
   :group 'notmuch-send
   :group 'notmuch-address
@@ -188,9 +190,9 @@ (defun notmuch-address-matching (substring)
 candidates))
 
 (defun notmuch-address-options (original)
-  "Returns a list of completion candidates. Uses either
-elisp-based implementation or older implementation requiring
-external commands."
+  "Return a list 

[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: `notmuch-tree' needs `notmuch-jump'.

Before this commit compiling (or even just loading) `notmuch-tree'
resulted in `notmuch-jump' being loaded because the former requires
`notmuch-lib', which autoloaded `notmuch-jump-search'.

The bug was that this dependency was not explicitly specified, which
we fix by adding the respective `require' form.
---
 emacs/notmuch-lib.el  | 3 ---
 emacs/notmuch-tree.el | 1 +
 2 files changed, 1 insertion(+), 3 deletions(-)

diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index 069a19e9..549161f3 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -35,9 +35,6 @@ (unless (require 'notmuch-version nil t)
   (defconst notmuch-emacs-version "unknown"
 "Placeholder variable when notmuch-version.el[c] is not available."))
 
-(autoload 'notmuch-jump-search "notmuch-jump"
-  "Jump to a saved search by shortcut key." t)
-
 (defgroup notmuch nil
   "Notmuch mail reader for Emacs."
   :group 'mail)
diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el
index 364da240..b538cef9 100644
--- a/emacs/notmuch-tree.el
+++ b/emacs/notmuch-tree.el
@@ -33,6 +33,7 @@ (require 'notmuch-query)
 (require 'notmuch-show)
 (require 'notmuch-tag)
 (require 'notmuch-parser)
+(require 'notmuch-jump)
 
 (declare-function notmuch-search "notmuch"
  ( query oldest-first target-thread target-line))
-- 
2.26.0
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[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 3127de86..c127bba9 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -687,7 +687,6 @@ (defvar notmuch-hello-mode-map
 (define-key map (kbd "") 'widget-backward)
 map)
   "Keymap for \"notmuch hello\" buffers.")
-(fset 'notmuch-hello-mode-map notmuch-hello-mode-map)
 
 (define-derived-mode notmuch-hello-mode fundamental-mode "notmuch-hello"
   "Major mode for convenient notmuch navigation. This is your entry portal 
into notmuch.
-- 
2.26.0
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[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 +-
 emacs/notmuch-show.el|  93 ++--
 emacs/notmuch-tree.el|  30 ++--
 emacs/notmuch-wash.el|  68 +-
 emacs/notmuch.el | 100 +++
 test/test-lib.el |   8 ++--
 12 files changed, 208 insertions(+), 205 deletions(-)

diff --git a/emacs/notmuch-address.el b/emacs/notmuch-address.el
index 2dd08661..85531489 100644
--- a/emacs/notmuch-address.el
+++ b/emacs/notmuch-address.el
@@ -171,10 +171,10 @@ (defun notmuch-address-toggle-internal-completion ()
   (if (local-variable-p 'notmuch-address-command)
   (kill-local-variable 'notmuch-address-command)
 (notmuch-setq-local notmuch-address-command 'internal))
-  (if (boundp 'company-idle-delay)
-  (if (local-variable-p 'company-idle-delay)
- (kill-local-variable 'company-idle-delay)
-   (notmuch-setq-local company-idle-delay nil
+  (when (boundp 'company-idle-delay)
+(if (local-variable-p 'company-idle-delay)
+   (kill-local-variable 'company-idle-delay)
+  (notmuch-setq-local company-idle-delay nil
 
 (defun notmuch-address-matching (substring)
   "Returns a list of completion candidates matching SUBSTRING.
diff --git a/emacs/notmuch-compat.el b/emacs/notmuch-compat.el
index 388ef70f..3340918f 100644
--- a/emacs/notmuch-compat.el
+++ b/emacs/notmuch-compat.el
@@ -68,9 +68,9 @@ (if (fboundp 'read-char-choice)
   ;; This is an inlined copy of help-form-show as that
   ;; was introduced in emacs 24 too.
   (let ((msg (eval help-form)))
-(if (stringp msg)
-(with-output-to-temp-buffer " *Char Help*"
-  (princ msg))
+(when (stringp msg)
+  (with-output-to-temp-buffer " *Char Help*"
+(princ msg))
 ((memq char chars)
  (setq done t))
 ((and executing-kbd-macro (= char -1))
diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index 25e28a52..3127de86 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -589,8 +589,8 @@ (defun notmuch-hello-insert-buttons (searches)
 (mapc (lambda (elem)
;; (not elem) indicates an empty slot in the matrix.
(when elem
- (if (> column-indent 0)
- (widget-insert (make-string column-indent ? )))
+ (when (> column-indent 0)
+   (widget-insert (make-string column-indent ? )))
  (let* ((name (plist-get elem :name))
 (query (plist-get elem :query))
 (oldest-first (cl-case (plist-get elem :sort-order)
@@ -890,8 +890,8 @@ (defun notmuch-hello-insert-searches (title query-list 
 options)
the same values as :filter. If :filter and :filter-count are specified, this
will be used instead of :filter, not in conjunction with it."
   (widget-insert title ": ")
-  (if (and notmuch-hello-first-run (plist-get options :initially-hidden))
-  (add-to-list 'notmuch-hello-hidden-sections title))
+  (when (and notmuch-hello-first-run (plist-get options :initially-hidden))
+(add-to-list 'notmuch-hello-hidden-sections title))
   (let ((is-hidden (member title notmuch-hello-hidden-sections))
(start (point)))
 (if is-hidden
diff --git a/emacs/notmuch-jump.el b/emacs/notmuch-jump.el
index adf79650..e302fe00 100644
--- a/emacs/notmuch-jump.el
+++ b/emacs/notmuch-jump.el
@@ -169,37 +169,37 @@ (defun notmuch-jump--make-keymap (action-map prompt)
   (let ((map (make-sparse-keymap)))
 (set-keymap-parent map notmuch-jump-minibuffer-map)
 (pcase-dolist (`(,key ,name ,fn) action-map)
-  (if (= (length key) 1)
- (define-key map key
-   `(lambda () (interactive)
-  (setq notmuch-jump--action ',fn)
-  (exit-minibuffer)
+  (when (= (length key) 1)
+   (define-key map key
+ `(lambda () (interactive)
+(setq notmuch-jump--action ',fn)
+(exit-minibuffer)
 ;; By doing this in two passes (and checking if we already have a
 ;; binding) we avoid problems if the user specifies a binding which
 ;; is a prefix of another binding.
 (pcase-dolist (`(,key ,name ,fn) action-map)
-  (if (> (length key) 1)
- (let* ((key (elt key 0))
-(keystr (string key))
-(new-prompt (concat prompt (format-kbd-macro keystr) " "))
-(action-submap nil))
-   (unless (lookup-key map keystr)
- (pcase-dolist (`(,k ,n ,f) action-map)
-   (when (= key (elt k 0))
- 

[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   |  2 +-
 emacs/notmuch-lib.el | 37 +-
 emacs/notmuch-maildir-fcc.el |  4 +-
 emacs/notmuch-mua.el | 13 +++
 emacs/notmuch-show.el| 45 +++---
 emacs/notmuch-tree.el|  4 +-
 emacs/notmuch-wash.el|  8 ++--
 emacs/notmuch.el | 28 --
 11 files changed, 114 insertions(+), 113 deletions(-)

diff --git a/emacs/coolj.el b/emacs/coolj.el
index 961db606..39a8de2b 100644
--- a/emacs/coolj.el
+++ b/emacs/coolj.el
@@ -107,12 +107,12 @@ (defun coolj-set-breakpoint (prefix)
 If the line should not be broken, return nil; point remains on the
 line."
   (move-to-column fill-column)
-  (if (and (re-search-forward "[^ ]" (line-end-position) 1)
-  (> (current-column) fill-column))
-  ;; This line is too long.  Can we break it?
-  (or (coolj-find-break-backward prefix)
- (progn (move-to-column fill-column)
-(coolj-find-break-forward)
+  (and (re-search-forward "[^ ]" (line-end-position) 1)
+   (> (current-column) fill-column)
+   ;; This line is too long.  Can we break it?
+   (or (coolj-find-break-backward prefix)
+  (progn (move-to-column fill-column)
+ (coolj-find-break-forward)
 
 (defun coolj-find-break-backward (prefix)
   "Move point backward to the first available breakpoint and return t.
diff --git a/emacs/notmuch-address.el b/emacs/notmuch-address.el
index 4db7096c..2dd08661 100644
--- a/emacs/notmuch-address.el
+++ b/emacs/notmuch-address.el
@@ -252,20 +252,20 @@ (defun notmuch-address-expand-name ()
 (defun notmuch-address-locate-command (command)
   "Return non-nil if `command' is an executable either on
 `exec-path' or an absolute pathname."
-  (when (stringp command)
-(if (and (file-name-absolute-p command)
-(file-executable-p command))
-   command
-  (setq command (file-name-nondirectory command))
-  (catch 'found-command
-   (let (bin)
- (dolist (dir exec-path)
-   (setq bin (expand-file-name command dir))
-   (when (or (and (file-executable-p bin)
-  (not (file-directory-p bin)))
- (and (file-executable-p (setq bin (concat bin ".exe")))
-  (not (file-directory-p bin
- (throw 'found-command bin
+  (and (stringp command)
+   (if (and (file-name-absolute-p command)
+   (file-executable-p command))
+  command
+(setq command (file-name-nondirectory command))
+(catch 'found-command
+  (let (bin)
+(dolist (dir exec-path)
+  (setq bin (expand-file-name command dir))
+  (when (or (and (file-executable-p bin)
+ (not (file-directory-p bin)))
+(and (file-executable-p (setq bin (concat bin ".exe")))
+ (not (file-directory-p bin
+(throw 'found-command bin
 
 (defun notmuch-address-harvest-addr (result)
   (let ((name-addr (plist-get result :name-addr)))
@@ -304,18 +304,20 @@ (defun notmuch-address-harvest ( addr-prefix 
synchronous callback)
 execution, CALLBACK is called when harvesting finishes."
   (let* ((sent (eq (car notmuch-address-internal-completion) 'sent))
 (config-query (cadr notmuch-address-internal-completion))
-(prefix-query (when addr-prefix
-(format "%s:%s*" (if sent "to" "from") addr-prefix)))
+(prefix-query (and addr-prefix
+   (format "%s:%s*"
+   (if sent "to" "from")
+   addr-prefix)))
 (from-or-to-me-query
  (mapconcat (lambda (x)
   (concat (if sent "from:" "to:") x))
 (notmuch-user-emails) " or "))
 (query (if (or prefix-query config-query)
(concat (format "(%s)" from-or-to-me-query)
-   (when prefix-query
- (format " and (%s)" prefix-query))
-   (when config-query
- (format " and (%s)" config-query)))
+   (and prefix-query
+(format " and (%s)" prefix-query))
+   (and config-query
+(format " and (%s)" config-query)))
  from-or-to-me-query))
 (args `("address" "--format=sexp" "--format-version=4"
 ,(if sent "--output=recipients" "--output=sender")
@@ -354,21 +356,21 @@ (defun notmuch-address--get-address-hash ()
 
 Returns 

[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 are Makefiles (of any flavor).
---
 Makefile.global  | 1 +
 Makefile.local   | 2 +-
 bindings/Makefile.local  | 2 +-
 compat/Makefile.local| 2 +-
 completion/Makefile.local| 2 +-
 doc/Makefile.local   | 2 +-
 emacs/Makefile.local | 2 +-
 lib/Makefile.local   | 2 +-
 parse-time-string/Makefile.local | 2 ++
 performance-test/Makefile.local  | 2 +-
 test/Makefile.local  | 2 +-
 util/Makefile.local  | 2 +-
 12 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/Makefile.global b/Makefile.global
index 98b6962e..c8812f9d 100644
--- a/Makefile.global
+++ b/Makefile.global
@@ -1,3 +1,4 @@
+# -*- makefile-gmake -*-
 # Here's the (hopefully simple) versioning scheme.
 #
 # Releases of notmuch have a two-digit version (0.1, 0.2, etc.). We
diff --git a/Makefile.local b/Makefile.local
index 22577617..77bc9850 100644
--- a/Makefile.local
+++ b/Makefile.local
@@ -1,4 +1,4 @@
-# -*- makefile -*-
+# -*- makefile-gmake -*-
 
 .PHONY: all
 all: notmuch notmuch-shared build-man build-info ruby-bindings 
python-cffi-bindings
diff --git a/bindings/Makefile.local b/bindings/Makefile.local
index 19ddd6ea..bc960bbc 100644
--- a/bindings/Makefile.local
+++ b/bindings/Makefile.local
@@ -1,4 +1,4 @@
-# -*- makefile -*-
+# -*- makefile-gmake -*-
 
 dir := bindings
 
diff --git a/compat/Makefile.local b/compat/Makefile.local
index bcb9f0ec..2ee1b399 100644
--- a/compat/Makefile.local
+++ b/compat/Makefile.local
@@ -1,4 +1,4 @@
-# -*- makefile -*-
+# -*- makefile-gmake -*-
 
 dir := compat
 extra_cflags += -I$(srcdir)/$(dir)
diff --git a/completion/Makefile.local b/completion/Makefile.local
index 8e86c9d2..54df463c 100644
--- a/completion/Makefile.local
+++ b/completion/Makefile.local
@@ -1,4 +1,4 @@
-# -*- makefile -*-
+# -*- makefile-gmake -*-
 
 dir := completion
 
diff --git a/doc/Makefile.local b/doc/Makefile.local
index 30411341..60bd7184 100644
--- a/doc/Makefile.local
+++ b/doc/Makefile.local
@@ -1,4 +1,4 @@
-# -*- makefile -*-
+# -*- makefile-gmake -*-
 
 dir := doc
 
diff --git a/emacs/Makefile.local b/emacs/Makefile.local
index 141f5868..d1b320c3 100644
--- a/emacs/Makefile.local
+++ b/emacs/Makefile.local
@@ -1,4 +1,4 @@
-# -*- makefile -*-
+# -*- makefile-gmake -*-
 
 dir := emacs
 emacs_sources := \
diff --git a/lib/Makefile.local b/lib/Makefile.local
index 5dc057c0..a6400126 100644
--- a/lib/Makefile.local
+++ b/lib/Makefile.local
@@ -1,4 +1,4 @@
-# -*- makefile -*-
+# -*- makefile-gmake -*-
 
 dir := lib
 
diff --git a/parse-time-string/Makefile.local b/parse-time-string/Makefile.local
index 53534f3e..ee8030cc 100644
--- a/parse-time-string/Makefile.local
+++ b/parse-time-string/Makefile.local
@@ -1,3 +1,5 @@
+# -*- makefile-gmake -*-
+
 dir := parse-time-string
 extra_cflags += -I$(srcdir)/$(dir)
 
diff --git a/performance-test/Makefile.local b/performance-test/Makefile.local
index 9dc260e3..b9f580c7 100644
--- a/performance-test/Makefile.local
+++ b/performance-test/Makefile.local
@@ -1,4 +1,4 @@
-# -*- makefile -*-
+# -*- makefile-gmake -*-
 
 dir := performance-test
 
diff --git a/test/Makefile.local b/test/Makefile.local
index 47244e8f..40574739 100644
--- a/test/Makefile.local
+++ b/test/Makefile.local
@@ -1,4 +1,4 @@
-# -*- makefile -*-
+# -*- makefile-gmake -*-
 
 dir := test
 
diff --git a/util/Makefile.local b/util/Makefile.local
index f5d72f79..7ef029a5 100644
--- a/util/Makefile.local
+++ b/util/Makefile.local
@@ -1,4 +1,4 @@
-# -*- makefile -*-
+# -*- makefile-gmake -*-
 
 dir := util
 extra_cflags += -I$(srcdir)/$(dir)
-- 
2.26.0
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[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)
 
-(declare-function notmuch-search-tag "notmuch" tag-changes)
-(declare-function notmuch-show-tag "notmuch-show" tag-changes)
-(declare-function notmuch-tree-tag "notmuch-tree" tag-changes)
+(declare-function notmuch-search-tag "notmuch"
+ (tag-changes  beg end only-matched))
+(declare-function notmuch-show-tag "notmuch-show" (tag-changes))
+(declare-function notmuch-tree-tag "notmuch-tree" (tag-changes))
 
 (autoload 'notmuch-jump "notmuch-jump")
 
-- 
2.26.0
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[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 first what is a key and what a
value and as a result it is easy to make a mistake.  Also it becomes
harder to comment out just one assignment.
---
 emacs/notmuch-address.el |  6 +++---
 emacs/notmuch-crypto.el  | 23 ---
 emacs/notmuch-lib.el |  8 
 emacs/notmuch-show.el| 26 ++
 emacs/notmuch-tree.el|  4 ++--
 emacs/notmuch.el | 35 ++-
 6 files changed, 53 insertions(+), 49 deletions(-)

diff --git a/emacs/notmuch-address.el b/emacs/notmuch-address.el
index 09dda247..4db7096c 100644
--- a/emacs/notmuch-address.el
+++ b/emacs/notmuch-address.el
@@ -381,9 +381,9 @@ (defun notmuch-address--load-address-hash ()
  notmuch-address-internal-completion)
   (equal (plist-get load-plist :version)
  notmuch-address--save-hash-version))
-  (setq notmuch-address-last-harvest (plist-get load-plist :last-harvest)
-   notmuch-address-completions (plist-get load-plist :completions)
-   notmuch-address-full-harvest-finished t)
+  (setq notmuch-address-last-harvest (plist-get load-plist :last-harvest))
+  (setq notmuch-address-completions (plist-get load-plist :completions))
+  (setq notmuch-address-full-harvest-finished t)
   ;; Return t to say load was successful.
   t)))
 
diff --git a/emacs/notmuch-crypto.el b/emacs/notmuch-crypto.el
index 58947a20..420b008f 100644
--- a/emacs/notmuch-crypto.el
+++ b/emacs/notmuch-crypto.el
@@ -117,20 +117,21 @@ (defun notmuch-crypto-insert-sigstatus-button (sigstatus 
from)
(userid (plist-get sigstatus :userid)))
;; If userid is present it has full or greater validity.
(if userid
-   (setq label (concat "Good signature by: " userid)
- face 'notmuch-crypto-signature-good)
- (setq label (concat "Good signature by key: " fingerprint)
-   face 'notmuch-crypto-signature-good-key))
-   (setq button-action 'notmuch-crypto-sigstatus-good-callback
- help-msg (concat "Click to list key ID 0x" fingerprint "."
+   (progn
+ (setq label (concat "Good signature by: " userid))
+ (setq face 'notmuch-crypto-signature-good))
+ (setq label (concat "Good signature by key: " fingerprint))
+ (setq face 'notmuch-crypto-signature-good-key))
+   (setq button-action 'notmuch-crypto-sigstatus-good-callback)
+   (setq help-msg (concat "Click to list key ID 0x" fingerprint "."
  ((string= status "error")
-  (setq label (concat "Unknown key ID " keyid " or unsupported algorithm")
-   button-action 'notmuch-crypto-sigstatus-error-callback
-   help-msg (concat "Click to retrieve key ID " keyid
+  (setq label (concat "Unknown key ID " keyid " or unsupported algorithm"))
+  (setq button-action 'notmuch-crypto-sigstatus-error-callback)
+  (setq help-msg (concat "Click to retrieve key ID " keyid
 " from keyserver.")))
  ((string= status "bad")
-  (setq label (concat "Bad signature (claimed key ID " keyid ")")
-   face 'notmuch-crypto-signature-bad))
+  (setq label (concat "Bad signature (claimed key ID " keyid ")"))
+  (setq face 'notmuch-crypto-signature-bad))
  (status
   (setq label (concat "Unknown signature status: " status)))
  (t
diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index f8958a91..886da99f 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -861,8 +861,8 @@ (defun notmuch-call-notmuch--helper (destination args)
   (let (stdin-string)
 (while (keywordp (car args))
   (cl-case (car args)
-   (:stdin-string (setq stdin-string (cadr args)
-args (cddr args)))
+   (:stdin-string (setq stdin-string (cadr args))
+  (setq args (cddr args)))
(otherwise
 (error "Unknown keyword argument: %s" (car args)
 (if (null stdin-string)
@@ -939,8 +939,8 @@ (defun notmuch-start-notmuch (name buffer sentinel  
args)
  :buffer buffer
  :command (cons command args)
  :connection-type 'pipe
- :stderr err-buffer)
-   err-proc (get-buffer-process err-buffer))
+ :stderr err-buffer))
+ (setq err-proc (get-buffer-process err-buffer))
  (process-put proc 'err-buffer err-buffer)
 
  (process-put err-proc 'err-file err-file)
diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 8592936f..a0a6c09d 100644
--- a/emacs/notmuch-show.el
+++ 

[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|   7 ++-
 emacs/notmuch-lib.el |  62 +
 emacs/notmuch-maildir-fcc.el |  14 ++---
 emacs/notmuch-message.el |   3 +-
 emacs/notmuch-mua.el |  78 +++---
 emacs/notmuch-show.el| 103 +++
 emacs/notmuch-tag.el |  14 +++--
 emacs/notmuch-tree.el|  55 +--
 emacs/notmuch-wash.el|  19 +--
 emacs/notmuch.el |  27 ++---
 emacs/rstdoc.el  |   3 +-
 17 files changed, 326 insertions(+), 187 deletions(-)

diff --git a/emacs/coolj.el b/emacs/coolj.el
index 350d537f..5d311170 100644
--- a/emacs/coolj.el
+++ b/emacs/coolj.el
@@ -1,6 +1,6 @@
 ;;; coolj.el --- automatically wrap long lines  -*- coding:utf-8 -*-
 
-;; Copyright (C) 2000, 2001, 2004, 2005, 2006, 2007, 2008, 2009 Free Software 
Foundation, Inc.
+;; Copyright (C) 2000, 2001, 2004-2009 Free Software Foundation, Inc.
 
 ;; Authors:Kai Grossjohann 
 ;; Alex Schroeder 
diff --git a/emacs/notmuch-address.el b/emacs/notmuch-address.el
index 0d56fba7..2a9c411a 100644
--- a/emacs/notmuch-address.el
+++ b/emacs/notmuch-address.el
@@ -195,10 +195,11 @@ (defun notmuch-address-options (original)
((eq notmuch-address-command 'internal)
 (unless (notmuch-address--harvest-ready)
   ;; First, run quick synchronous harvest based on what the user
-  ;; entered so far
+  ;; entered so far.
   (notmuch-address-harvest original t))
 (prog1 (notmuch-address-matching original)
-  ;; Then start the (potentially long-running) full asynchronous harvest 
if necessary
+  ;; Then start the (potentially long-running) full asynchronous
+  ;; harvest if necessary.
   (notmuch-address-harvest-trigger)))
(t
 (process-lines notmuch-address-command original
@@ -241,7 +242,8 @@ (defun notmuch-address-expand-name ()
(push chosen notmuch-address-history)
(delete-region beg end)
(insert chosen)
-   (run-hook-with-args 'notmuch-address-post-completion-functions 
chosen))
+   (run-hook-with-args 'notmuch-address-post-completion-functions
+   chosen))
(message "No matches.")
(ding
(t nil)))
@@ -393,10 +395,11 @@ (defun notmuch-address--save-address-hash ()
  ;; The file exists, check it is a file we saved
(notmuch-address--get-address-hash))
(with-temp-file notmuch-address-save-filename
- (let ((save-plist (list :version notmuch-address--save-hash-version
- :completion-settings 
notmuch-address-internal-completion
- :last-harvest notmuch-address-last-harvest
- :completions notmuch-address-completions)))
+ (let ((save-plist
+(list :version notmuch-address--save-hash-version
+  :completion-settings notmuch-address-internal-completion
+  :last-harvest notmuch-address-last-harvest
+  :completions notmuch-address-completions)))
(print "notmuch-address-hash" (current-buffer))
(print save-plist (current-buffer
   (message "\
@@ -408,16 +411,17 @@ (defun notmuch-address-harvest-trigger ()
   (let ((now (float-time)))
 (when (> (- now notmuch-address-last-harvest) 86400)
   (setq notmuch-address-last-harvest now)
-  (notmuch-address-harvest nil nil
-  (lambda (proc event)
-;; If harvest fails, we want to try
-;; again when the trigger is next
-;; called
-(if (string= event "finished\n")
-(progn
-  (notmuch-address--save-address-hash)
-  (setq 
notmuch-address-full-harvest-finished t))
-  (setq notmuch-address-last-harvest 0)))
+  (notmuch-address-harvest
+   nil nil
+   (lambda (proc event)
+;; If harvest fails, we want to try
+;; again when the trigger is next
+;; called
+(if (string= event "finished\n")
+(progn
+  (notmuch-address--save-address-hash)
+  (setq notmuch-address-full-harvest-finished t))
+  (setq notmuch-address-last-harvest 0)))
 
 ;;
 
diff --git a/emacs/notmuch-company.el b/emacs/notmuch-company.el
index ac998f9b..c1f3594e 100644
--- a/emacs/notmuch-company.el
+++ b/emacs/notmuch-company.el
@@ -69,9 +69,11 @@ 

[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
+++ b/emacs/notmuch-hello.el
@@ -609,7 +609,7 @@ (defun notmuch-hello-insert-buttons (searches)
   name)
(setq column-indent
  (1+ (max 0 (- column-width (length name)))
-   (setq count (1+ count))
+   (cl-incf count)
(when (eq (% count tags-per-line) 0)
  (setq column-indent 0)
  (widget-insert "\n")))
diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index 886da99f..5d0c373a 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -417,7 +417,7 @@ (defun notmuch-subkeymap-help ()
 (i 0))
 (while (< i (length prefix))
   (aset prefix i (aref key i))
-  (setq i (1+ i)))
+  (cl-incf i))
 (let* ((subkeymap (key-binding prefix))
   (ua-keys (where-is-internal 'universal-argument nil t))
   (prefix-string (notmuch-prefix-key-description prefix))
-- 
2.26.0
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[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   | 8 
 emacs/notmuch.el| 4 ++--
 test/test-lib.el| 6 +++---
 8 files changed, 18 insertions(+), 19 deletions(-)

diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index 1c084bf7..25e28a52 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -638,7 +638,7 @@ (defun notmuch-hello-window-configuration-change ()
 (dolist (window (window-list))
   (let ((last-buf (window-parameter window 'notmuch-hello-last-buffer))
(cur-buf (window-buffer window)))
-   (when (not (eq last-buf cur-buf))
+   (unless (eq last-buf cur-buf)
  ;; This window changed or is new.  Update recorded buffer
  ;; for next time.
  (set-window-parameter window 'notmuch-hello-last-buffer cur-buf)
@@ -652,7 +652,7 @@ (defun notmuch-hello-window-configuration-change ()
   ;; 24, we can't do it right here because something in this
   ;; hook's call stack overrides hello's point placement.
   (run-at-time nil nil #'notmuch-hello t))
-(when (null hello-buf)
+(unless hello-buf
   ;; Clean up hook
   (remove-hook 'window-configuration-change-hook
   #'notmuch-hello-window-configuration-change
@@ -908,7 +908,7 @@ (defun notmuch-hello-insert-searches (title query-list 
 options)
(notmuch-hello-update))
 "hide"))
 (widget-insert "\n")
-(when (not is-hidden)
+(unless is-hidden
   (let ((searches (apply 'notmuch-hello-query-counts query-list options)))
(when (or (not (plist-get options :hide-if-empty))
  searches)
diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el
index 3fe513ab..6e7f1569 100644
--- a/emacs/notmuch-mua.el
+++ b/emacs/notmuch-mua.el
@@ -198,7 +198,7 @@ (defun notmuch-mua-user-agent-emacs ()
 (defun notmuch-mua-add-more-hidden-headers ()
   "Add some headers to the list that are hidden by default."
   (mapc (lambda (header)
- (when (not (member header message-hidden-headers))
+ (unless (member header message-hidden-headers)
(push header message-hidden-headers)))
notmuch-mua-hidden-headers))
 
@@ -368,7 +368,7 @@ (defun notmuch-mua-mail ( to subject other-headers 
continue
   (interactive)
   (when notmuch-mua-user-agent-function
 (let ((user-agent (funcall notmuch-mua-user-agent-function)))
-  (when (not (string= "" user-agent))
+  (unless (string= "" user-agent)
(push (cons 'User-Agent user-agent) other-headers
   (unless (assq 'From other-headers)
 (push (cons 'From (message-make-from
diff --git a/emacs/notmuch-parser.el b/emacs/notmuch-parser.el
index 06e7487b..fbcfc2ef 100644
--- a/emacs/notmuch-parser.el
+++ b/emacs/notmuch-parser.el
@@ -78,7 +78,7 @@ (defun notmuch-sexp-read (sp)
 ;; parse, extend the partial parse to figure out when we
 ;; have a complete list.
 (catch 'return
-  (when (null (notmuch-sexp--partial-state sp))
+  (unless (notmuch-sexp--partial-state sp)
 (let ((start (point)))
   (condition-case nil
   (throw 'return (read (current-buffer)))
diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 211be091..6102ca2e 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -1060,8 +1060,7 @@ (defun notmuch-show-insert-msg (msg depth)
   ;; If the subject of this message is the same as that of the
   ;; previous message, don't display it when this message is
   ;; collapsed.
-  (when (not (string= notmuch-show-previous-subject
- bare-subject))
+  (unless (string= notmuch-show-previous-subject bare-subject)
(forward-line 1))
   (setq headers-start (point-marker)))
 (setq headers-end (point-marker))
diff --git a/emacs/notmuch-tag.el b/emacs/notmuch-tag.el
index 2fcf5a9e..1067f185 100644
--- a/emacs/notmuch-tag.el
+++ b/emacs/notmuch-tag.el
@@ -382,8 +382,8 @@ (defun notmuch-tag-completions ( search-terms)
   "Return a list of tags for messages matching SEARCH-TERMS.
 
 Returns all tags if no search terms are given."
-  (if (null search-terms)
-  (setq search-terms (list "*")))
+  (unless search-terms
+(setq search-terms (list "*")))
   (split-string
(with-output-to-string
  (with-current-buffer standard-output
diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el
index 37a5d1c8..a5ae0edb 100644
--- a/emacs/notmuch-tree.el
+++ b/emacs/notmuch-tree.el
@@ -1063,10 +1063,10 @@ (defun notmuch-tree ( query query-context 
target buffer-name open-targe
   OPEN-TARGET: If TRUE open the target message in the message pane.
   UNTHREADED: If TRUE only show 

[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 the face in Emacs 27, so that it looks
the same as it did in older Emacs releases.  We have to do this
conditionally, otherwise older Emacsen would choke on it.
---
 emacs/notmuch.el | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index 4fc338e2..5562ad10 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -273,8 +273,12 @@ (defun notmuch-search-first-thread ()
   (goto-char (point-min)))
 
 (defface notmuch-message-summary-face
-  'class color) (background light)) (:background "#f0f0f0"))
-(((class color) (background dark)) (:background "#303030")))
+  `class color) (background light))
+ ,@(and (>= emacs-major-version 27) '(:extend t))
+ (:background "#f0f0f0"))
+(((class color) (background dark))
+ ,@(and (>= emacs-major-version 27) '(:extend t))
+ (:background "#303030")))
   "Face for the single-line message summary in notmuch-show-mode."
   :group 'notmuch-show
   :group 'notmuch-faces)
-- 
2.26.0
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[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 --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index 6110e45d..fc76fd67 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -611,7 +611,8 @@ (defun notmuch--get-bodypart-raw (msg part process-crypto 
binaryp cache)
   ,@(and process-crypto '("--decrypt=true"))
   ,(notmuch-id-to-query (plist-get msg :id
   (coding-system-for-read
-   (if binaryp 'no-conversion
+   (if binaryp
+   'no-conversion
  (let ((coding-system
 (mm-charset-to-coding-system
  (plist-get part :content-charset
@@ -680,7 +681,8 @@ (defun notmuch-mm-display-part-inline (msg part 
content-type process-crypto)
   ;; `gnus-decoded' charset.  Otherwise, we'll fetch the binary
   ;; part content and let mm-* decode it.
   (let* ((have-content (plist-member part :content))
-(charset (if have-content 'gnus-decoded
+(charset (if have-content
+ 'gnus-decoded
(plist-get part :content-charset)))
 (handle (mm-make-handle (current-buffer)
 `(,content-type (charset . ,charset)
diff --git a/emacs/notmuch-tag.el b/emacs/notmuch-tag.el
index 1067f185..e71de041 100644
--- a/emacs/notmuch-tag.el
+++ b/emacs/notmuch-tag.el
@@ -532,7 +532,8 @@ (defun notmuch-tag-jump (reverse)
   (and (symbolp name)
(symbol-name name
 (name-string (if name
- (if reverse (concat "Reverse " name)
+ (if reverse
+ (concat "Reverse " name)
name)
(mapconcat #'identity tag-change " "
(push (list key name-string
diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el
index 6a619ec2..b498db07 100644
--- a/emacs/notmuch-tree.el
+++ b/emacs/notmuch-tree.el
@@ -1009,7 +1009,8 @@ (defun notmuch-tree-worker (basic-query  
query-context target open-targ
   (setq notmuch-tree-basic-query basic-query)
   (setq notmuch-tree-query-context (if (or (string= query-context "")
   (string= query-context "*"))
-  nil query-context))
+  nil
+query-context))
   (setq notmuch-tree-target-msg target)
   (setq notmuch-tree-open-target open-target)
   ;; Set the default value for `notmuch-show-process-crypto' in this
-- 
2.26.0
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[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 -
 emacs/notmuch-maildir-fcc.el   |  58 -
 emacs/notmuch-mua.el   |  34 +-
 emacs/notmuch-query.el |   6 +-
 emacs/notmuch-show.el  | 111 +
 emacs/notmuch-tag.el   |   4 +-
 emacs/notmuch-tree.el  | 102 +++---
 emacs/notmuch-wash.el  |   2 +-
 emacs/notmuch.el   |  76 +++---
 test/emacs-address-cleaning.el |   2 +-
 15 files changed, 307 insertions(+), 306 deletions(-)

diff --git a/emacs/coolj.el b/emacs/coolj.el
index 5d311170..961db606 100644
--- a/emacs/coolj.el
+++ b/emacs/coolj.el
@@ -108,11 +108,11 @@ (defun coolj-set-breakpoint (prefix)
 line."
   (move-to-column fill-column)
   (if (and (re-search-forward "[^ ]" (line-end-position) 1)
-   (> (current-column) fill-column))
+  (> (current-column) fill-column))
   ;; This line is too long.  Can we break it?
   (or (coolj-find-break-backward prefix)
-  (progn (move-to-column fill-column)
- (coolj-find-break-forward)
+ (progn (move-to-column fill-column)
+(coolj-find-break-forward)
 
 (defun coolj-find-break-backward (prefix)
   "Move point backward to the first available breakpoint and return t.
@@ -135,12 +135,12 @@ (defun coolj-find-break-forward ()
 If no break point is found, return nil."
   (and (search-forward " " (line-end-position) 1)
(progn (skip-chars-forward " " (line-end-position))
-  (null (eolp)))
+ (null (eolp)))
(if (and fill-nobreak-predicate
-(run-hook-with-args-until-success
- 'fill-nobreak-predicate))
-   (coolj-find-break-forward)
- t)))
+   (run-hook-with-args-until-success
+'fill-nobreak-predicate))
+  (coolj-find-break-forward)
+t)))
 
 (provide 'coolj)
 
diff --git a/emacs/notmuch-address.el b/emacs/notmuch-address.el
index ca4da3f3..09dda247 100644
--- a/emacs/notmuch-address.el
+++ b/emacs/notmuch-address.el
@@ -153,14 +153,14 @@ (defcustom notmuch-address-use-company t
 
 (defun notmuch-address-setup ()
   (let* ((setup-company (and notmuch-address-use-company
-  (require 'company nil t)))
+(require 'company nil t)))
 (pair (cons notmuch-address-completion-headers-regexp
-  #'notmuch-address-expand-name)))
-  (when setup-company
-   (notmuch-company-setup))
-  (unless (member pair message-completion-alist)
-   (setq message-completion-alist
- (push pair message-completion-alist)
+#'notmuch-address-expand-name)))
+(when setup-company
+  (notmuch-company-setup))
+(unless (member pair message-completion-alist)
+  (setq message-completion-alist
+   (push pair message-completion-alist)
 
 (defun notmuch-address-toggle-internal-completion ()
   "Toggle use of internal completion for current buffer.
@@ -323,7 +323,7 @@ (defun notmuch-address-harvest ( addr-prefix 
synchronous callback)
 ,query)))
 (if synchronous
(mapc #'notmuch-address-harvest-addr
-  (apply 'notmuch-call-notmuch-sexp args))
+ (apply 'notmuch-call-notmuch-sexp args))
   ;; Asynchronous
   (let* ((current-proc (if addr-prefix
   (car notmuch-address-harvest-procs)
@@ -390,7 +390,7 @@ (defun notmuch-address--load-address-hash ()
 (defun notmuch-address--save-address-hash ()
   (when notmuch-address-save-filename
 (if (or (not (file-exists-p notmuch-address-save-filename))
- ;; The file exists, check it is a file we saved
+   ;; The file exists, check it is a file we saved
(notmuch-address--get-address-hash))
(with-temp-file notmuch-address-save-filename
  (let ((save-plist
diff --git a/emacs/notmuch-compat.el b/emacs/notmuch-compat.el
index 2cedd39d..388ef70f 100644
--- a/emacs/notmuch-compat.el
+++ b/emacs/notmuch-compat.el
@@ -35,7 +35,7 @@ (if (fboundp 'setq-local)
 (if (fboundp 'read-char-choice)
 (defalias 'notmuch-read-char-choice 'read-char-choice)
   (defun notmuch-read-char-choice (prompt chars  
inhibit-keyboard-quit)
-  "Read and return one of CHARS, prompting for PROMPT.
+"Read and return one of CHARS, prompting for PROMPT.
 Any input that is not one of CHARS is ignored.
 
 If optional argument INHIBIT-KEYBOARD-QUIT is non-nil, ignore
@@ -44,49 +44,49 @@ (if (fboundp 'read-char-choice)
 This is an exact copy of this function from emacs 24 for use on
 emacs 23, except with 

[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
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -555,13 +555,11 @@ (defun notmuch-match-content-type (t1 t2)
   (string= (downcase t1) (downcase t2)
 
 (defvar notmuch-multipart/alternative-discouraged
-  '(
-;; Avoid HTML parts.
+  '(;; Avoid HTML parts.
 "text/html"
 ;; multipart/related usually contain a text/html part and some
 ;; associated graphics.
-"multipart/related"
-))
+"multipart/related"))
 
 (defun notmuch-multipart/alternative-determine-discouraged (msg)
   "Return the discouraged alternatives for the specified message."
diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index f38866b0..8592936f 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -297,13 +297,12 @@ (defun notmuch-show-view-all-mime-parts ()
;;
;; Any MIME part not explicitly mentioned here will be handled by an
;; external viewer as configured in the various mailcap files.
-   (let ((mm-inline-media-tests '(
- ("text/.*" ignore identity)
- ("application/pgp-signature" ignore identity)
- ("multipart/alternative" ignore identity)
- ("multipart/mixed" ignore identity)
- ("multipart/related" ignore identity)
- )))
+   (let ((mm-inline-media-tests
+ '(("text/.*" ignore identity)
+   ("application/pgp-signature" ignore identity)
+   ("multipart/alternative" ignore identity)
+   ("multipart/mixed" ignore identity)
+   ("multipart/related" ignore identity
  (mm-display-parts (mm-dissect-buffer)
 
 (defun notmuch-show-save-attachments ()
@@ -1785,10 +1784,8 @@ (defun notmuch-show-get-message-ids-for-open-messages ()
(if (notmuch-show-message-visible-p)
(setq message-ids
  (append message-ids (list (notmuch-show-get-message-id)
-   (setq done (not (notmuch-show-goto-message-next)))
-   )
-  message-ids
-  )))
+   (setq done (not (notmuch-show-goto-message-next
+  message-ids)))
 
 ;; Commands typically bound to keys.
 
diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el
index 6ac0c62d..b1bb40b1 100644
--- a/emacs/notmuch-tree.el
+++ b/emacs/notmuch-tree.el
@@ -1020,8 +1020,8 @@ (defun notmuch-tree-worker (basic-query  
query-context target open-targ
   (erase-buffer)
   (goto-char (point-min))
   (let* ((search-args (concat basic-query
- (if query-context (concat " and (" query-context 
")"))
- ))
+ (if query-context
+ (concat " and (" query-context ")"
 (message-arg (if unthreaded "--unthreaded" "--entire-thread")))
 (if (equal (car (process-lines notmuch-command "count" search-args)) "0")
(setq search-args basic-query))
diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index 2e84cd34..d6e0a9d5 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -910,8 +910,7 @@ (defun notmuch-search-buffer-title (query)
query)
   "*"))
  (t
-  (concat "*notmuch-search-" query "*"))
- )))
+  (concat "*notmuch-search-" query "*")
 
 (defun notmuch-read-query (prompt)
   "Read a notmuch-query from the minibuffer with completion.
@@ -1003,8 +1002,7 @@ (defun notmuch-search ( query oldest-first 
target-thread target-line no
 (let ((proc (get-buffer-process (current-buffer)))
  (inhibit-read-only t))
   (if proc
- (error "notmuch search process already running for query `%s'" query)
-   )
+ (error "notmuch search process already running for query `%s'" query))
   (erase-buffer)
   (goto-char (point-min))
   (save-excursion
-- 
2.26.0
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[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 up and that closer look led to me discovering
issues and once I had ran into a bunch of issue of the same kind it
made sense to systematically look for that kind across all elisp
files.

Well, one thing led to another and here we are with 23 cleanup
commits, some of which are fairly big on their own.  I just looked
at very change again; everything looks to be in order.

I am intentionally leaving out that one commit that actually does
what I originally set out to do.  In some cases I will need to gain
a deeper understanding before I can finish splitting libraries into
sections.

 Cheers,
 Jonas

Jonas Bernoulli (23):
  emacs: Shorten long lines
  emacs: Remove excess empty lines
  emacs: Fix indentation
  emacs: Closing parenthesis go on the same line
  emacs: Only set one variable per setq form
  emacs: Use cl-incf where appropriate
  emacs: Use 'and' instead of 'when' when the return value matters
  emacs: Use 'unless' instead of 'when' and 'not'
  emacs: Use 'when' instead of 'if' when there is no ELSE part
  emacs: Use one or three lines for 'if' forms
  emacs: Extend face to window edge again
  emacs: Fix some function declarations
  emacs: No longer define notmuch-hello-mode-map as a function
  emacs: notmuch-poll: Let the user know we are polling
  emacs: Use makefile-gmake-mode in Makefile*s
  emacs: Improve doc-strings
  emacs: Autoload notmuch-jump-search only once
  emacs: Autoload notmuch-jump using an autoload cookie
  emacs: Various cosmetic changes
  emacs: Increase consistency of library headers
  Fix typos
  .dir-locals.el: Set variables for correct "shell" mode
  test: Fix indentation

 .dir-locals.el |   2 +-
 Makefile.global|   1 +
 Makefile.local |   2 +-
 NEWS   |   2 +-
 bindings/Makefile.local|   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 +-
 bindings/python-cffi/notmuch2/_tags.py |   8 +-
 bindings/python-cffi/tests/conftest.py |   2 +-
 bindings/python/notmuch/database.py|  12 +-
 bindings/python/notmuch/query.py   |   2 +-
 compat/Makefile.local  |   2 +-
 completion/Makefile.local  |   2 +-
 doc/Makefile.local |   2 +-
 emacs/Makefile.local   |   2 +-
 emacs/coolj.el |  24 +-
 emacs/make-deps.el |   5 +-
 emacs/notmuch-address.el   | 186 -
 emacs/notmuch-company.el   |  53 ++-
 emacs/notmuch-compat.el|  99 +++--
 emacs/notmuch-crypto.el|  49 ++-
 emacs/notmuch-draft.el |  24 +-
 emacs/notmuch-hello.el | 102 +++--
 emacs/notmuch-jump.el  |  61 ++-
 emacs/notmuch-lib.el   | 204 +-
 emacs/notmuch-maildir-fcc.el   | 122 +++---
 emacs/notmuch-message.el   |   3 +-
 emacs/notmuch-mua.el   | 181 -
 emacs/notmuch-parser.el|  16 +-
 emacs/notmuch-print.el |   2 +-
 emacs/notmuch-query.el |  29 +-
 emacs/notmuch-show.el  | 439 ++---
 emacs/notmuch-tag.el   |  38 +-
 emacs/notmuch-tree.el  | 189 -
 emacs/notmuch-wash.el  | 109 +++--
 emacs/notmuch.el   | 276 ++---
 emacs/rstdoc.el|  18 +-
 lib/Makefile.local |   2 +-
 lib/notmuch.h  |   4 +-
 parse-time-string/Makefile.local   |   2 +
 performance-test/Makefile.local|   2 +-
 tag-util.c |   2 +-
 tag-util.h |   2 +-
 test/Makefile.local|   2 +-
 test/T610-message-property.sh  |   2 +-
 test/T710-message-id.sh|   2 +-
 test/emacs-address-cleaning.el |   2 +-
 test/random-corpus.c   |   2 +-
 test/test-lib.el   |  47 ++-
 test/test-lib.sh   |  36 +-
 util/Makefile.local|   2 +-
 53 files changed, 1189 insertions(+), 1210 deletions(-)

-- 
2.26.0
___
notmuch mailing list -- notmuch@notmuchmail.org
To 

[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 ..e9e4cd0f
--- /dev/null
+++ b/test/T563-lib-directory.sh
@@ -0,0 +1,61 @@
+#!/usr/bin/env bash
+test_description="notmuch_database_* API"
+
+. $(dirname "$0")/test-lib.sh || exit 1
+
+add_email_corpus
+
+test_begin_subtest "building database"
+test_expect_success "NOTMUCH_NEW"
+
+cat < c_head
+#include 
+#include 
+#include 
+#include 
+int main (int argc, char** argv)
+{
+   notmuch_database_t *db;
+   notmuch_directory_t *dir;
+   notmuch_status_t stat = NOTMUCH_STATUS_SUCCESS;
+   char *msg = NULL;
+
+   stat = notmuch_database_open_verbose (argv[1], 
NOTMUCH_DATABASE_MODE_READ_WRITE, , );
+   if (stat != NOTMUCH_STATUS_SUCCESS) {
+ fprintf (stderr, "error opening database: %d %s\n", stat, msg ? msg : "");
+ exit (1);
+   }
+
+   EXPECT0(notmuch_database_get_directory (db, "", ));
+   EXPECT0(notmuch_database_close (db));
+EOF
+
+cat <<'EOF' > c_tail
+   if (stat) {
+   const char *stat_str = notmuch_database_status_string (db);
+   if (stat_str)
+   fputs (stat_str, stderr);
+}
+
+}
+EOF
+
+test_begin_subtest "get child directories for a closed db"
+test_subtest_known_broken
+cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR}
+{
+notmuch_filenames_t *children;
+children = notmuch_directory_get_child_directories (dir);
+printf ("%d\n", children == NULL);
+stat = NOTMUCH_STATUS_XAPIAN_EXCEPTION;
+}
+EOF
+cat < EXPECTED
+== stdout ==
+1
+== stderr ==
+A Xapian exception occurred at lib/directory.cc:XXX: Database has been closed
+EOF
+test_expect_equal_file EXPECTED OUTPUT
+
+test_done
-- 
2.27.0
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[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 100755
--- a/test/T563-lib-directory.sh
+++ b/test/T563-lib-directory.sh
@@ -91,4 +91,22 @@ EOF
 test_expect_equal_file EXPECTED OUTPUT
 restore_database
 
+backup_database
+test_begin_subtest "get/set mtime of directory for a closed db"
+cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR}
+{
+time_t stamp = notmuch_directory_get_mtime (dir);
+stat = notmuch_directory_set_mtime (dir, stamp);
+printf ("%d\n", stat == NOTMUCH_STATUS_XAPIAN_EXCEPTION);
+}
+EOF
+cat < EXPECTED
+== stdout ==
+1
+== stderr ==
+A Xapian exception occurred setting directory mtime: Database has been closed.
+EOF
+test_expect_equal_file EXPECTED OUTPUT
+restore_database
+
 test_done
-- 
2.27.0
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[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 b/lib/indexopts.c
index 1e8d180e..82a0026f 100644
--- a/lib/indexopts.c
+++ b/lib/indexopts.c
@@ -32,7 +32,7 @@ notmuch_database_get_default_indexopts (notmuch_database_t 
*db)
 char *decrypt_policy;
 notmuch_status_t err = notmuch_database_get_config (db, "index.decrypt", 
_policy);
 if (err)
-   return ret;
+   return NULL;
 
 if (decrypt_policy) {
if ((! (strcasecmp (decrypt_policy, "true"))) ||
diff --git a/lib/notmuch.h b/lib/notmuch.h
index 1fe62914..f3cb0fe2 100644
--- a/lib/notmuch.h
+++ b/lib/notmuch.h
@@ -2325,6 +2325,7 @@ notmuch_config_list_destroy (notmuch_config_list_t 
*config_list);
  * added to the index.  At the moment it is a featureless stub.
  *
  * @since libnotmuch 5.1 (notmuch 0.26)
+ * @retval NULL in case of error
  */
 notmuch_indexopts_t *
 notmuch_database_get_default_indexopts (notmuch_database_t *db);
diff --git a/test/T562-lib-database.sh b/test/T562-lib-database.sh
index 815c9856..d6097418 100755
--- a/test/T562-lib-database.sh
+++ b/test/T562-lib-database.sh
@@ -373,7 +373,6 @@ EOF
 test_expect_equal_file EXPECTED OUTPUT
 
 test_begin_subtest "get indexopts from closed database"
-test_subtest_known_broken
 cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR}
 {
 notmuch_indexopts_t *result;
-- 
2.27.0
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[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
--- a/test/T562-lib-database.sh
+++ b/test/T562-lib-database.sh
@@ -389,4 +389,43 @@ cat < EXPECTED
 EOF
 test_expect_equal_file EXPECTED OUTPUT
 
+test_begin_subtest "get decryption policy from closed database"
+cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR}
+{
+notmuch_indexopts_t *result;
+result = notmuch_database_get_default_indexopts (db);
+EXPECT0(notmuch_database_close (db));
+notmuch_decryption_policy_t policy = 
notmuch_indexopts_get_decrypt_policy (result);
+printf ("%d\n",  policy == NOTMUCH_DECRYPT_AUTO);
+notmuch_indexopts_destroy (result);
+printf ("SUCCESS\n");
+}
+EOF
+cat < EXPECTED
+== stdout ==
+1
+SUCCESS
+== stderr ==
+EOF
+test_expect_equal_file EXPECTED OUTPUT
+
+test_begin_subtest "set decryption policy with closed database"
+cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR}
+{
+notmuch_indexopts_t *result;
+result = notmuch_database_get_default_indexopts (db);
+EXPECT0(notmuch_database_close (db));
+notmuch_decryption_policy_t policy = 
notmuch_indexopts_get_decrypt_policy (result);
+stat = notmuch_indexopts_set_decrypt_policy (result, policy);
+printf("%d\n%d\n",  policy == NOTMUCH_DECRYPT_AUTO, stat == 
NOTMUCH_STATUS_SUCCESS);
+}
+EOF
+cat < EXPECTED
+== stdout ==
+1
+1
+== stderr ==
+EOF
+test_expect_equal_file EXPECTED OUTPUT
+
 test_done
-- 
2.27.0
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[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
+++ b/test/T566-lib-message.sh
@@ -18,7 +18,7 @@ cat <<'EOF' > c_tail
 }
 EOF
 
-cat < c_head
+cat < c_head0
 #include 
 #include 
 #include 
@@ -36,9 +36,11 @@ int main (int argc, char** argv)
  exit (1);
}
EXPECT0(notmuch_database_find_message (db, id, ));
-   EXPECT0(notmuch_database_close (db));
 EOF
 
+cp c_head0 c_head
+echo "   EXPECT0(notmuch_database_close (db));" >> c_head
+
 test_begin_subtest "Handle getting message-id from closed database"
 cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR}
 {
-- 
2.27.0
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[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
+++ b/test/T566-lib-message.sh
@@ -149,6 +149,29 @@ A Xapian exception occurred at lib/message.cc:XXX: 
Database has been closed
 EOF
 test_expect_equal_file EXPECTED OUTPUT
 
+test_begin_subtest "iterate over all message filenames from closed database"
+cat c_head0 - c_tail <<'EOF' | test_C ${MAIL_DIR}
+{
+notmuch_filenames_t *filenames;
+filenames = notmuch_message_get_filenames (message);
+EXPECT0(notmuch_database_close (db));
+for (; notmuch_filenames_valid (filenames);
+   notmuch_filenames_move_to_next (filenames)) {
+const char *filename = notmuch_filenames_get (filenames);
+printf("%s\n", filename);
+}
+notmuch_filenames_destroy (filenames);
+printf("SUCCESS\n");
+}
+EOF
+cat < EXPECTED
+== stdout ==
+MAIL_DIR/01:2,
+SUCCESS
+== stderr ==
+EOF
+test_expect_equal_file EXPECTED OUTPUT
+
 test_begin_subtest "Handle getting ghost flag from closed database"
 cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR}
 {
-- 
2.27.0
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[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
--- a/lib/directory.cc
+++ b/lib/directory.cc
@@ -264,15 +264,19 @@ notmuch_filenames_t *
 notmuch_directory_get_child_files (notmuch_directory_t *directory)
 {
 char *term;
-notmuch_filenames_t *child_files;
+notmuch_filenames_t *child_files = NULL;
 
 term = talloc_asprintf (directory, "%s%u:",
_find_prefix ("file-direntry"),
directory->document_id);
 
-child_files = _create_filenames_for_terms_with_prefix (directory,
-  directory->notmuch,
-  term);
+try {
+   child_files = _create_filenames_for_terms_with_prefix (directory,
+  
directory->notmuch,
+  term);
+} catch (Xapian::Error ) {
+   LOG_XAPIAN_EXCEPTION (directory, error);
+}
 
 talloc_free (term);
 
diff --git a/lib/notmuch.h b/lib/notmuch.h
index 03db3b24..d52fa976 100644
--- a/lib/notmuch.h
+++ b/lib/notmuch.h
@@ -2148,6 +2148,8 @@ notmuch_directory_get_mtime (notmuch_directory_t 
*directory);
  *
  * The returned filenames will be the basename-entries only (not
  * complete paths).
+ *
+ * Returns NULL if it triggers a Xapian exception
  */
 notmuch_filenames_t *
 notmuch_directory_get_child_files (notmuch_directory_t *directory);
diff --git a/test/T563-lib-directory.sh b/test/T563-lib-directory.sh
index bbd12e12..739469a6 100755
--- a/test/T563-lib-directory.sh
+++ b/test/T563-lib-directory.sh
@@ -58,7 +58,6 @@ EOF
 test_expect_equal_file EXPECTED OUTPUT
 
 test_begin_subtest "get child filenames for a closed db"
-test_subtest_known_broken
 cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR}
 {
 notmuch_filenames_t *children;
-- 
2.27.0
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[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 @@ notmuch_config_list_key (notmuch_config_list_t 
*config_list);
  * next call to notmuch_config_list_value or notmuch config_list_destroy
  *
  * @since libnotmuch 4.4 (notmuch 0.23)
+ * @retval NULL for errors
  */
 const char *
 notmuch_config_list_value (notmuch_config_list_t *config_list);
diff --git a/test/T590-libconfig.sh b/test/T590-libconfig.sh
index 602fad0b..360e45b0 100755
--- a/test/T590-libconfig.sh
+++ b/test/T590-libconfig.sh
@@ -100,6 +100,28 @@ zzzafter afterval
 EOF
 test_expect_equal_file EXPECTED OUTPUT
 
+test_begin_subtest "notmuch_database_get_config_list: all pairs (closed db)"
+cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR}
+{
+   notmuch_config_list_t *list;
+   EXPECT0(notmuch_database_get_config_list (db, "", ));
+   EXPECT0(notmuch_database_close (db));
+   for (; notmuch_config_list_valid (list); notmuch_config_list_move_to_next 
(list)) {
+  printf("%s %d\n", notmuch_config_list_key (list), NULL == 
notmuch_config_list_value(list));
+   }
+   notmuch_config_list_destroy (list);
+}
+EOF
+cat <<'EOF' >EXPECTED
+== stdout ==
+aaabefore 1
+testkey1 1
+testkey2 1
+zzzafter 1
+== stderr ==
+EOF
+test_expect_equal_file EXPECTED OUTPUT
+
 test_begin_subtest "notmuch_database_get_config_list: one prefix"
 cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR}
 {
-- 
2.27.0
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[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 b/test/T563-lib-directory.sh
index 739469a6..4de31078 100755
--- a/test/T563-lib-directory.sh
+++ b/test/T563-lib-directory.sh
@@ -26,7 +26,7 @@ int main (int argc, char** argv)
  exit (1);
}
 
-   EXPECT0(notmuch_database_get_directory (db, "", ));
+   EXPECT0(notmuch_database_get_directory (db, "bar", ));
EXPECT0(notmuch_database_close (db));
 EOF
 
@@ -74,4 +74,21 @@ A Xapian exception occurred at lib/directory.cc:XXX: 
Database has been closed
 EOF
 test_expect_equal_file EXPECTED OUTPUT
 
+backup_database
+test_begin_subtest "delete directory document for a closed db"
+cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR}
+{
+stat = notmuch_directory_delete (dir);
+printf ("%d\n", stat == NOTMUCH_STATUS_SUCCESS || stat == 
NOTMUCH_STATUS_XAPIAN_EXCEPTION);
+stat = NOTMUCH_STATUS_SUCCESS;
+}
+EOF
+cat < EXPECTED
+== stdout ==
+1
+== stderr ==
+EOF
+test_expect_equal_file EXPECTED OUTPUT
+restore_database
+
 test_done
-- 
2.27.0
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[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 +285,37 @@ unread
 EOF
 test_expect_equal_file EXPECTED OUTPUT
 
+test_begin_subtest "collect tags with closed database"
+cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR}
+{
+  notmuch_messages_t *messages = notmuch_thread_get_messages (thread);
+
+  notmuch_tags_t *tags = notmuch_messages_collect_tags (messages);
+
+  const char *tag;
+  for (tags = notmuch_thread_get_tags (thread);
+   notmuch_tags_valid (tags);
+   notmuch_tags_move_to_next (tags))
+{
+  tag = notmuch_tags_get (tags);
+  printf ("%s\n", tag);
+}
+  notmuch_tags_destroy (tags);
+  notmuch_messages_destroy (messages);
+
+  printf("SUCCESS\n");
+}
+EOF
+cat < EXPECTED
+== stdout ==
+inbox
+signed
+unread
+SUCCESS
+== stderr ==
+EOF
+test_expect_equal_file EXPECTED OUTPUT
+
 test_begin_subtest "destroy thread with closed database"
 cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR}
 {
-- 
2.27.0
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[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
+++ b/test/T563-lib-directory.sh
@@ -57,4 +57,22 @@ A Xapian exception occurred at lib/directory.cc:XXX: 
Database has been closed
 EOF
 test_expect_equal_file EXPECTED OUTPUT
 
+test_begin_subtest "get child filenames for a closed db"
+test_subtest_known_broken
+cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR}
+{
+notmuch_filenames_t *children;
+children = notmuch_directory_get_child_files (dir);
+printf ("%d\n", children == NULL);
+stat = NOTMUCH_STATUS_XAPIAN_EXCEPTION;
+}
+EOF
+cat < EXPECTED
+== stdout ==
+1
+== stderr ==
+A Xapian exception occurred at lib/directory.cc:XXX: Database has been closed
+EOF
+test_expect_equal_file EXPECTED OUTPUT
+
 test_done
-- 
2.27.0
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[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
--- a/lib/directory.cc
+++ b/lib/directory.cc
@@ -49,6 +49,19 @@ struct _notmuch_directory {
 time_t mtime;
 };
 
+#define LOG_XAPIAN_EXCEPTION(directory, error) _log_xapian_exception 
(__location__, directory, error)
+
+static void
+_log_xapian_exception (const char *where, notmuch_directory_t *dir,  const 
Xapian::Error error) {
+notmuch_database_t *notmuch = dir->notmuch;
+_notmuch_database_log (notmuch,
+  "A Xapian exception occurred at %s: %s\n",
+  where,
+  error.get_msg ().c_str ());
+notmuch->exception_reported = true;
+}
+
+
 /* We end up having to call the destructor explicitly because we had
  * to use "placement new" in order to initialize C++ objects within a
  * block that we allocated with talloc. So C++ is making talloc
@@ -270,14 +283,18 @@ notmuch_filenames_t *
 notmuch_directory_get_child_directories (notmuch_directory_t *directory)
 {
 char *term;
-notmuch_filenames_t *child_directories;
+notmuch_filenames_t *child_directories = NULL;
 
 term = talloc_asprintf (directory, "%s%u:",
_find_prefix ("directory-direntry"),
directory->document_id);
 
-child_directories = _create_filenames_for_terms_with_prefix (directory,
-
directory->notmuch, term);
+try {
+   child_directories = _create_filenames_for_terms_with_prefix (directory,
+
directory->notmuch, term);
+} catch (Xapian::Error ) {
+   LOG_XAPIAN_EXCEPTION (directory, error);
+}
 
 talloc_free (term);
 
diff --git a/lib/notmuch.h b/lib/notmuch.h
index f9e9cc41..03db3b24 100644
--- a/lib/notmuch.h
+++ b/lib/notmuch.h
@@ -2158,6 +2158,8 @@ notmuch_directory_get_child_files (notmuch_directory_t 
*directory);
  *
  * The returned filenames will be the basename-entries only (not
  * complete paths).
+ *
+ * Returns NULL if it triggers a Xapian exception
  */
 notmuch_filenames_t *
 notmuch_directory_get_child_directories (notmuch_directory_t *directory);
diff --git a/test/T563-lib-directory.sh b/test/T563-lib-directory.sh
index e9e4cd0f..4d8b7e82 100755
--- a/test/T563-lib-directory.sh
+++ b/test/T563-lib-directory.sh
@@ -41,7 +41,6 @@ cat <<'EOF' > c_tail
 EOF
 
 test_begin_subtest "get child directories for a closed db"
-test_subtest_known_broken
 cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR}
 {
 notmuch_filenames_t *children;
-- 
2.27.0
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[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
 test_expect_equal_file EXPECTED OUTPUT
 
+test_begin_subtest "notmuch_database_get_config_list: closed db"
+cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR}
+{
+   notmuch_config_list_t *list;
+   EXPECT0(notmuch_database_close (db));
+   stat = notmuch_database_get_config_list (db, "nonexistent", );
+   printf("%d\n", stat == NOTMUCH_STATUS_XAPIAN_EXCEPTION);
+}
+EOF
+cat <<'EOF' >EXPECTED
+== stdout ==
+1
+== stderr ==
+EOF
+test_expect_equal_file EXPECTED OUTPUT
 
 test_begin_subtest "notmuch_database_get_config_list: all pairs"
 cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR}
-- 
2.27.0
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


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.

The not-completely-trivial changes are

[PATCH 05/13] lib: catch exceptions in  n_directory_get_child_directories
[PATCH 07/13] lib: catch exceptions in n_directory_get_child_files
[PATCH 13/13] lib: return NULL from n_d_get_default_indexopts on

The last one is a repost to keep the series together. 
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[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 b/lib/indexopts.c
index 1e8d180e..82a0026f 100644
--- a/lib/indexopts.c
+++ b/lib/indexopts.c
@@ -32,7 +32,7 @@ notmuch_database_get_default_indexopts (notmuch_database_t 
*db)
 char *decrypt_policy;
 notmuch_status_t err = notmuch_database_get_config (db, "index.decrypt", 
_policy);
 if (err)
-   return ret;
+   return NULL;
 
 if (decrypt_policy) {
if ((! (strcasecmp (decrypt_policy, "true"))) ||
diff --git a/lib/notmuch.h b/lib/notmuch.h
index 1fe62914..f3cb0fe2 100644
--- a/lib/notmuch.h
+++ b/lib/notmuch.h
@@ -2325,6 +2325,7 @@ notmuch_config_list_destroy (notmuch_config_list_t 
*config_list);
  * added to the index.  At the moment it is a featureless stub.
  *
  * @since libnotmuch 5.1 (notmuch 0.26)
+ * @retval NULL in case of error
  */
 notmuch_indexopts_t *
 notmuch_database_get_default_indexopts (notmuch_database_t *db);
diff --git a/test/T562-lib-database.sh b/test/T562-lib-database.sh
index 815c9856..d6097418 100755
--- a/test/T562-lib-database.sh
+++ b/test/T562-lib-database.sh
@@ -373,7 +373,6 @@ EOF
 test_expect_equal_file EXPECTED OUTPUT
 
 test_begin_subtest "get indexopts from closed database"
-test_subtest_known_broken
 cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR}
 {
 notmuch_indexopts_t *result;
-- 
2.27.0
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


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:

> Sandra Snan  writes:
>
>> Hi, I'm not sure what's tripping me up here.
>>
>> ellen% notmuch --version
>> notmuch 0.29.3
>> ellen% notmuch config set index.headers.Blahonga MIME-Version
>> ellen% notmuch config list|grep Blahonga
>> index.headers.Blahonga=MIME-Version
>
> That looks like a typo. it should be index.header.Blahonga. Unfortunately
> notmuch config is bad at catching typos.
>
>>
>> Sandra
>> PS I've loved notmuch since 2009. Best app of all time♥
>
> Thanks for your kind words.
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org