[PATCH] test: add regression test for Subject with newline.

2022-09-23 Thread David Bremner
This tests the issue reported by Thibault in id:87wn9w4xus@thb.lt
---

I could not duplicate the problem here. Maybe it depends on the version of 
gmime?
I have 3.2.9 here.

 test/T050-new.sh |  4 
 test/corpora/indexing/subject-newline:2, | 10 ++
 2 files changed, 14 insertions(+)
 create mode 100644 test/corpora/indexing/subject-newline:2,

diff --git a/test/T050-new.sh b/test/T050-new.sh
index cb67889c..0ac9fd7c 100755
--- a/test/T050-new.sh
+++ b/test/T050-new.sh
@@ -463,4 +463,8 @@ notmuch search 
id:20200930101213.2m2pt3jrspvcrxfx@localhost.localdomain > EXPECT
 notmuch search id:20200930101213.2m2pt3jrspvcrxfx@localhost.localdomain and 
ersatz > OUTPUT
 test_expect_equal_file_nonempty EXPECTED OUTPUT
 
+test_begin_subtest "base64 subject with newline"
+output=$(notmuch show id:subject-with-newl...@shopping.com | grep ^Subject:)
+test_expect_equal "${output}" \
+ "Subject: Livraison prévue pour aujourd’hui: RESTRAP Saddle 
Bag Saccoche..."
 test_done
diff --git a/test/corpora/indexing/subject-newline:2, 
b/test/corpora/indexing/subject-newline:2,
new file mode 100644
index ..bb2dde55
--- /dev/null
+++ b/test/corpora/indexing/subject-newline:2,
@@ -0,0 +1,10 @@
+From: "Thibault" 
+To: notmuch@notmuchmail.org
+Date: Wed, 18 Nov 2009 02:08:10 -0800
+Subject: =?UTF-8?B?TGl2cmFpc29uIHByw6l2dWUgcG91ciBhdWpvdXJk4oCZaHU=?=
+ =?UTF-8?B?aTogUkVTVFJBUCBTYWRkbGUgQmFnIFNhY2NvY2hlLi4u?=
+Message-ID: 
+
+The subject should be
+
+> Livraison prévue pour aujourd’hui: RESTRAP Saddle Bag Saccoche...
-- 
2.35.2

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


Re: [PATCH] emacs: add notmuch-search-edit-search and notmuch-tree-edit-search

2022-09-23 Thread David Bremner
Jose A Ortega Ruiz  writes:

> looks good, and very useful, to me, fwiw.
>
> now i'll have to free E in my keymap, which i was using for something
> else... i was thinking that, given how crowded those keymaps are
> becoming, it might be worth considering two-key chords, with the first
> grouping by "kind" (a la gnus); e.g. "/" could be a prefix for
> query-related ones.  another option for recent emacsen which include
> transient (the menu system used in magit, for instance) could be to
> write one for notmuch-search-mode and notmuch-tree-search-mode.

At the risk of stating the obvious, we already sortof have this with
notmuch-tag-jump and notmuch-jump-search. Maybe that code can be
generalized / re-used? It might just be familiarity, but I actually
prefer the way our "hydras" work to those of magit.

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


Re: [PATCH] emacs: add notmuch-search-edit-search and notmuch-tree-edit-search

2022-09-23 Thread David Bremner
Tomi Ollila  writes:

> ...and bind these to "E" in their respective keymaps.
>
> Expected to be called interactively, then using read-from-minibuffer
> with current search string as initial contents for editing.
> (Noninteractive use makes little sense, but is supported.)

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


Re: [PATCH] nmweb: escape subject in search view

2022-09-23 Thread David Bremner
David Bremner  writes:

> Fix a bug reported by Jakub Wilk [1].
>
> [1]: id:20220822064717.qftn4tr7cs4r2...@jwilk.net

applied to master

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


Re: [PATCH] test: replace aging OpenPGP key used in the test suite

2022-09-23 Thread David Bremner
Justus Winter  writes:

> This replaces the old OpenPGPv4 key that is used in the test suite
> with a more modern OpenPGPv4 key.  All cryptographic artifacts in the
> test suite are updated accordingly.
>
> Having old cryptographic artifacts in the test suite presents a
> problem once the old algorithms are rejected by contemporary
> implementations.
>

applied to master.

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


[PATCH v4] emacs: notmuch-tree-outline-mode

2022-09-23 Thread jao
With this mode, one can fold trees in the notmuch-tree buffer as if
they were outlines, using all the commands provided by
outline-minor-mode.  We also define a couple of movement commands
that, optional, will ensure that only the thread around point is
unfolded.

The implementation is based on the trick of inserting an invisible
prefix before each thread head that is then used as the regexp used by
outline-minor-mode to recognise headers.  The message plist is also
augmented with a :level property that provides a fast outline-level
function.

---
This version supesedes v3 (id:20220921225510.3159023-1-...@gnu.org)
by allowing notmuch-tree-ouline-mode to be enabled manually, not only
automatically via notmuch-tree-outline-enabled, which was misnamed in
the defcustom, by the way: we use now that name, as documented).

Signed-off-by: jao 
---
 doc/notmuch-emacs.rst |  20 +
 emacs/notmuch-tree.el | 176 ++
 2 files changed, 196 insertions(+)

diff --git a/doc/notmuch-emacs.rst b/doc/notmuch-emacs.rst
index 846f5e67..53e68c4d 100644
--- a/doc/notmuch-emacs.rst
+++ b/doc/notmuch-emacs.rst
@@ -606,6 +606,26 @@ can be controlled by the variable 
``notmuch-search-oldest-first``.
See also :el:defcustom:`notmuch-search-result-format` and
:el:defcustom:`notmuch-unthreaded-result-format`.
 
+It is also possible to enable outlines in notmuch tree buffers, via
+``notmuch-tree-outline-mode``.
+
+|docstring::notmuch-tree-outline-mode|
+
+The behaviour of this minor mode is affected by the following
+customizable variables:
+
+.. el:defcustom:: notmuch-tree-outline-enabled
+
+   |docstring::notmuch-tree-outline-enabled|
+
+.. el:defcustom:: notmuch-tree-outline-visibility
+
+   |docstring::notmuch-tree-outline-visibility|
+
+.. el:defcustom:: notmuch-tree-outline-auto-close
+
+   |docstring::notmuch-tree-outline-auto-close|
+
 
 .. _notmuch-unthreaded:
 
diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el
index 7ceddee2..bff29351 100644
--- a/emacs/notmuch-tree.el
+++ b/emacs/notmuch-tree.el
@@ -989,6 +989,7 @@ unchanged ADDRESS if parsing fails."
   ;; We need to save the previous subject as it will get overwritten
   ;; by the insert-field calls.
   (let ((previous-subject notmuch-tree-previous-subject))
+(notmuch-tree-outline--insert-prefix msg)
 (insert (notmuch-tree-format-field-list (notmuch-tree-result-format) msg))
 (notmuch-tree-set-message-properties msg)
 (notmuch-tree-set-prop :previous-subject previous-subject)
@@ -1036,6 +1037,8 @@ message together with all its descendents."
 (setq msg (plist-put msg :first (and first (eq 0 depth
 (setq msg (plist-put msg :tree-status tree-status))
 (setq msg (plist-put msg :orig-tags (plist-get msg :tags)))
+(setq msg (plist-put msg
+:level (1+ (if (and (eq 0 depth) (not first)) 1 
depth
 (notmuch-tree-goto-and-insert-msg msg)
 (pop tree-status)
 (pop tree-status)
@@ -1265,6 +1268,179 @@ search results and that are also tagged with the given 
TAG."
  nil
  notmuch-search-oldest-first)))
 
+;;; Tree outline mode
+ Custom variables
+(defcustom notmuch-tree-outline-enabled nil
+  "Whether to automatically activate `notmuch-tree-outline-mode' in tree 
views."
+  :type 'boolean)
+
+(defcustom notmuch-tree-outline-visibility 'hide-others
+  "Default state of the forest outline for `notmuch-tree-outline-mode'.
+This variable controls the state of a forest initially and after
+a movement command.  If set to nil, all trees are displayed while
+the symbol hide-all indicates that all trees in the forest should
+be folded and hide-other that only the first one should be
+unfolded."
+  :type '(choice (const :tag "Show all" nil)
+(const :tag "Hide others" hide-others)
+(const :tag "Hide all" hide-all)))
+
+(defcustom notmuch-tree-outline-auto-close nil
+  "Close message and tree windows when moving past the last message."
+  :type 'boolean)
+
+ Helper functions
+(defsubst notmuch-tree-outline--pop-at-end (pop-at-end)
+  (if notmuch-tree-outline-auto-close (not pop-at-end) pop-at-end))
+
+(defun notmuch-tree-outline--enable-mode ()
+  (when notmuch-tree-outline-enabled (notmuch-tree-outline-mode 1)))
+
+(add-hook 'notmuch-tree-mode-hook #'notmuch-tree-outline--enable-mode)
+
+(defun notmuch-tree-outline--set-visibility ()
+  (when (and notmuch-tree-outline-mode (> (point-max) (point-min)))
+(cond ((eq notmuch-tree-outline-visibility 'hide-others)
+  (notmuch-tree-outline-hide-others))
+ ((eq notmuch-tree-outline-visibility 'hide-all)
+  (outline-hide-body)
+
+(defun notmuch-tree-outline--on-exit (proc)
+  (when (eq (process-status proc) 'exit)
+(notmuch-tree-outline--set-visibility)))
+
+(add-hook 'notmuch-tree-process-exit-functions #'notmuch-tree-outline--on-exit)
+
+(defsubst notmuch-tree-outline--level (&optional props)
+  (or (plist-get (or props (

Re: [PATCH] test: replace aging OpenPGP key used in the test suite

2022-09-23 Thread Daniel Kahn Gillmor
I believe this is "v2" of Justus's earlier patch
id:20220909161354.715326-1-jus...@sequoia-pgp.org, even though the
subject line doesn't say "v2" in it:

On Thu 2022-09-22 10:46:06 +0200, Justus Winter wrote:
> This replaces the old OpenPGPv4 key that is used in the test suite
> with a more modern OpenPGPv4 key.  All cryptographic artifacts in the
> test suite are updated accordingly.
>
> Having old cryptographic artifacts in the test suite presents a
> problem once the old algorithms are rejected by contemporary
> implementations.
>
> For reference, this is the old key.
>
>   sec   rsa1024 2011-02-05 [SC]
> 5AEAB11F5E33DCE875DDB75B6D92612D94E46381
>   uid   [ unknown] Notmuch Test Suite  
> (INSECURE!)
>   ssb   rsa1024 2011-02-05 [E]
>
> And this is the new key.  Note that is has the same shape, but uses
> Ed25519 and Cv25519 instead of 1024-bit RSA.
>
>   sec   ed25519 2022-09-07 [SC]
> 9A3AFE6C60065A148FD4B58A7E6ABE924645CC60
>   uid   [ultimate] Notmuch Test Suite (INSECURE!) 
> 
>   ssb   cv25519 2022-09-07 [E]
> ---
>  configure |  8 +--
>  test/T356-protected-headers.sh|  8 +--
>  test/corpora/crypto/basic-encrypted.eml   | 13 +++--
>  .../crypto/encrypted-rfc822-attachment| 49 +--
>  test/corpora/crypto/encrypted-signed.eml  | 27 +-
>  test/corpora/mangling/mixed-up.eml| 14 ++
>  ...le-wrapped-with-phony-protected-header.eml | 37 +++---
>  ...pted-message-with-forwarded-attachment.eml | 29 ++-
>  .../encrypted-signed-not-masked.eml   | 25 +-
>  .../protected-headers/encrypted-signed.eml| 25 +-
>  .../misplaced-protected-header.eml| 36 --
>  .../nested-rfc822-message.eml | 23 -
>  .../no-protected-header-attribute.eml | 16 +++---
>  .../phony-protected-header-bad-encryption.eml | 13 ++---
>  .../protected-headers/protected-header.eml| 15 +++---
>  .../protected-with-legacy-display.eml | 38 +++---
>  .../signed-protected-header.eml   | 11 ++---
>  .../protected-headers/simple-signed-mail.eml  | 11 ++---
>  .../subjectless-protected-header.eml  | 15 +++---
>  .../wrapped-protected-header.eml  | 15 +++---
>  test/gnupg-secret-key.NOTE|  9 
>  test/gnupg-secret-key.asc | 34 -
>  test/openpgp4-secret-key.asc  | 15 ++
>  test/openpgp4-secret-key.asc.NOTE |  5 ++
>  test/test-lib.sh  |  6 +--
>  25 files changed, 236 insertions(+), 261 deletions(-)
>  delete mode 100644 test/gnupg-secret-key.NOTE
>  delete mode 100644 test/gnupg-secret-key.asc
>  create mode 100644 test/openpgp4-secret-key.asc
>  create mode 100644 test/openpgp4-secret-key.asc.NOTE
>
> diff --git a/configure b/configure
> index 5247e05a..be69b34d 100755
> --- a/configure
> +++ b/configure
> @@ -525,9 +525,9 @@ EOF
>   printf 'No.\nCould not make tempdir for testing session-key support.\n'
>   errors=$((errors + 1))
>  elif ${CC} ${CFLAGS} ${gmime_cflags} _check_session_keys.c 
> ${gmime_ldflags} -o _check_session_keys \
> -&& GNUPGHOME=${TEMP_GPG} gpg --batch --quiet --import < 
> "$srcdir"/test/gnupg-secret-key.asc \
> +&& GNUPGHOME=${TEMP_GPG} gpg --batch --quiet --import < 
> "$srcdir"/test/openpgp4-secret-key.asc \
>  && SESSION_KEY=$(GNUPGHOME=${TEMP_GPG} ./_check_session_keys) \
> -&& [ $SESSION_KEY = 
> 9:0BACD64099D1468AB07C796F0C0AC4851948A658A15B34E803865E9FC635F2F5 ]
> +&& [ $SESSION_KEY = 
> 9:496A0B6D15A5E7BA762FB8E5FE6DEE421D4D9BBFCEAD1CDD0CCF636D07ADE621 ]
>  then
>   printf "OK.\n"
>  else
> @@ -670,7 +670,7 @@ int main () {
>  body = GMIME_MULTIPART_ENCRYPTED(g_mime_message_get_mime_part 
> (g_mime_parser_construct_message (parser, NULL)));
>  if (body == NULL) return !!  fprintf (stderr, "did not find a 
> multipart/encrypted message\n");
>  
> -output = g_mime_multipart_encrypted_decrypt (body, GMIME_DECRYPT_NONE, 
> "9:13607E4217515A70EC8DF9DBC16C5327B94577561D98AD1246FA8756659C7899", 
> &result, &error);
> +output = g_mime_multipart_encrypted_decrypt (body, GMIME_DECRYPT_NONE, 
> "9:9E1CDF53BBF794EA34F894B5B68E1E56FB015EA69F81D2A5EAB7F96C7B65783E", 
> &result, &error);
>  if (error || output == NULL) return !! fprintf (stderr, "decrypt 
> failed\n");
>  
>  sig_list = g_mime_decrypt_result_get_signatures (result);
> @@ -691,7 +691,7 @@ EOF
>   printf 'No.\nCould not make tempdir for testing signature verification 
> when decrypting with session keys.\n'
>   errors=$((errors + 1))
>  elif ${CC} ${CFLAGS} ${gmime_cflags} _verify_sig_with_session_key.c 
> ${gmime_ldflags} -o _verify_sig_with_session_key \
> - && GNUPGHOME=${TEMP_GPG} gpg --batch --quiet --import < 
> "$srcdir"/test/gnupg-secret-key.asc \
> +