Re: bug: subject line with several chunks of base64

2022-12-09 Thread David Bremner
Emmanuel Beffara  writes:

> Hello,
>
> I am stumbling upon what looks to be a bug.
>
> Sometimes I receive messages where a header entry consists of several chunks
> of base64-encoded quoted utf-8 text. For instance:
>
> Subject: 
> =?UTF-8?B?dGhpcyBpcyBqdXN0IGFuIGV4YW1wbGUgZm9yIGRlbW9uc3RyYXRpb24gcHVycA==?=  
> =?UTF-8?B?b3Nlcw==?=
>
> For such input, `notmuch search` and `notmuch show` (whatever the output
> format) consider only the first block as part of the subject, the second block
> is ignored. Apparently, this happens when the first block is padded with =
> signs as in my example, not when the base64 encoded part is full.
>

This looks like the same bug as discussed at

 https://nmbug.notmuchmail.org/nmweb/show/87wn9w4xus@thb.lt

It turns out to be a bug in the GMime library, fixed upstream:

   https://github.com/jstedfast/gmime/commit/1a33a55baafc73b0

As far as I know that's not part of any GMime release yet. 
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: converting from nmh: how to?

2022-12-05 Thread David Bremner
Greg Minshall  writes:

> David,
>
>> notmuch tag -inbox '*'
>> notmuch tag +inbox path:relative/path/to/inbox/folder
>
> also, thanks.  i need to spend more time with =man
> notmuch-search-terms=.
>
>> you may want to use "notmuch dump > backup.tags" before some bold
>> experiments.
>
> a question: i'm still starting, experimenting, and i assume at some
> point i will throw my accumulated notmuch database away, and do a "new"
> to re-build from scratch.  given that, are there any dangers i should
> worry about while experimenting boldly?

Not that I can think of. But it's nice if throwing everything away is a
choice, rather than something forced upon you.

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


Re: converting from nmh: how to?

2022-12-05 Thread David Bremner
Greg Minshall  writes:

> hi.  apologies if this is an FAQ.
>
> i'm exploring notmuch (via the emacs front-end).  i have 1.2M e-mail
> messages sorted into 200 or so nmh folders.  (*)
>
> after running `notmuch new`, i end up with 1.2M "unread" messages, all
> in "inbox".
>
> i would like to end up with the "inbox" tag applied only to messages
> actually in my nmh +inbox folder; messages from *other* nmh folders
> should end up with a tag derived from that folder name.

If I remember how mh works you should be able to use something like

notmuch tag -inbox '*'
notmuch tag +inbox path:relative/path/to/inbox/folder

you may want to use "notmuch dump > backup.tags" before some bold experiments.

> and, i would like to have the "unread" tag only apply to messages that
> nmh thinks are unseen.
>
> (iiuc, nmh keeps track of unseen messages in ".mh_sequences" local to
> each nmh folder; i don't think i care about any other sequences,
> including "cur", in any of the ".mh_sequences" files.)
>
> is there a known procedure for accomplishing this?  or, thoughts on
> same?

notmuch does not index filenames, so that makes things a bit more
challenging. With a little scripting, you could extract the message-id
for message 'n' and pass that to notmuch. I'd probably write a python
script (and use the 'notmuch2' module), but it's doable as a shell
script also (given some hack to extract the message-id).

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


Re: [PATCH v7 1/1] emacs: notmuch-tree-outline-mode

2022-12-04 Thread David Bremner
jao  writes:
>
> diff --git a/doc/notmuch-emacs.rst b/doc/notmuch-emacs.rst
> index 846f5e67..b5f88a98 100644
> --- a/doc/notmuch-emacs.rst
> +++ b/doc/notmuch-emacs.rst
> @@ -606,6 +606,29 @@ 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``.
> +

I'm looking at the HTML output (I guess it's similar in the info output)
and I think this probably needs a sub-heading 


> +|docstring::notmuch-tree-outline-mode|

Unfortunately the more ambitious docstrings don't really transfer across
to rst. Probably it is easier to write a new blurb rather than fix the tooling.

I also felt like I wasn't really clear on what to do with the minor mode
from the docstring.

>  
> diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el
> index b3c2c992..47bd17bc 100644
> --- a/emacs/notmuch-tree.el
> +++ b/emacs/notmuch-tree.el
> @@ -1034,6 +1034,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

Probably I'm just being lazy, but it would be nice to have a comment
here why level is needed in addition to depth.

more later, I hope...

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


[PATCH 2/3] test: add known broken test for exception handling in _n_m_delete

2022-12-03 Thread David Bremner
In [1], Thomas Schneider reported an uncaught Xapian exception when
running out of disk space. We generate the same exception via database
corruption.

[1]: id:wwuk039sk2p@chaotikum.eu
---
 test/T566-lib-message.sh | 28 
 1 file changed, 28 insertions(+)

diff --git a/test/T566-lib-message.sh b/test/T566-lib-message.sh
index 511d56ca..562ab05a 100755
--- a/test/T566-lib-message.sh
+++ b/test/T566-lib-message.sh
@@ -516,4 +516,32 @@ cat < EXPECTED
 EOF
 test_expect_equal_file EXPECTED OUTPUT
 
+TERMLIST_PATH=(${MAIL_DIR}/.notmuch/xapian/termlist.*)
+test_begin_subtest "remove message with corrupted db"
+test_subtest_known_broken
+backup_database
+cat c_head0 - c_tail <<'EOF' | test_private_C ${MAIL_DIR} ${TERMLIST_PATH}
+{
+notmuch_status_t status;
+
+int fd = open(argv[2],O_WRONLY|O_TRUNC);
+if (fd < 0) {
+fprintf (stderr, "error opening %s\n", argv[1]);
+exit (1);
+}
+
+stat = _notmuch_message_delete (message);
+printf ("%d\n", stat == NOTMUCH_STATUS_XAPIAN_EXCEPTION);
+}
+EOF
+cat < EXPECTED
+== stdout ==
+1
+== stderr ==
+A Xapian exception occurred at message.cc:XXX: EOF reading block YYY
+EOF
+sed 's/EOF reading block [0-9]*/EOF reading block YYY/' < OUTPUT > OUTPUT.clean
+test_expect_equal_file EXPECTED OUTPUT.clean
+restore_database
+
 test_done
-- 
2.35.2

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


[PATCH 3/3] lib/message: move xapian call inside try/catch block in _n_m_delete

2022-12-03 Thread David Bremner
The call to delete_document can throw exceptions (and can happen in
practice [1]), so catch the exception and extract the error
message. As a side effect, also move the call to _n_m_has_term inside
the try/catch. This should not change anything as that function
already traps any Xapian exceptions.

[1]: id:wwuk039sk2p@chaotikum.eu
---
 lib/message.cc   | 22 +++---
 test/T566-lib-message.sh |  1 -
 2 files changed, 11 insertions(+), 12 deletions(-)

diff --git a/lib/message.cc b/lib/message.cc
index 1c87f8c0..5ccca95a 100644
--- a/lib/message.cc
+++ b/lib/message.cc
@@ -1383,21 +1383,21 @@ _notmuch_message_delete (notmuch_message_t *message)
 if (status)
return status;
 
-message->notmuch->writable_xapian_db->delete_document (message->doc_id);
-
-/* if this was a ghost to begin with, we are done */
-private_status = _notmuch_message_has_term (message, "type", "ghost", 
_ghost);
-if (private_status)
-   return COERCE_STATUS (private_status,
- "Error trying to determine whether message was a 
ghost");
-if (is_ghost)
-   return NOTMUCH_STATUS_SUCCESS;
-
-/* look for a non-ghost message in the same thread */
 try {
Xapian::PostingIterator thread_doc, thread_doc_end;
Xapian::PostingIterator mail_doc, mail_doc_end;
 
+   message->notmuch->writable_xapian_db->delete_document (message->doc_id);
+
+   /* look for a non-ghost message in the same thread */
+   /* if this was a ghost to begin with, we are done */
+   private_status = _notmuch_message_has_term (message, "type", "ghost", 
_ghost);
+   if (private_status)
+   return COERCE_STATUS (private_status,
+ "Error trying to determine whether message 
was a ghost");
+   if (is_ghost)
+   return NOTMUCH_STATUS_SUCCESS;
+
_notmuch_database_find_doc_ids (message->notmuch, "thread", tid, 
_doc,
_doc_end);
_notmuch_database_find_doc_ids (message->notmuch, "type", "mail", 
_doc, _doc_end);
diff --git a/test/T566-lib-message.sh b/test/T566-lib-message.sh
index 562ab05a..7f0e8eb0 100755
--- a/test/T566-lib-message.sh
+++ b/test/T566-lib-message.sh
@@ -518,7 +518,6 @@ test_expect_equal_file EXPECTED OUTPUT
 
 TERMLIST_PATH=(${MAIL_DIR}/.notmuch/xapian/termlist.*)
 test_begin_subtest "remove message with corrupted db"
-test_subtest_known_broken
 backup_database
 cat c_head0 - c_tail <<'EOF' | test_private_C ${MAIL_DIR} ${TERMLIST_PATH}
 {
-- 
2.35.2

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


handle exceptions in _notmuch_message_delete

2022-12-03 Thread David Bremner
It's a bit tricky to test running out of disk space in the test suite but I 
think I caught the exception shown
in your first backtrace (which was not attached to your mail, only pasted to 
IRC).

#10 GlassWritableDatabase::delete_document(unsigned int) (this=0x55da391cc550, 
did=413358) at 
/tmp/portage/dev-libs/xapian-1.4.19/work/xapian-core-1.4.19/backends/glass/glass_database.cc:1223
#11 0x7fb7f3fba3a0 in _notmuch_message_delete(notmuch_message_t*) 
(message=0x55da5f74f070) at lib/message.cc:1374
#12 0x7fb7f3fb376a in notmuch_database_remove_message(notmuch_database_t*, 
char const*)
(notmuch=, filename=0x55da41a8c440 
"/var/dedup/qsx/maildir/AStA.INBOX.Admin/cur/1636633029.12621_18.neptun,U=9117:2,S")
 at lib/database.cc:1438
#13 0x55da374eea01 in remove_filename (notmuch=0x55da39183530, 
path=0x55da41a8c440 
"/var/dedup/qsx/maildir/AStA.INBOX.Admin/cur/1636633029.12621_18.neptun,U=9117:2,S",
 add_files_state=0x7ffe493a1440)
at notmuch-new.c:950
#14 0x55da374eed09 in _remove_directory (notmuch=0x55da39183530, 
path=0x55da3faad350 "/var/dedup/qsx/maildir/AStA.INBOX.Admin/cur", 
add_files_state=0x7ffe493a1440) at notmuch-new.c:987
#15 0x55da374eed79 in _remove_directory (notmuch=0x55da39183530, 
path=0x55da3a7349d0 "/var/dedup/qsx/maildir/AStA.INBOX.Admin", 
add_files_state=0x7ffe493a1440) at notmuch-new.c:998
#16 0x55da374ed6e5 in notmuch_new_command (notmuch=0x55da39183530, 
argc=, argv=) at notmuch-new.c:1267
#17 0x55da374e910b in main (argc=, argv=0x7ffe493a1bc8) at 
notmuch.c:588


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


[PATCH 1/3] lib/database: propagate status code from _notmuch_message_delete

2022-12-03 Thread David Bremner
_notmuch_message_delete can return (at least)
NOTMUCH_STATUS_XAPIAN_EXCEPTION, which we should not ignore.
---
 lib/database.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/database.cc b/lib/database.cc
index c05d70d3..d1e5f1af 100644
--- a/lib/database.cc
+++ b/lib/database.cc
@@ -1456,7 +1456,7 @@ notmuch_database_remove_message (notmuch_database_t 
*notmuch,
 if (status == NOTMUCH_STATUS_SUCCESS && message) {
status = _notmuch_message_remove_filename (message, filename);
if (status == NOTMUCH_STATUS_SUCCESS)
-   _notmuch_message_delete (message);
+   status = _notmuch_message_delete (message);
else if (status == NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID)
_notmuch_message_sync (message);
 
-- 
2.35.2

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


Re: [PATCH] doc: mark `--output=summary` as default

2022-12-03 Thread David Bremner
michaeljgruber+grubix+...@gmail.com writes:

> From: Michael J Gruber 
>
> `notmuch search` behaves differently depending on the output option: It
> either outputs information pertaining to all threads with matching
> messages (summary, threads) or to all matching messages (messages,
> files, tags). The man page refres solely to the former in the main
> description.
>
> Help the user by clearly marking `summary` as the default output option.

Applied to master.

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


Re: Inconsistent folder search results

2022-11-29 Thread David Bremner
mail...@z01d.net writes:

> I'm running :
> notmuch search --output=files --format=text folder:user@domain/INBOX
>
> For this query I get results mixed in from user@domain/Sent folder in 
> addition to expected results from the INBOX folder.
>
> For similar query to a different otheruser@otherdomain/INBOX folder I also 
> get results mixed in from various different folders.

Does the answer

 https://notmuchmail.org/faq/#index1h2

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


Re: [PATCH 3/3] emacs/show: use n-s-i-headerline to update tags

2022-11-15 Thread David Bremner
Tomi Ollila  writes:

>
> and then grepping thru notmuch source code:
>
> notmuch-tree.el:497:  (delete-region (point) (1+ (line-end-position)))
>
> -- it looks to me this could be simpler and faster alternative.
>

Applied to master with your suggested modification. Thanks for the
review.

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


[PATCH 2/3] emacs/show: add optional orig-tags argument to n-s-i-headerline

2022-11-11 Thread David Bremner
This will support use of this function in notmuch-show-update-tags.
---
 emacs/notmuch-show.el | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index b7a8de6a..5fb5ab31 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -530,7 +530,7 @@ Return unchanged ADDRESS if parsing fails."
  (plist-put msg :height height)
  height
 
-(defun notmuch-show-insert-headerline (msg-plist depth tags)
+(defun notmuch-show-insert-headerline (msg-plist depth tags  
orig-tags)
   "Insert a notmuch style headerline based on HEADERS for a
 message at DEPTH in the current thread."
   (let* ((start (point))
@@ -556,7 +556,7 @@ message at DEPTH in the current thread."
" ("
date
") ("
-   (notmuch-tag-format-tags tags tags)
+   (notmuch-tag-format-tags tags (or orig-tags tags))
")")
 (insert
  (if (> file-count 1)
-- 
2.35.1

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


[PATCH 3/3] emacs/show: use n-s-i-headerline to update tags

2022-11-11 Thread David Bremner
Although this has more steps than the previous regular expression
search and replace, it should be more robust against changes in the
headerline format, such as the inclusion of duplicate numbers (which
broke the previous version).
---
 emacs/notmuch-show.el | 22 ++
 1 file changed, 14 insertions(+), 8 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 5fb5ab31..c4e88be2 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -452,14 +452,20 @@ operation on the contents of the current buffer."
 (defun notmuch-show-update-tags (tags)
   "Update the displayed tags of the current message."
   (save-excursion
-(goto-char (notmuch-show-message-top))
-(when (re-search-forward "(\\([^()]*\\))$" (line-end-position) t)
-  (let ((inhibit-read-only t))
-   (replace-match (concat "("
-  (notmuch-tag-format-tags
-   tags
-   (notmuch-show-get-prop :orig-tags))
-  ")"))
+(let ((inhibit-read-only t)
+ (start (notmuch-show-message-top))
+ (depth (notmuch-show-get-prop :depth))
+ (orig-tags (notmuch-show-get-prop :orig-tags))
+ (props (notmuch-show-get-message-properties))
+ (extent (notmuch-show-message-extent)))
+  (goto-char start)
+  (notmuch-show-insert-headerline props depth tags orig-tags)
+  (put-text-property start (1+ start)
+:notmuch-message-properties props)
+  (put-text-property (car extent) (cdr extent) :notmuch-message-extent 
extent)
+  ;; delete original headerline, but do not save to kill ring
+  (delete-region
+   (point) (save-excursion (end-of-line nil) (1+ (point)))
 
 (defun notmuch-clean-address (address)
   "Try to clean a single email ADDRESS for display. Return a cons
-- 
2.35.1

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


[PATCH 1/3] emacs/show: use plist to pass message info to n-s-insert-headerline

2022-11-11 Thread David Bremner
This should allow calling notmuch-show-insert-headerline from other
places without duplicating the set of plist accesses.
---
 emacs/notmuch-show.el | 21 +++--
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index ec998ede..b7a8de6a 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -530,11 +530,18 @@ Return unchanged ADDRESS if parsing fails."
  (plist-put msg :height height)
  height
 
-(defun notmuch-show-insert-headerline (headers date tags depth duplicate 
file-count)
+(defun notmuch-show-insert-headerline (msg-plist depth tags)
   "Insert a notmuch style headerline based on HEADERS for a
 message at DEPTH in the current thread."
-  (let ((start (point))
-   (from (notmuch-sanitize
+  (let* ((start (point))
+(headers (plist-get msg-plist :headers))
+(duplicate (or (plist-get msg-plist :duplicate) 0))
+(file-count (length (plist-get msg-plist :filename)))
+(date (or (and notmuch-show-relative-dates
+   (plist-get msg-plist :date_relative))
+  (plist-get headers :Date)))
+(duplicate (or (plist-get msg-plist :duplicate) 0))
+(from (notmuch-sanitize
   (notmuch-show-clean-address (plist-get headers :From)
 (when (string-match "\\cR" from)
   ;; If the From header has a right-to-left character add
@@ -1171,8 +1178,6 @@ is out of range."
 (defun notmuch-show-insert-msg (msg depth)
   "Insert the message MSG at depth DEPTH in the current thread."
   (let* ((headers (plist-get msg :headers))
-(duplicate (or (plist-get msg :duplicate) 0))
-(files (length (plist-get msg :filename)))
 ;; Indentation causes the buffer offset of the start/end
 ;; points to move, so we must use markers.
 message-start message-end
@@ -1180,11 +1185,7 @@ is out of range."
 headers-start headers-end
 (bare-subject (notmuch-show-strip-re (plist-get headers :Subject
 (setq message-start (point-marker))
-(notmuch-show-insert-headerline headers
-   (or (and notmuch-show-relative-dates
-(plist-get msg :date_relative))
-   (plist-get headers :Date))
-   (plist-get msg :tags) depth duplicate files)
+(notmuch-show-insert-headerline msg depth (plist-get msg :tags))
 (setq content-start (point-marker))
 ;; Set `headers-start' to point after the 'Subject:' header to be
 ;; compatible with the existing implementation. This just sets it
-- 
2.35.1

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


Re: [PATCH] emacs: fix notmuch-show-update-tags to support duplicate files

2022-11-05 Thread David Bremner
Tomi Ollila  writes:


> Is this getting too complex (well, we may have other stuff with
> similar complexity there ;/) ?
>
> Is there any better solutions ?

I want to try redrawing the whole headerline. It should be more robust
against headerline format changes, but replacing the headerline has its
own complexities. I guess once I get something working, we can compare.
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: [PATCH] emacs: move From header addition to after header intern

2022-11-05 Thread David Bremner
Russell Sim  writes:

> OTHER-HEADERS are expected to be passed as strings, to match the
> implementation of `compose-mail'.  But the "From" header is currently
> expected to be passed as a symbol.  Instead the "From" header can be
> safely added after converting all the headers to symbols.

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


Re: [PATCH v2] cli: add options --offset and --limit to notmuch show

2022-11-05 Thread David Bremner
Robin Jarry  writes:

> notmuch search does not output header values. However, when browsing
> through a large email corpus, it can be time saving to be able to
> paginate without running notmuch show for each message/thread.
>
> Add --offset and --limit options to notmuch show. This is inspired from
> commit 796b629c3b82 ("cli: add options --offset and --limit to notmuch
> search").

applied to master

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


Re: [PATCH] emacs: fix dangling overlays in notmuch-search

2022-11-05 Thread David Bremner
Matt Armstrong  writes:

> notmuch-search-insert-authors now sets the evaporate property on the
> ellipsis overlays.  Emacs will delete them when the buffer contents
> are zeroed out, which happens with `notmuch-refresh-buffer`.  This
> prevents them from being collapsed to zero-width overlays in position
> 1.  See Emacs bug#58479.  An upcoming change in Emacs will make these
> dangling overlays visible to the user.
> ---
applied to master

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


Re: [PATCH] configure: use pkg-config for gpgme

2022-11-02 Thread David Bremner
Daniel Kahn Gillmor  writes:

> GnuPG upstream has supported pkg-config since gpgme version 1.13 and
> gpg-error 1.33, and now prefers the use of pkg-config by default,
> instead of relying on gpg-error-config and gpgme-config.
>
> As of libgpg-error 1.46, upstream deliberately does not ship
> gpg-error-config by default.  As of gpgme 1.18.0, upstream does not
> ship gpgme-config if gpg-error-config is also not present.
>
> Both of these versions of upstream libraries are in debian unstable
> now.  To the extent that notmuch is dependent on GnuPG, it should
> follow GnuPG upstream's lead.

How is the (debian specific) story for backports?

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


Re: Consider following XDG base directory specification

2022-10-24 Thread David Bremner
Dario  writes:

> I apologize in advance if the issue has already been raised by somebody else
> but I couldn't find anything on the bug tracker and furthermore I'm one of
> those freaks who prefer a de-cluttered home directory. ;-)
>
> Instead of saving config file in $HOME/.notmuch-config,
> ${XDG_CONFIG_HOME:-$HOME/notmuch}/notmuch-config (notmuchrc is a nice name 
> too)
> should be used for unix-based operating systems according to the XDG Base 
> Directory Specification.
>

See 

https://notmuchmail.org/doc/latest/man1/notmuch-config.html#configuration

> As well as keeping the home directory clean, the semantic separation of 
> config,
> runtime data, cache data and user-local software by the spec is helpful to 
> users
> and other tools (e.g. backup software).
>
> In terms of migration, I would suggest using the xdg-compilant config location
> if it exists and falling back to the current default location.

The priority of configurations is unlikely to change at this point. Too
much potential for breakage for too little gain.

d

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


[PATCH] CLI/git: use --exclude=false when calling notmuch-search

2022-10-16 Thread David Bremner
We use notmuch search in two places in notmuch-git.py: to find which
tags have a given prefix, and to see if message with given id exists
locally. In both cases we do not want the presence of exclude tags
(e.g. deleted) to change the results.
---
 notmuch-git.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

The effects of this bug are a bit subtle; out of 12324 messages tagged
'deleted', without this fix I was missing 25 messages. That probably
explains why I couldn't come up with a test to demonstrate the
issue. On other hand, I think it is pretty clearly the right thing to
do, even if most people don't notice a change.

diff --git a/notmuch-git.py b/notmuch-git.py
index ceb86fbc..57098aae 100644
--- a/notmuch-git.py
+++ b/notmuch-git.py
@@ -254,7 +254,7 @@ def count_messages(prefix=None):
 def get_tags(prefix=None):
 "Get a list of tags with a given prefix."
 (status, stdout, stderr) = _spawn(
-args=['notmuch', 'search', '--query=sexp', '--output=tags', 
_tag_query(prefix)],
+args=['notmuch', 'search', '--exclude=false', '--query=sexp', 
'--output=tags', _tag_query(prefix)],
 stdout=_subprocess.PIPE, wait=True)
 return [tag for tag in stdout.splitlines()]
 
@@ -719,7 +719,7 @@ class DatabaseCache:
 self._known[id] = False
 else:
 (_, stdout, stderr) = _spawn(
-args=['notmuch', 'search', '--output=files', 
'id:{0}'.format(id)],
+args=['notmuch', 'search', '--exclude=false', 
'--output=files', 'id:{0}'.format(id)],
 stdout=_subprocess.PIPE,
 wait=True)
 self._known[id] = stdout != None
-- 
2.35.2

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


Re: [PATCH] nmweb: Fix spacing around punctuation in headers

2022-10-14 Thread David Bremner
Jakub Wilk  writes:

> * David Bremner , 2022-10-11 08:20:
>>>This is completely untested, but hey, what could possibly go wrong?
>>
>>I've yolo-ed this into production on nmbug.notmuchmail.org. Maybe you 
>>can poke at it and see if it looks like you expect.
>
> Looks good. Thanks!
>

applied to master.

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


Re: Selection bug

2022-10-14 Thread David Bremner
Justus Winter  writes:

> I think I found a reproducer:
>
> mkdir -p /tmp/selection-bug/{tmp,new,cur}
> echo "[database]
> path=/tmp/selection-bug" > /tmp/selection-bug/notmuch-config
> NOTMUCH_CONFIG=/tmp/selection-bug/notmuch-config notmuch new
> NOTMUCH_CONFIG=/tmp/selection-bug/notmuch-config emacs -q --eval "(require 
> 'notmuch)"
> # M-x notmuch-hello, search for '*'
> notmuch show --format=raw id:87edvlanuh@tethera.net | 
> NOTMUCH_CONFIG=/tmp/selection-bug/notmuch-config notmuch insert
> # refresh search buffer, press down once, i.e. navigate to "End of search 
> results".
> notmuch show --format=raw id:87fsfuuxwn.fsf@thinkbox | 
> NOTMUCH_CONFIG=/tmp/selection-bug/notmuch-config notmuch insert
> notmuch show --format=raw id:8735buw7gf@ngraves.fr | 
> NOTMUCH_CONFIG=/tmp/selection-bug/notmuch-config notmuch insert
> # refresh search buffer, bug: Nicolas' mail is green, mine is opened on 
> pressing enter.

1) Do you think the particular messages matter? I don't have
   id:8735buw7gf@ngraves.fr

2) Just to be clear, that script has to be run manually, with the
   comments corresponding to interactive actions in emacs?

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


Re: Selection bug

2022-10-11 Thread David Bremner
Justus Winter  writes:

> there is a bug in notmuch emacs that is mildly annoying.  Sometimes when
> I refresh my search buffer, and there are new mails, the topmost
> (i.e. newest) message seems to be selected (i.e. with green background),
> but in fact if i hit enter (or do any other state changing action like
> tagging), notmuch emacs acts on the previously selected message.  There
> is a visual clue to that, the block cursor is still on that previously
> selected message.
>
> Still, I think it is a bug, and because the green background dominates
> the block cursor, I run into this all the time.

Hi Justus;

That should be hl-line-mode, not sure why it's not tracking your
cursor. Can you duplicate the issue in emacs -q? Also, what version of
emacs is this?

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


Re: [PATCH] nmweb: Fix spacing around punctuation in headers

2022-10-11 Thread David Bremner
Jakub Wilk  writes:

> ---
>  devel/notmuch-web/nmweb.py| 2 +-
>  devel/notmuch-web/templates/show.html | 4 ++--
>  2 files changed, 3 insertions(+), 3 deletions(-)
>
> This is completely untested, but hey, what could possibly go wrong?
>

I've yolo-ed this into production on nmbug.notmuchmail.org. Maybe you
can poke at it and see if it looks like you expect.

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


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

2022-10-10 Thread David Bremner
David Bremner  writes:

> 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.

Now that I have gmime 3.2.13 I can confirm your bug (my previously
posted test fails).  It seems the purely a gmime issue (the following
reproducer is thanks to Jakub Wilk; on debian it needs the package
gir1.2-gmime-3.0).

#!/usr/bin/python3

import pathlib
import tempfile

import gi
gi.require_version('GMime', '3.0')
from gi.repository import GMime
GMime.init()

msg = b'''\
Subject: =?UTF-8?B?SGVsbG8=?= =?UTF-8?B?IHdvcmxk?=

.
'''

with tempfile.NamedTemporaryFile() as tmpfile:
tmpfile.write(msg)
tmpfile.flush()
fp = GMime.StreamFile.open(tmpfile.name, 'r')
parser = GMime.Parser.new_with_stream(fp)
msg = parser.construct_message()
subject = msg.subject
expected = 'Hello world'
assert subject == expected, f'{subject!r} != {expected!r}'


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


Re: Test failure in Ubuntu 22.04 and 22.10 (new test)

2022-10-06 Thread David Bremner
Michael J Gruber  writes:

> Could it be that within a parallel make session, that gcc-make-call
> gets delegated to the master make jobserver and thus gcc returns too
> early? Wild speculation, I admit.

That's the kind of thing I would consider a bug in gcc.

> I haven't checked the code, but having those testhelpers as
> prerequisites of the test scripts may help in that case.

The test scripts are not make targets, so I don't really know how we
would specify prerequisites.
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: Test failure in Ubuntu 22.04 and 22.10 (new test)

2022-10-06 Thread David Bremner
Michael J Gruber  writes:

>
> Yes, lto-wrapper calls make.
>
> Are we compiling test functions on the fly during the test? In that
> case we need to make sure that each test depends on the build
> products, or else the test helper compilation and its users might run
> in parallel ...

Yes, we compile C code on the fly during the run of the tests. I'm not
really clear on what race condition you are anticipating, as neither the
compilation nor the other parts of the test are directly run by make.
Execution is sequential within each T*.sh file. Unless gcc is returning
before it has finished compilation (which I think we'd all agree would
be gcc bug), I don't see how a race can arise there. One thing I can
imagine happening is gcc's recursive invocation of make somehow fails
under make -j, possibly something to do with violated assumptions about
the jobserver and/or environment variables.

d

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


Re: Test failure in Ubuntu 22.04 and 22.10 (new test)

2022-10-06 Thread David Bremner
David Bremner  writes:

> Gianfranco Costamagna  writes:
>
>> Hello, the test is now failing in Ubuntu 22.04 (last LTS), when run with 
>> parallel > 1
>>
>> (version 0.37)
>>
>> e.g. here you can see a build fail
>>
>> /<>/test/test-lib.sh: line 904: ./test19: No such file or 
>> directory
>> make[2]: *** read jobs pipe: Bad file descriptor.  Stop.
>> make[2]: *** Waiting for unfinished jobs
>> lto-wrapper: fatal error: make returned 2 exit status
>>
>>
>> https://launchpadlibrarian.net/627359226/buildlog_ubuntu-kinetic-amd64.notmuch_0.37-1ubuntu3_BUILDING.txt.gz
>>
>> Running dh_auto_test with --no-parallel flag works as workaround, and using 
>> last gmame from Debian doesn't fix the issue
>> (you can see in the above build log the version that is used Get:2 
>> http://ppa.launchpadcontent.net/costamagnagianfranco/locutusofborg-ppa/ubuntu
>>  kinetic/main amd64 libgmime-3.0-0 amd64 3.2.13+dfsg-2 [177 kB] )
>>
>>
>> Looks like all the tests using test_private_C function are failing, but I 
>> can't figure out where its the race-condition.
>
> It's especially puzzling as make -j$(whatever) should not enable running
> the test suite in parallel, only the presence of (GNU|moreutils)
> parallel. So it's like something is cleaning up after the test suite too
> early.

A second look at the log I see lto-wrapper failing, presumably in trying
to the test binaries.  I can duplicate the problem by adding -flto to
CFLAGS and CXXFLAGS. It _looks_ like lto-wrapper is invoking make
internally? 

Anyway, if you have an lto expert (or you are one), it would be
interesting to get feedback on what those error messages mean, and why
they are only triggered under make -j.


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


Re: Test failure in Ubuntu 22.04 and 22.10 (new test)

2022-10-06 Thread David Bremner
Gianfranco Costamagna  writes:

> Hello, the test is now failing in Ubuntu 22.04 (last LTS), when run with 
> parallel > 1
>
> (version 0.37)
>
> e.g. here you can see a build fail
>
> /<>/test/test-lib.sh: line 904: ./test19: No such file or 
> directory
> make[2]: *** read jobs pipe: Bad file descriptor.  Stop.
> make[2]: *** Waiting for unfinished jobs
> lto-wrapper: fatal error: make returned 2 exit status
>
>
> https://launchpadlibrarian.net/627359226/buildlog_ubuntu-kinetic-amd64.notmuch_0.37-1ubuntu3_BUILDING.txt.gz
>
> Running dh_auto_test with --no-parallel flag works as workaround, and using 
> last gmame from Debian doesn't fix the issue
> (you can see in the above build log the version that is used Get:2 
> http://ppa.launchpadcontent.net/costamagnagianfranco/locutusofborg-ppa/ubuntu 
> kinetic/main amd64 libgmime-3.0-0 amd64 3.2.13+dfsg-2 [177 kB] )
>
>
> Looks like all the tests using test_private_C function are failing, but I 
> can't figure out where its the race-condition.

It's especially puzzling as make -j$(whatever) should not enable running
the test suite in parallel, only the presence of (GNU|moreutils)
parallel. So it's like something is cleaning up after the test suite too
early.
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: Splitting long lines in .notmuch-config

2022-10-05 Thread David Bremner
Rudolf Adamkovič  writes:

> Hi there!
>
> Is it possible to split long lines in the .notmuch-config?  I normally
> wrap my markup, config, and source files to 80 columns, but some of the
> queries I define in my .notmuch-config now sprawl for over 200 columns.
> I have tried to use two backslashes (\\) followed by a newline, like in
> say Bash, but that does not work.  Any tips?

Not sure if this helps, but we are using the GLib GKeyFile API, so
whatever it supports (if anything) for line continuation, we do too.

One not so nice strategy would be to break your queries up into several
subqueries and and/or them together.
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: Tag notmuch email based on header values?

2022-10-04 Thread David Bremner
Petter Reinholdtsen  writes:

> I would like to tag all emails with a specific header, but fail to find
> a way to do this.  Is this a missing feature in notmuch?
>
> To be specific, I want to filter out emails related to request tracker
> tickets owned by me at the time of the email.  These emails get a simple
> RFC 822 style header in each email, that look like this:
>
>   RT-Owner: myusername
>
> I tried searching for 'RT-Owner' without any success, and have read the
> normuch-search-terms(7) dokucmentation trying to find a clue.  Is there
> something obvious I am missing.
>
> PS: Please CC me on replies, as I am not subscribed to the list.
>

You can add RT-Owner as header to index (see notmuch-config(1)) and re-index.
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH 2/2] lib: add better diagnostics for over long filenames.

2022-10-02 Thread David Bremner
Previously we just crashed with an internal error. With this change,
the caller can handle it better, although the error code could be
further improved.
---
 lib/message.cc   | 15 +++
 test/T050-new.sh |  1 -
 2 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/lib/message.cc b/lib/message.cc
index 1c87f8c0..0e6ea809 100644
--- a/lib/message.cc
+++ b/lib/message.cc
@@ -941,6 +941,7 @@ _notmuch_message_add_filename (notmuch_message_t *message,
 {
 const char *relative, *directory;
 notmuch_status_t status;
+notmuch_private_status_t private_status;
 void *local = talloc_new (message);
 char *direntry;
 
@@ -964,10 +965,16 @@ _notmuch_message_add_filename (notmuch_message_t *message,
 
 /* New file-direntry allows navigating to this message with
  * notmuch_directory_get_child_files() . */
-status = COERCE_STATUS (_notmuch_message_add_term (message, 
"file-direntry", direntry),
-   "adding file-direntry term");
-if (status)
-   return status;
+private_status =_notmuch_message_add_term (message, "file-direntry", 
direntry);
+switch (private_status) {
+case NOTMUCH_PRIVATE_STATUS_SUCCESS:
+   break;
+case NOTMUCH_PRIVATE_STATUS_TERM_TOO_LONG:
+   _notmuch_database_log(message->notmuch, "filename too long for 
file-direntry term: %s\n", filename);
+   return NOTMUCH_STATUS_FILE_ERROR;
+default:
+   return COERCE_STATUS (private_status, "adding file-direntry term");
+}
 
 status = _notmuch_message_add_folder_terms (message, directory);
 if (status)
diff --git a/test/T050-new.sh b/test/T050-new.sh
index 74890928..bf086609 100755
--- a/test/T050-new.sh
+++ b/test/T050-new.sh
@@ -384,7 +384,6 @@ EOF
 test_expect_equal_file EXPECTED OUTPUT
 
 test_begin_subtest "Long file names have reasonable diagnostics"
-test_subtest_known_broken
 printf -v name 'f%.0s' {1..234}
 generate_message "[filename]=$name"
 notmuch new 2>&1 | notmuch_dir_sanitize >OUTPUT
-- 
2.35.2

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


[PATCH 1/2] test: add known broken test for diagnostics from over long filenames.

2022-10-02 Thread David Bremner
Previously we tested over long directory names, add similar testing
for over long filenames.
---
 test/T050-new.sh | 15 +++
 1 file changed, 15 insertions(+)

diff --git a/test/T050-new.sh b/test/T050-new.sh
index cb67889c..74890928 100755
--- a/test/T050-new.sh
+++ b/test/T050-new.sh
@@ -383,6 +383,21 @@ No new mail. Removed 1 message.
 EOF
 test_expect_equal_file EXPECTED OUTPUT
 
+test_begin_subtest "Long file names have reasonable diagnostics"
+test_subtest_known_broken
+printf -v name 'f%.0s' {1..234}
+generate_message "[filename]=$name"
+notmuch new 2>&1 | notmuch_dir_sanitize >OUTPUT
+rm ${MAIL_DIR}/${name}
+cat < EXPECTED
+Unexpected error with file MAIL_DIR/$name
+add_file: Something went wrong trying to read or write a file
+filename too long for file-direntry term: MAIL_DIR/$name
+Processed 1 file in almost no time.
+No new mail.
+EOF
+test_expect_equal_file EXPECTED OUTPUT
+
 test_begin_subtest "Xapian exception: read only files"
 chmod u-w ${MAIL_DIR}/.notmuch/xapian/*.*
 output=$(NOTMUCH_NEW --debug 2>&1 | sed 's/: .*$//' )
-- 
2.35.2

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


[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


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

2022-09-19 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.
>
> 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]

The configure script still looks for gnupg-secret-key.asc, so that needs
to be updated as well.

I applied the first patch in the series to master

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


Re: Notmuch emacs client is slow when opening inbox.

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

> On Sun, Sep 18 2022, David Bremner wrote:
>
>> Jose A Ortega Ruiz  writes:
>>>
>>> interesting!  if we were to have this, i think i'd prefer pagination
>>> rather than increasing the limit and keeping the old ones, and make it
>>> work for tree searches too.  and perhaps the limit (page size) could be
>>> a query parameter, so that one could have different page sizes for
>>> different queries.  if that makes sense (and i'm not missing a better
>>> way already in place), i might try to implement it when i have a bit of
>>> time.
>>
>> Before going to far with pagination, maybe get Jani to recap the
>> difficulties he saw at the time that led him to propose the simpler
>> approach.
>>
>> I can think of a few issues, but I don't really know if they are
>> blockers.
>> - the result set is going to vary dynamically as messages are added and
>>   removed from the database
>>
>> - As far as I can tell, there isn't really an easy way to jump to page
>> n of the results.
>
> fwiw, my idea here was to always run the full, non-paginated query, and
> populate its result buffer just as now, but show, instead of that
> buffer, an indirect buffer pointing to it, narrowed to the page at hand.
[snip]
> not as efficient as a limit/offset query per page, but i think the
> bottleneck here is in displaying results rather than running the query
> in most cases, isn't it?

Ah, indeed that sounds like a different approach than was previously
mooted. I guess it might be a simple-ish way of making the display more
lazy, which I agree is most likely the bottleneck most people are seeing.
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: Notmuch emacs client is slow when opening inbox.

2022-09-18 Thread David Bremner
Jose A Ortega Ruiz  writes:
>
> interesting!  if we were to have this, i think i'd prefer pagination
> rather than increasing the limit and keeping the old ones, and make it
> work for tree searches too.  and perhaps the limit (page size) could be
> a query parameter, so that one could have different page sizes for
> different queries.  if that makes sense (and i'm not missing a better
> way already in place), i might try to implement it when i have a bit of
> time.

Before going to far with pagination, maybe get Jani to recap the
difficulties he saw at the time that led him to propose the simpler
approach.

I can think of a few issues, but I don't really know if they are
blockers.
- the result set is going to vary dynamically as messages are added and
  removed from the database

- As far as I can tell, there isn't really an easy way to jump to page n of the 
results.
___
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-16 Thread David Bremner
David Bremner  writes:

> Fix a bug reported by Jakub Wilk [1].
>
> [1]: id:20220822064717.qftn4tr7cs4r2...@jwilk.net
> ---
>  devel/notmuch-web/nmweb.py | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/devel/notmuch-web/nmweb.py b/devel/notmuch-web/nmweb.py
> index 928e4863..7b555c62 100755
> --- a/devel/notmuch-web/nmweb.py
> +++ b/devel/notmuch-web/nmweb.py
> @@ -131,7 +131,7 @@ env.globals['mailto_addrs'] = mailto_addrs
>  def link_msg(msg):
>lnk = quote_plus(msg.messageid.encode('utf8'))
>try:
> -subj = msg.header('Subject')
> +subj = html.escape(msg.header('Subject'))
>except LookupError:
>  subj = ""
>out = '%s' % (prefix, lnk, subj)
> -- 
> 2.35.2

I've deployed this patch on nmbug.notmuchmail.org. It seems to do the
right thing, at least for Jakub's original reported message.

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


Re: best practices for keeping a notmuch tag in sync with maildir folder

2022-09-05 Thread David Bremner
Bence Ferdinandy  writes:

> are there any best practices for keeping notmuch tags synced with an imap
> folder? It seems to me that simply moving a mail file in the shell from one
> folder to the other is not something that works well, at least with mbsync
> the moved file didn't appear in my webmail (I would like to keep a few tags
> mapped one-to-one with folders so I have a rudimentary access to some tags
> on my phone and webmail).

As far as I know (as a non-mbsync user) this is only a problem for
mbsync. Notmuch itself is fine with moving (or copying) files between
folders. You will have to run notmuch-new afterwards. If I remember
correctly mbsync encodes an IMAP UUID into the file name, but I don't
know the details. I guess that the general mbsync instructions for how
to move messages should work fine with notmuch.

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


Re: feature request: notmuch-show-print-message w/prefix to print PS to file

2022-09-05 Thread David Bremner
Alexander Adolf  writes:

> Hello,
>
> I'd like to request a feature. My intent is to redirect PostScript
> printing of a message via `notmuch-show-print-message` to a file.
> Ideally (IMHO) `notmuch-show-print-message` would accept an optional
> prefix argument ("C-u"), which would be passed down to
> `ps-print-buffer`, which would then prompt me for the name of the file,
> and save the PS to that file.
>
> This would be specific to ps-print, and does not make sense for lpr
> printing, of course.
>

One workaround is to set notmuch-print-mechanism to
notmuch-print-ps-print/evince, and save the file from evince.
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH] nmweb: escape subject in search view

2022-09-05 Thread David Bremner
Fix a bug reported by Jakub Wilk [1].

[1]: id:20220822064717.qftn4tr7cs4r2...@jwilk.net
---
 devel/notmuch-web/nmweb.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/devel/notmuch-web/nmweb.py b/devel/notmuch-web/nmweb.py
index 928e4863..7b555c62 100755
--- a/devel/notmuch-web/nmweb.py
+++ b/devel/notmuch-web/nmweb.py
@@ -131,7 +131,7 @@ env.globals['mailto_addrs'] = mailto_addrs
 def link_msg(msg):
   lnk = quote_plus(msg.messageid.encode('utf8'))
   try:
-subj = msg.header('Subject')
+subj = html.escape(msg.header('Subject'))
   except LookupError:
 subj = ""
   out = '%s' % (prefix, lnk, subj)
-- 
2.35.2

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


[PATCH 2/3] lib: parse index.as_text

2022-09-03 Thread David Bremner
We pre-parse into a list of compiled regular expressions to avoid
calling regexc on the hot (indexing) path.  As explained in the code
comment, this cannot be done lazily with reasonable error reporting,
at least not without touching a lot of the code in index.cc.
---
 lib/database-private.h |  4 
 lib/open.cc| 53 ++
 2 files changed, 57 insertions(+)

diff --git a/lib/database-private.h b/lib/database-private.h
index b9be4e22..61232f1a 100644
--- a/lib/database-private.h
+++ b/lib/database-private.h
@@ -291,6 +291,10 @@ struct _notmuch_database {
 
 /* Track what parameters were specified when opening */
 notmuch_open_param_t params;
+
+/* list of regular expressions to check for text indexing */
+regex_t *index_as_text;
+size_t index_as_text_length;
 };
 
 /* Prior to database version 3, features were implied by the database
diff --git a/lib/open.cc b/lib/open.cc
index 67ff868c..54d1faf3 100644
--- a/lib/open.cc
+++ b/lib/open.cc
@@ -320,6 +320,8 @@ _alloc_notmuch (const char *database_path, const char 
*config_path, const char *
 notmuch->transaction_count = 0;
 notmuch->transaction_threshold = 0;
 notmuch->view = 1;
+notmuch->index_as_text = NULL;
+notmuch->index_as_text_length = 0;
 
 notmuch->params = NOTMUCH_PARAM_NONE;
 if (database_path)
@@ -427,6 +429,53 @@ _load_database_state (notmuch_database_t *notmuch)
notmuch, notmuch->xapian_db->get_uuid ().c_str ());
 }
 
+/* XXX This should really be done lazily, but the error reporting path in the 
indexing code
+ * would need to be redone to report any errors.
+ */
+notmuch_status_t
+_ensure_index_as_text (notmuch_database_t *notmuch, char **message)
+{
+int nregex = 0;
+regex_t *regexv = NULL;
+
+if (notmuch->index_as_text)
+   return NOTMUCH_STATUS_SUCCESS;
+
+for (notmuch_config_values_t *list = notmuch_config_get_values (notmuch,
+   
NOTMUCH_CONFIG_INDEX_AS_TEXT);
+notmuch_config_values_valid (list);
+notmuch_config_values_move_to_next (list)) {
+   regex_t *new_regex;
+   int rerr;
+   const char *str = notmuch_config_values_get (list);
+   size_t len = strlen (str);
+
+   /* str must be non-empty, because n_c_get_values skips empty
+* strings */
+   assert (len > 0);
+
+   regexv = talloc_realloc (notmuch, regexv, regex_t, nregex + 1);
+   new_regex = [nregex];
+
+   rerr = regcomp (new_regex, str, REG_EXTENDED | REG_NOSUB);
+   if (rerr) {
+   size_t error_size = regerror (rerr, new_regex, NULL, 0);
+   char *error = (char *) talloc_size (str, error_size);
+
+   regerror (rerr, new_regex, error, error_size);
+   IGNORE_RESULT (asprintf (message, "Error in index.as_text: %s: 
%s\n", error, str));
+
+   return NOTMUCH_STATUS_ILLEGAL_ARGUMENT;
+   }
+   nregex++;
+}
+
+notmuch->index_as_text = regexv;
+notmuch->index_as_text_length = nregex;
+
+return NOTMUCH_STATUS_SUCCESS;
+}
+
 static notmuch_status_t
 _finish_open (notmuch_database_t *notmuch,
  const char *profile,
@@ -531,6 +580,10 @@ _finish_open (notmuch_database_t *notmuch,
if (status)
goto DONE;
 
+   status = _ensure_index_as_text (notmuch, );
+   if (status)
+   goto DONE;
+
autocommit_str = notmuch_config_get (notmuch, 
NOTMUCH_CONFIG_AUTOCOMMIT);
if (unlikely (! autocommit_str)) {
INTERNAL_ERROR ("missing configuration for autocommit");
-- 
2.35.2

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


[PATCH 1/3] lib: add config key INDEX_AS_TEXT

2022-09-03 Thread David Bremner
Higher level processing as a list of regular expressions and
documentation will follow.
---
 lib/config.cc| 3 +++
 lib/notmuch.h| 1 +
 test/T030-config.sh  | 1 +
 test/T055-path-config.sh | 1 +
 test/T590-libconfig.sh   | 5 +
 5 files changed, 11 insertions(+)

diff --git a/lib/config.cc b/lib/config.cc
index 503a0c8b..2323860d 100644
--- a/lib/config.cc
+++ b/lib/config.cc
@@ -599,6 +599,8 @@ _notmuch_config_key_to_string (notmuch_config_key_t key)
return "database.autocommit";
 case NOTMUCH_CONFIG_EXTRA_HEADERS:
return "show.extra_headers";
+case NOTMUCH_CONFIG_INDEX_AS_TEXT:
+   return "index.as_text";
 default:
return NULL;
 }
@@ -642,6 +644,7 @@ _notmuch_config_default (notmuch_database_t *notmuch, 
notmuch_config_key_t key)
else
email = _get_email_from_passwd_file (notmuch);
return email;
+case NOTMUCH_CONFIG_INDEX_AS_TEXT:
 case NOTMUCH_CONFIG_NEW_IGNORE:
return "";
 case NOTMUCH_CONFIG_AUTOCOMMIT:
diff --git a/lib/notmuch.h b/lib/notmuch.h
index 0b0540b1..935a8d59 100644
--- a/lib/notmuch.h
+++ b/lib/notmuch.h
@@ -2558,6 +2558,7 @@ typedef enum {
 NOTMUCH_CONFIG_USER_NAME,
 NOTMUCH_CONFIG_AUTOCOMMIT,
 NOTMUCH_CONFIG_EXTRA_HEADERS,
+NOTMUCH_CONFIG_INDEX_AS_TEXT,
 NOTMUCH_CONFIG_LAST
 } notmuch_config_key_t;
 
diff --git a/test/T030-config.sh b/test/T030-config.sh
index 43bbce31..ea0b4012 100755
--- a/test/T030-config.sh
+++ b/test/T030-config.sh
@@ -57,6 +57,7 @@ database.mail_root=MAIL_DIR
 database.path=MAIL_DIR
 foo.list=this;is another;list value;
 foo.string=this is another string value
+index.as_text=
 maildir.synchronize_flags=true
 new.ignore=
 new.tags=unread;inbox
diff --git a/test/T055-path-config.sh b/test/T055-path-config.sh
index fe295324..efc79e8b 100755
--- a/test/T055-path-config.sh
+++ b/test/T055-path-config.sh
@@ -299,6 +299,7 @@ database.backup_dir
 database.hook_dir
 database.mail_root=MAIL_DIR
 database.path
+index.as_text=
 maildir.synchronize_flags=true
 new.ignore=
 new.tags=unread;inbox
diff --git a/test/T590-libconfig.sh b/test/T590-libconfig.sh
index 26a1f033..9326ba3e 100755
--- a/test/T590-libconfig.sh
+++ b/test/T590-libconfig.sh
@@ -440,6 +440,7 @@ cat <<'EOF' >EXPECTED
 10: 'USER_FULL_NAME'
 11: '8000'
 12: 'NULL'
+13: ''
 == stderr ==
 EOF
 unset MAILDIR
@@ -725,6 +726,7 @@ test_expect_equal_file EXPECTED OUTPUT
 test_begin_subtest "list by keys (ndlc)"
 notmuch config set search.exclude_tags "foo;bar;fub"
 notmuch config set new.ignore "sekrit_junk"
+notmuch config set index.as_text "text/"
 cat c_head2 - c_tail <<'EOF' | test_C ${MAIL_DIR} %NULL% %NULL%
 {
 notmuch_config_key_t key;
@@ -751,6 +753,7 @@ cat <<'EOF' >EXPECTED
 10: 'Notmuch Test Suite'
 11: '8000'
 12: 'NULL'
+13: 'text/'
 == stderr ==
 EOF
 test_expect_equal_file EXPECTED OUTPUT
@@ -785,6 +788,7 @@ cat <<'EOF' >EXPECTED
 10: 'USER_FULL_NAME'
 11: '8000'
 12: 'NULL'
+13: ''
 == stderr ==
 EOF
 test_expect_equal_file EXPECTED OUTPUT.clean
@@ -856,6 +860,7 @@ database.backup_dir MAIL_DIR/.notmuch/backups
 database.hook_dir MAIL_DIR/.notmuch/hooks
 database.mail_root MAIL_DIR
 database.path MAIL_DIR
+index.as_text text/
 key with spaces value, with, spaces!
 maildir.synchronize_flags true
 new.ignore sekrit_junk
-- 
2.35.2

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


[PATCH 3/3] lib: index attachements with mime types matching index.as_text

2022-09-03 Thread David Bremner
Instead of skipping indexing all attachments, we check of a (user
configured) mime type that is indexable as text.
---
 doc/man1/notmuch-config.rst |  7 +++
 lib/database.cc | 12 
 lib/index.cc| 25 ++---
 lib/notmuch-private.h   |  4 
 test/T050-new.sh| 37 -
 5 files changed, 81 insertions(+), 4 deletions(-)

diff --git a/doc/man1/notmuch-config.rst b/doc/man1/notmuch-config.rst
index 388315f6..caa3bd65 100644
--- a/doc/man1/notmuch-config.rst
+++ b/doc/man1/notmuch-config.rst
@@ -122,6 +122,13 @@ paths are presumed relative to `$HOME` for items in section
 
 Default tag prefix (filter) for :any:`notmuch-git`.
 
+.. nmconfig:: index.as_text
+
+   List of regular expressions (without delimiters) for MIME types to
+   be indexed as text. Currently this applies only to attachments.
+
+   History: This configuration value was introduced in notmuch 0.38.
+
 .. nmconfig:: index.decrypt
 
 Policy for decrypting encrypted messages during indexing.  Must be
diff --git a/lib/database.cc b/lib/database.cc
index c05d70d3..6b962a15 100644
--- a/lib/database.cc
+++ b/lib/database.cc
@@ -1573,3 +1573,15 @@ notmuch_database_status_string (const notmuch_database_t 
*notmuch)
 {
 return notmuch->status_string;
 }
+
+bool
+_notmuch_database_indexable_as_text (notmuch_database_t *notmuch, const char 
*mime_string)
+{
+for (size_t i = 0; i < notmuch->index_as_text_length; i++) {
+   if (regexec (>index_as_text[i], mime_string, 0, NULL, 0) == 0) 
{
+   return true;
+   }
+}
+
+return false;
+}
diff --git a/lib/index.cc b/lib/index.cc
index 728bfb22..629dcb22 100644
--- a/lib/index.cc
+++ b/lib/index.cc
@@ -380,6 +380,23 @@ _index_pkcs7_part (notmuch_message_t *message,
   GMimeObject *part,
   _notmuch_message_crypto_t *msg_crypto);
 
+static bool
+_indexable_as_text (notmuch_message_t *message, GMimeObject *part)
+{
+GMimeContentType *content_type = g_mime_object_get_content_type (part);
+notmuch_database_t *notmuch = notmuch_message_get_database (message);
+
+if (content_type) {
+   char *mime_string = g_mime_content_type_get_mime_type (content_type);
+   if (mime_string) {
+   bool ret = _notmuch_database_indexable_as_text (notmuch, 
mime_string);
+   g_free (mime_string);
+   return ret;
+   }
+}
+return false;
+}
+
 /* Callback to generate terms for each mime part of a message. */
 static void
 _index_mime_part (notmuch_message_t *message,
@@ -497,9 +514,11 @@ _index_mime_part (notmuch_message_t *message,
_notmuch_message_add_term (message, "tag", "attachment");
_notmuch_message_gen_terms (message, "attachment", filename);
 
-   /* XXX: Would be nice to call out to something here to parse
-* the attachment into text and then index that. */
-   goto DONE;
+   if (! _indexable_as_text (message, part)) {
+   /* XXX: Would be nice to call out to something here to parse
+* the attachment into text and then index that. */
+   goto DONE;
+   }
 }
 
 byte_array = g_byte_array_new ();
diff --git a/lib/notmuch-private.h b/lib/notmuch-private.h
index 1d3d2b0c..c19ee8e2 100644
--- a/lib/notmuch-private.h
+++ b/lib/notmuch-private.h
@@ -259,6 +259,10 @@ _notmuch_database_filename_to_direntry (void *ctx,
notmuch_find_flags_t flags,
char **direntry);
 
+bool
+_notmuch_database_indexable_as_text (notmuch_database_t *notmuch,
+const char *mime_string);
+
 /* directory.cc */
 
 notmuch_directory_t *
diff --git a/test/T050-new.sh b/test/T050-new.sh
index cb67889c..427c5b22 100755
--- a/test/T050-new.sh
+++ b/test/T050-new.sh
@@ -455,12 +455,47 @@ Date: Fri, 17 Jun 2016 22:14:41 -0400
 EOF
 test_expect_equal_file EXPECTED OUTPUT
 
+add_email_corpus indexing
+test_begin_subtest "index text/* attachments, no config"
+messages=$(notmuch count 
id:20200930101213.2m2pt3jrspvcrxfx@localhost.localdomain)
+count=$(notmuch count id:20200930101213.2m2pt3jrspvcrxfx@localhost.localdomain 
and ersatz)
+test_expect_equal "$messages,$count" "1,0"
+
+notmuch config set index.as_text "text/"
 add_email_corpus indexing
 
 test_begin_subtest "index text/* attachments"
-test_subtest_known_broken
 notmuch search id:20200930101213.2m2pt3jrspvcrxfx@localhost.localdomain > 
EXPECTED
 notmuch search id:20200930101213.2m2pt3jrspvcrxfx@localhost.localdomain and 
ersatz > OUTPUT
 test_expect_equal_file_nonempty EXPECTED OUTPUT
 
+test_begin_subtest "reindex text/* attachments, no config"
+notmuch config set index.as_text
+notmuch reindex '*'
+messages=$(notmuch count 
id:20200930101213.2m2pt3jrspvcrxfx@localhost.localdomain)
+count=$(notmuch count id:20200930101213.2m2pt3jrspvcrxfx@localhost.localdomain 
and ersatz)
+test_expect_equal 

index user selected MIME types of attachments

2022-09-03 Thread David Bremner
This series obsoletes the WIP patch [1]. Most of the work is in making
it configurable.

[1]: id:20220820185007.289543-4-da...@tethera.net


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


Re: [PATCH 1/3] test: rename indexing corpus

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

> The corpus is not really suitable for general indexing test since the
> sole message is ignored (and will most likely continue to be ignored)
> by notmuch-new.

applied the first two patches (test changes) to master
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: Feature request: search for last N modified mails

2022-09-03 Thread David Bremner
Ico  writes:

> My normal mail workflow is to keep todo's in my inbox; these can be a few days
> or weeks old if I'm lazy. Every now and then I find myself accidentally
> removing things from the inbox, and I have a very hard time finding things
> back. As discussed on #notmuch IRC today: I'd like to request a feature for
> searching for the last N modified mails, as notmuch already has this info in
> the database.
>
> bremner suggested this could be implemented using with a query like
>
>lastmod:-10
>
>
>
> 14:39 < Zevv> basically, I'd like to be able to search for the last 10 
> modified
>   mails. Where 'modified' would probably mean changing tags
> 14:41 < bremner> Zevv: you can get the current value from notmuch count 
> --lastmod '*'
> 14:41 < bremner> then basically every tag change increments it
> 14:42 < bremner> so I guess subtract 10 and search?
> 14:44 < Zevv> Hm that would make it hard to use it as a simple query for in 
> alot
> 14:45 < bremner> yes.
> 14:45 < bremner> I never thought about it before, but it would be possible to
>  impliment lastmod:-10
> 14:47 < Zevv> that would be extremely handy

The syntax lastmod:-10.. (or '(lastmod -10 *)' is now  supported in git
master.

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


Re: [PATCH 1/3] lib/sexp: provide relative lastmod queries

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

> Test the relatively trivial logic changes for the sexp query parser
> first before refactoring that logic to share with the infix query
> parser.

series applied to master.

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


Re: Database location bug when database does not already exist

2022-09-03 Thread David Bremner
Sean Whitton  writes:

> Hello,
>
> In the following situation:
>
> - only notmuch config is ~/.notmuch-config
> - database.mail_root is set
> - database.path is not set
> - notmuch database does not yet exist
>
> then notmuch wants to create its db under mail_root/.notmuch, contrary
> to notmuch-config(1).
>

This bug should be fixed as of commit 84e4e130e2c920b3dee91901582c4ab6276e2630
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: [PATCH 2/6] test: add test for creating database in various configurations.

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

> The existing database creation (via add_email_corpus) was always done
> in the traditional configuration. The use of xapian-metadata is just
> to portably ensure that there is a database created where we expect
> there to be.

remainder of the series applied to master.

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


Re: [PATCH] emacs: new notmuch-tree-process-exit-functions

2022-09-03 Thread David Bremner
jao  writes:

> Hook run when the tree insertion process finishes its job.
>

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


Re: [PATCH] emacs/show: use read-shell-command instead of read-string

2022-09-03 Thread David Bremner
Antoine Beaupré  writes:

> This enables auto-completion of commands, something which plain
> read-string does not do. It's otherwise a drop-in
> replacement. According to `C-h f`, read-shell-command was introduced
> in Emacs 23.1 or earlier.

Applied to master.

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


notmuch release 0.37 now available

2022-08-21 Thread David Bremner

In addition to the "official" release notes below, I would like to
mention that we have passed 2000 tests (and that is not even counting
the individual python-cffi tests). Go us!

There will be a (hopefully) short delay for the debian upload while we
deal with the fallout of the emacs 28 upload.

Where to obtain notmuch 0.37
===
  https://notmuchmail.org/releases/notmuch-0.37.tar.xz

Which can be verified with:

  https://notmuchmail.org/releases/notmuch-0.37.tar.xz.sha256.asc
  -BEGIN PGP SIGNED MESSAGE-
  Hash: SHA256
  
  0e766df28b78bf4eb8235626ab1f52f04f1e366649325a8ce8d3c908602786f6  
notmuch-0.37.tar.xz
  -BEGIN PGP SIGNATURE-
  
  iQIzBAEBCAAdFiEEkiyHYXwaY0SiY6fqA0U5G1WqFSEFAmMClZkACgkQA0U5G1Wq
  FSEgpQ/+NQiWJTe0qxF9zIdioi+ca3bFL4CslzJPZZn4AKXWDEk0beZW9J+as0+L
  XgDYC3gcJbLEHqdMBUBq8a4URBbv0ilrvJontm8RF845N38XHusJLtFn46EFlq2w
  Fdqg04yxXVhKlrJPmD+zT536Tl4M5T/spiVtHv7ExFABKW/xFD8DMK96gLkmI8Zy
  hSAadLHpxxxmfPwUn2HHhU2eOezRl3VbQaqBDYhu9vj2y7uNZB3ifzj+/bXuc2QO
  BOQv+wz7f7t+nAXhMFI++sNqm18X5+p7LObGuiA5aek9wUioq0mo3nW1X+ifPFJa
  JrQh4d1Rjcw80ZGak/shUkxNECwvOonDW9q9nDFkQ7FVv8DRwrW7UcU96DRHHYQw
  YGZT6j/nzOrJpsS3ZWOut6S65j+nbUmn4hWTKT/z2xrRHJJclxAocWrvCVZ8vboh
  mFhTAqUjRtmZ5Sa6rLWz2mgbuBS1q53Gi6LeLf8yKhoC1EfB6/5zchVjxztMgk8L
  x9CeSb8D02kZfk3IR6ik8VgpQAYl7UQA1wN/zlnUSiBy0gx07buHwxLk2vclWSaJ
  ga/tVHWicQS3MNGaoyfve+bUuuxQfv1kZtKIOL1EmXR0oti4/7CCCBEUgypAFEOd
  ewcS7wEm0HlBi6ahD5f/vZoC79b1820INXDz8u5YE/S8Cuhg9tM=
  =kR2k
  -END PGP SIGNATURE-

  https://notmuchmail.org/releases/notmuch-0.37.tar.xz.asc
  (signed by David Bremner)

What's new in notmuch 0.37
=

Library
---

Fix uninitialized field in message objects.

Improve exception handling and error propagation for message objects.

Sexp Queries


Add one sided lastmod ranges for sexp queries.

Expand macro parameters inside regex and wildcard modifiers.

Command Line Interface
--

`notmuch help` now works for external commands.

`NOTMUCH_CONFIG` is now passed to external commands and hooks.

Promote the development tool `nmbug` to a user facing tool
`notmuch-git`. See notmuch-git(1) for details.

Emacs
-

The function `notmuch-mua-mail` now moves point depending on the
provided arguments.

Restrict what mime types are inlined in replies and on refresh.

The functions in notmuch-query.el are now obsolete and may be removed
in a future version of Notmuch.

Add some controls for lazy display of message bodies (See "Dealing
with large messages and threads" in the notmuch-emacs documentation).

Allow the user to select (with '%') a different duplicate message file
to display.

Use `message-dont-reply-to-names` in `notmuch-message-mode`.

Support custom header-line format for notmuch-show mode.

What is notmuch
===
Notmuch is a system for indexing, searching, reading, and tagging
large collections of email messages in maildir or mh format. It uses
the Xapian library to provide fast, full-text search with a convenient
search syntax.

For more about notmuch, see https://notmuchmail.org
make[1]: Leaving directory '/home/bremner/software/upstream/notmuch'


signature.asc
Description: PGP signature
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH 3/3] WIP/lib: index all text/* attachements.

2022-08-20 Thread David Bremner
This probably needs a stricter test, perhaps an explicit list
of (regexes? for) allowed types.
---
 lib/index.cc | 23 ---
 test/T050-new.sh |  1 -
 2 files changed, 20 insertions(+), 4 deletions(-)

diff --git a/lib/index.cc b/lib/index.cc
index 728bfb22..aca73580 100644
--- a/lib/index.cc
+++ b/lib/index.cc
@@ -380,6 +380,21 @@ _index_pkcs7_part (notmuch_message_t *message,
   GMimeObject *part,
   _notmuch_message_crypto_t *msg_crypto);
 
+static bool _indexable_mime_type (GMimeObject *part) {
+GMimeContentType *content_type = g_mime_object_get_content_type (part);
+
+if (content_type) {
+   char *mime_string = g_mime_content_type_get_mime_type (content_type);
+   if (mime_string) {
+   /* XXX TODO: use a more sensible test, maybe configurable */
+   bool ret = (STRNCMP_LITERAL (mime_string, "text/") == 0);
+   g_free (mime_string);
+   return ret;
+   }
+}
+return false;
+}
+
 /* Callback to generate terms for each mime part of a message. */
 static void
 _index_mime_part (notmuch_message_t *message,
@@ -497,9 +512,11 @@ _index_mime_part (notmuch_message_t *message,
_notmuch_message_add_term (message, "tag", "attachment");
_notmuch_message_gen_terms (message, "attachment", filename);
 
-   /* XXX: Would be nice to call out to something here to parse
-* the attachment into text and then index that. */
-   goto DONE;
+   if (! _indexable_mime_type (part)) {
+   /* XXX: Would be nice to call out to something here to parse
+* the attachment into text and then index that. */
+   goto DONE;
+   }
 }
 
 byte_array = g_byte_array_new ();
diff --git a/test/T050-new.sh b/test/T050-new.sh
index cb67889c..dd665de3 100755
--- a/test/T050-new.sh
+++ b/test/T050-new.sh
@@ -458,7 +458,6 @@ test_expect_equal_file EXPECTED OUTPUT
 add_email_corpus indexing
 
 test_begin_subtest "index text/* attachments"
-test_subtest_known_broken
 notmuch search id:20200930101213.2m2pt3jrspvcrxfx@localhost.localdomain > 
EXPECTED
 notmuch search id:20200930101213.2m2pt3jrspvcrxfx@localhost.localdomain and 
ersatz > OUTPUT
 test_expect_equal_file_nonempty EXPECTED OUTPUT
-- 
2.35.1

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


[PATCH 2/3] test: add known broken test for indexing text/* attachments

2022-08-20 Thread David Bremner
The general problem of indexing attachments requires some help to turn
things into text, but (most?) text/* should be doable internally,
possibly with optimizations as for the text/html case.
---
 test/T050-new.sh  |   8 +
 ...TCH-1-2-system_data_types.7-srcfix.txt:2,S | 282 ++
 2 files changed, 290 insertions(+)
 create mode 100644 
test/corpora/indexing/PATCH-1-2-system_data_types.7-srcfix.txt:2,S

diff --git a/test/T050-new.sh b/test/T050-new.sh
index 6791f87c..cb67889c 100755
--- a/test/T050-new.sh
+++ b/test/T050-new.sh
@@ -455,4 +455,12 @@ Date: Fri, 17 Jun 2016 22:14:41 -0400
 EOF
 test_expect_equal_file EXPECTED OUTPUT
 
+add_email_corpus indexing
+
+test_begin_subtest "index text/* attachments"
+test_subtest_known_broken
+notmuch search id:20200930101213.2m2pt3jrspvcrxfx@localhost.localdomain > 
EXPECTED
+notmuch search id:20200930101213.2m2pt3jrspvcrxfx@localhost.localdomain and 
ersatz > OUTPUT
+test_expect_equal_file_nonempty EXPECTED OUTPUT
+
 test_done
diff --git a/test/corpora/indexing/PATCH-1-2-system_data_types.7-srcfix.txt:2,S 
b/test/corpora/indexing/PATCH-1-2-system_data_types.7-srcfix.txt:2,S
new file mode 100644
index ..1361c6f2
--- /dev/null
+++ b/test/corpora/indexing/PATCH-1-2-system_data_types.7-srcfix.txt:2,S
@@ -0,0 +1,282 @@
+From mboxrd@z Thu Jan  1 00:00:00 1970
+Return-Path: 
+X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on
+   aws-us-west-2-korg-lkml-1.web.codeaurora.org
+X-Spam-Level: 
+X-Spam-Status: No, score=-8.3 required=3.0 tests=BAYES_00,DKIM_SIGNED,
+   DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,
+   
HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,
+   SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham 
autolearn_force=no
+   version=3.4.0
+Received: from mail.kernel.org (mail.kernel.org [198.145.29.99])
+   by smtp.lore.kernel.org (Postfix) with ESMTP id AFE3FC4727E
+   for ; Wed, 30 Sep 2020 10:12:21 + 
(UTC)
+Received: from vger.kernel.org (vger.kernel.org [23.128.96.18])
+   by mail.kernel.org (Postfix) with ESMTP id 4E0D62074A
+   for ; Wed, 30 Sep 2020 10:12:21 + 
(UTC)
+Authentication-Results: mail.kernel.org;
+   dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com 
header.b="Osm9Pn67"
+Received: (majord...@vger.kernel.org) by vger.kernel.org via listexpand
+id S1725823AbgI3KMU (ORCPT );
+Wed, 30 Sep 2020 06:12:20 -0400
+Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50038 "EHLO
+lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org
+with ESMTP id S1725779AbgI3KMU (ORCPT
+); Wed, 30 Sep 2020 06:12:20 -0400
+Received: from mail-pf1-x443.google.com (mail-pf1-x443.google.com 
[IPv6:2607:f8b0:4864:20::443])
+by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5026DC061755
+for ; Wed, 30 Sep 2020 03:12:20 -0700 (PDT)
+Received: by mail-pf1-x443.google.com with SMTP id b124so832681pfg.13
+for ; Wed, 30 Sep 2020 03:12:20 -0700 (PDT)
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
+d=gmail.com; s=20161025;
+h=date:from:to:cc:subject:message-id:references:mime-version
+ :content-disposition:in-reply-to:user-agent;
+bh=qR1FJVXOhU6/g+m4SoSco3vMtV+CNvRvNyXS1xuG+T4=;
+b=Osm9Pn67G380QiA1ORltntJShSHlKg/KZZfKV8ebvfEXJw9893EO0N6J6GDR+zkmHi
+ TOQuIe7x9y95Pipm54rWWEW33U3gwoXRHsPc2Kivm6L8Ixb+f0T0rMPKw/FOkL8OGo9t
+ WmmSvnlErAXHqBq9aRAJJsf2bSlDgdAyYY1Qe6PSq2hKi2rg+sOy1Vaj4RqZ6jTK/DWY
+ tX28Ql0XS3kKWp0Lc8MNsSP+SXlcdwHQYll5LeReAg1oi++hICgWphuMmo3OH+2B1WtO
+ hMH7VuUONqbuE1aLoZ6PyyUlCeN1soJd8bKY0cmY0TKCsw0Jvkuh/XzYDVNi6wOSM6Ez
+ okpA==
+X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
+d=1e100.net; s=20161025;
+h=x-gm-message-state:date:from:to:cc:subject:message-id:references
+ :mime-version:content-disposition:in-reply-to:user-agent;
+bh=qR1FJVXOhU6/g+m4SoSco3vMtV+CNvRvNyXS1xuG+T4=;
+b=TJU+duGLhruSES/5sJy4y1wfcltfokDpA58edkSUJyasvsooUo67VNtOB3ZK49iHm5
+ C/cjy0ExxTECB0aM6p+B1jcePdWoPUaVBY9bVd/Q5DNhm4KhTO8ON96gB43d2rLWLOiK
+ /Y1vCu+MwOpY0JQTojbC140s/JYccR/KPapTmbUkRzrpmeoYqw8CbBPV60rQxYCn9GUu
+ FeCXJY5q9OfaYW1viQZoBL5n1IMMpJDVa61Q8gZ33b3wRCvQv/x1eZCsVlYpjcqf7Umc
+ /Amx3i27cxvo8pSvvwiTzrlJHJv0Gkytz13i7s+zW+XKzZRyzy3yirtU2DFTGat6FeMn
+ H8Ig==
+X-Gm-Message-State: AOAM530Yon7xNOW6kiuy6bVpbpwbzR/9pldRB49OtZaSAHAZg7Gyf7qE
+JXgAH20rZzYlwqOZyeZCeAwtWh09PeI=
+X-Google-Smtp-Source: 
ABdhPJxzyZAVDBtMwQ5+dUqVg37y/LgZByrSaTxvhS6wnx6sJuG8ROItw0CwDAg939XUVADeje/nZQ==
+X-Received: by 2002:a63:c547:: with SMTP id g7mr1563654pgd.234.1601460739764;
+Wed, 30 Sep 2020 03:12:19 -0700 (PDT)
+Received: from localhost.localdomain ([1.129.172.177])
+by smtp.gmail.com with ESMTPSA id 
k14sm1804437pjd.45.2020.09.30.03.12.17
+

[PATCH 1/3] test: rename indexing corpus

2022-08-20 Thread David Bremner
The corpus is not really suitable for general indexing test since the
sole message is ignored (and will most likely continue to be ignored)
by notmuch-new.
---
 test/T070-insert.sh   | 2 +-
 test/corpora/{indexing => insert}/mbox-attachment.eml | 0
 2 files changed, 1 insertion(+), 1 deletion(-)
 rename test/corpora/{indexing => insert}/mbox-attachment.eml (100%)

diff --git a/test/T070-insert.sh b/test/T070-insert.sh
index 7d5f842d..73953272 100755
--- a/test/T070-insert.sh
+++ b/test/T070-insert.sh
@@ -293,7 +293,7 @@ for code in OUT_OF_MEMORY XAPIAN_EXCEPTION ; do
 done
 
 test_begin_subtest "insert converts mboxes on delivery"
-notmuch insert +unmboxed < 
"${TEST_DIRECTORY}"/corpora/indexing/mbox-attachment.eml
+notmuch insert +unmboxed < 
"${TEST_DIRECTORY}"/corpora/insert/mbox-attachment.eml
 output=$(notmuch count tag:unmboxed)
 test_expect_equal "${output}" 1
 
diff --git a/test/corpora/indexing/mbox-attachment.eml 
b/test/corpora/insert/mbox-attachment.eml
similarity index 100%
rename from test/corpora/indexing/mbox-attachment.eml
rename to test/corpora/insert/mbox-attachment.eml
-- 
2.35.1

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


WIP: index text attachments.

2022-08-20 Thread David Bremner
I'm curious if this really blows up indexing certain text/*
mime types. Certainly we had to add special handling for text/html so I'm
expecting some stricter set of types to be indexable.

For configuration I was thinking a list of regexes, in the style of
new.ignore. We still need to have some reasonable idea of default set
of attachements types to index.


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


Re: [Emacs] Using notmuch-address with EUDC, and completion-at-point

2022-08-18 Thread David Bremner
Alexander Adolf  writes:

>
> From what it sound s like, it would seem to make more sense to wait for
> that Emacs patch to get merged? Bundling the new code with notmuch, but
> without any integration with the rest of it, effectively leaving it to
> users to figure out how to make use of it wouldn't seem to make too much
> sense, OTOH.
>

One point is that it is unlikely that notmuch will ever require the most
recent version of emacs (currently the baseline is supposedly emacs
25.1). It's fine to optionally take advantage of new features in emacs,
but we want people to be able to use notmuch-emacs without necessarily
upgrading their version of Emacs.

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


Re: Formatting nm-search output

2022-08-18 Thread David Bremner
martin f krafft  writes:

> Is there a way to get notmuch search to print custom fields for the 
> messages it returns, i.e. if I wanted to get a list of messages (not 
> threads) matching my search terms, along with e.g. date, subject, 
> from/to/cc, and body size?

Hi Martin;

Currently the short answer is no. There are several possible
workarounds.

1) Use the (apparently undocumented!) --unthreaded option to notmuch
show and then postprocess the json output

2) write a python script (using the notmuch2 module).

I have thought about having some custom output formatting (probably
based on some sexp dsl, since the code already uses sfsexp for query
parsing) but I apparently it never got farther than thinking.

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


Re: [PATCH] test: increase cffi timeout

2022-08-16 Thread David Bremner
michaeljgruber+grubix+...@gmail.com writes:

> From: Michael J Gruber 
>
> By default, the test suite uses 2min for other tests and 5s for cffi
> tests. Sporadically, this leads to test failures caused by the timeout
> on slower or loaded test infrastructure (as seen on ppc64le in Fedora's
> infrastructure during branch time).
>
> Increase the cffi timeout to the same 2m=120s.
>
> Signed-off-by: Michael J Gruber 
> ---
> It's the first time I encountered this on Fedora's infrastructure during
> a test build. In any case, having the timeouts similar may make sense in
> general, unless we typically run into them in normal (local) use.
>

Applied to release and master.

It is still not exactly consistent with the other tests, since the
remaining tests have a 2 minute timeout per test script T*.sh, not per
subtest. The python CFFI tests have timeouts for both.

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


[PATCH 2/3] lib: factor out lastmod range handling from sexp parser.

2022-08-14 Thread David Bremner
This will permit the re-use of the same logic in the infix query
parser. The location of the shared code in the infix side is for
consistency with the other shared parsing logic. It will make more
sense when a Xapian field processor is added for the lastmod prefix.
---
 lib/Makefile.local |  3 +-
 lib/database-private.h |  6 
 lib/lastmod-fp.cc  | 68 ++
 lib/parse-sexp.cc  | 37 ---
 4 files changed, 82 insertions(+), 32 deletions(-)
 create mode 100644 lib/lastmod-fp.cc

diff --git a/lib/Makefile.local b/lib/Makefile.local
index 6d67a2a4..4e766305 100644
--- a/lib/Makefile.local
+++ b/lib/Makefile.local
@@ -65,7 +65,8 @@ libnotmuch_cxx_srcs = \
$(dir)/open.cc  \
$(dir)/init.cc  \
$(dir)/parse-sexp.cc\
-   $(dir)/sexp-fp.cc
+   $(dir)/sexp-fp.cc   \
+   $(dir)/lastmod-fp.cc
 
 libnotmuch_modules := $(libnotmuch_c_srcs:.c=.o) $(libnotmuch_cxx_srcs:.cc=.o)
 
diff --git a/lib/database-private.h b/lib/database-private.h
index 419b9fe6..b9be4e22 100644
--- a/lib/database-private.h
+++ b/lib/database-private.h
@@ -381,5 +381,11 @@ _notmuch_sexp_string_to_xapian_query (notmuch_database_t 
*notmuch, const char *q
 notmuch_status_t
 _notmuch_date_strings_to_query (Xapian::valueno slot, const std::string , 
const std::string ,
Xapian::Query , std::string );
+
+/* lastmod-fp.h */
+notmuch_status_t
+_notmuch_lastmod_strings_to_query (notmuch_database_t *notmuch,
+  const std::string , const std::string 
,
+  Xapian::Query , std::string );
 #endif
 #endif
diff --git a/lib/lastmod-fp.cc b/lib/lastmod-fp.cc
new file mode 100644
index ..5fdaf281
--- /dev/null
+++ b/lib/lastmod-fp.cc
@@ -0,0 +1,68 @@
+/* lastmod-fp.cc - lastmod range query glue
+ *
+ * This file is part of notmuch.
+ *
+ * Copyright © 2022 David Bremner
+ *
+ * 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
+ * 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.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see https://www.gnu.org/licenses/ .
+ *
+ * Author: David Bremner 
+ */
+
+#include "database-private.h"
+
+notmuch_status_t
+_notmuch_lastmod_strings_to_query (notmuch_database_t *notmuch,
+  const std::string , const std::string 
,
+  Xapian::Query , std::string )
+{
+long from_idx = 0L, to_idx = LONG_MAX;
+long current;
+std::string str;
+
+/* revision should not change, but for the avoidance of doubt,
+ * grab for both ends of range, if needed*/
+current = notmuch_database_get_revision (notmuch, NULL);
+
+try {
+   if (from.empty ())
+   from_idx = 0L;
+   else
+   from_idx = std::stol (from);
+} catch (std::logic_error ) {
+   msg = "bad 'from' revision: '" + from + "'";
+   return NOTMUCH_STATUS_BAD_QUERY_SYNTAX;
+}
+
+if (from_idx < 0)
+   from_idx += current;
+
+try {
+   if (EMPTY_STRING (to))
+   to_idx = LONG_MAX;
+   else
+   to_idx = std::stol (to);
+} catch (std::logic_error ) {
+   msg = "bad 'to' revision: '" + to + "'";
+   return NOTMUCH_STATUS_BAD_QUERY_SYNTAX;
+}
+
+if (to_idx < 0)
+   to_idx += current;
+
+output = Xapian::Query (Xapian::Query::OP_VALUE_RANGE, 
NOTMUCH_VALUE_LAST_MOD,
+   Xapian::sortable_serialise (from_idx),
+   Xapian::sortable_serialise (to_idx));
+return NOTMUCH_STATUS_SUCCESS;
+}
diff --git a/lib/parse-sexp.cc b/lib/parse-sexp.cc
index e9ef4268..9cadbc13 100644
--- a/lib/parse-sexp.cc
+++ b/lib/parse-sexp.cc
@@ -563,38 +563,13 @@ _sexp_parse_range (notmuch_database_t *notmuch,  const 
_sexp_prefix_t *prefix,
 }
 
 if (strcmp (prefix->name, "lastmod") == 0) {
-   long from_idx, to_idx;
-
-   try {
-   if (EMPTY_STRING (from))
-   from_idx = 0L;
-   else
-   from_idx = std::stol (from);
-   } catch (std::logic_error ) {
-   _notmuch_database_log (notmuch, "bad 'from' revision: '%s'\n", 
from);
-   return NOTMUCH_STATUS_BAD_QUERY_SYNTAX;
-   }
-
-   if (from_idx < 0)
-   from_idx += notmuch_database_get_revision (notmuch, NULL);
-
-   try {
-   if (EMPTY_STRING (to))
-   

[PATCH 3/3] lib: add field processor for lastmod: prefix

2022-08-14 Thread David Bremner
By sharing the existing logic used by the sexp query parser, this
allows negative lastmod revisions to be interpreted as relative to the
most recent revision.
---
 doc/man7/notmuch-search-terms.rst |  9 +++
 lib/lastmod-fp.cc | 15 
 lib/lastmod-fp.h  | 39 +++
 lib/open.cc   |  4 ++--
 test/T570-revision-tracking.sh| 19 +++
 5 files changed, 80 insertions(+), 6 deletions(-)
 create mode 100644 lib/lastmod-fp.h

diff --git a/doc/man7/notmuch-search-terms.rst 
b/doc/man7/notmuch-search-terms.rst
index 4f616b7e..acc1c967 100644
--- a/doc/man7/notmuch-search-terms.rst
+++ b/doc/man7/notmuch-search-terms.rst
@@ -153,10 +153,11 @@ date:.. or date:
 lastmod:..
 The **lastmod:** prefix can be used to restrict the result by the
 database revision number of when messages were last modified (tags
-were added/removed or filenames changed). This is usually used in
-conjunction with the ``--uuid`` argument to
-:any:`notmuch-search(1)` to find messages that have changed since
-an earlier query.
+were added/removed or filenames changed). Negative revisions are
+interpreted relative to the most recent database revision (see
+:option:`count --lastmod`). This is usually used in conjunction
+with the ``--uuid`` argument to :any:`notmuch-search(1)` to find
+messages that have changed since an earlier query.
 
 query:
 The **query:** prefix allows queries to refer to previously saved
diff --git a/lib/lastmod-fp.cc b/lib/lastmod-fp.cc
index 5fdaf281..f85efd28 100644
--- a/lib/lastmod-fp.cc
+++ b/lib/lastmod-fp.cc
@@ -21,6 +21,7 @@
  */
 
 #include "database-private.h"
+#include "lastmod-fp.h"
 
 notmuch_status_t
 _notmuch_lastmod_strings_to_query (notmuch_database_t *notmuch,
@@ -66,3 +67,17 @@ _notmuch_lastmod_strings_to_query (notmuch_database_t 
*notmuch,
Xapian::sortable_serialise (to_idx));
 return NOTMUCH_STATUS_SUCCESS;
 }
+
+Xapian::Query
+LastModRangeProcessor::operator() (const std::string , const std::string 
)
+{
+
+Xapian::Query output;
+std::string msg;
+
+if (_notmuch_lastmod_strings_to_query (notmuch, begin, end, output, msg))
+   throw Xapian::QueryParserError (msg);
+
+return output;
+}
+
diff --git a/lib/lastmod-fp.h b/lib/lastmod-fp.h
new file mode 100644
index ..448241f8
--- /dev/null
+++ b/lib/lastmod-fp.h
@@ -0,0 +1,39 @@
+/* lastmod-fp.h - database revision query glue
+ *
+ * This file is part of notmuch.
+ *
+ * Copyright © 2022 David Bremner
+ *
+ * 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
+ * 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.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see https://www.gnu.org/licenses/ .
+ *
+ * Author: David Bremner 
+ */
+
+#ifndef NOTMUCH_LASTMOD_FP_H
+#define NOTMUCH_LASTMOD_FP_H
+
+#include 
+
+class LastModRangeProcessor : public Xapian::RangeProcessor {
+protected:
+notmuch_database_t *notmuch;
+
+public:
+LastModRangeProcessor (notmuch_database_t *notmuch_, const std::string 
prefix_)
+   :  Xapian::RangeProcessor(NOTMUCH_VALUE_LAST_MOD, prefix_, 0), 
notmuch(notmuch_) { }
+
+Xapian::Query operator() (const std::string , const std::string 
);
+};
+
+#endif /* NOTMUCH_LASTMOD_FP_H */
diff --git a/lib/open.cc b/lib/open.cc
index 30cfcf9e..02ed7285 100644
--- a/lib/open.cc
+++ b/lib/open.cc
@@ -3,6 +3,7 @@
 
 #include "database-private.h"
 #include "parse-time-vrp.h"
+#include "lastmod-fp.h"
 #include "path-util.h"
 
 #if HAVE_XAPIAN_DB_RETRY_LOCK
@@ -431,8 +432,7 @@ _finish_open (notmuch_database_t *notmuch,
notmuch->value_range_processor = new Xapian::NumberRangeProcessor 
(NOTMUCH_VALUE_TIMESTAMP);
notmuch->date_range_processor = new ParseTimeRangeProcessor 
(NOTMUCH_VALUE_TIMESTAMP,
 "date:");
-   notmuch->last_mod_range_processor = new Xapian::NumberRangeProcessor 
(NOTMUCH_VALUE_LAST_MOD,
- 
"lastmod:");
+   notmuch->last_mod_range_processor = new LastModRangeProcessor (notmuch, 
"lastmod:");
notmuch->query_parser->set_default_op (Xapian::Query::OP_AND);
notmuch->query_parser->set_database (*notmuch->xapian_db);
notmuch->stemmer = new Xapian::Stem (

[PATCH 1/3] lib/sexp: provide relative lastmod queries

2022-08-14 Thread David Bremner
Test the relatively trivial logic changes for the sexp query parser
first before refactoring that logic to share with the infix query
parser.
---
 doc/man7/notmuch-sexp-queries.rst |  3 +++
 lib/parse-sexp.cc |  6 ++
 test/T081-sexpr-search.sh | 30 ++
 test/T570-revision-tracking.sh|  8 
 4 files changed, 47 insertions(+)

diff --git a/doc/man7/notmuch-sexp-queries.rst 
b/doc/man7/notmuch-sexp-queries.rst
index d28f40bb..422154c7 100644
--- a/doc/man7/notmuch-sexp-queries.rst
+++ b/doc/man7/notmuch-sexp-queries.rst
@@ -125,6 +125,9 @@ bounds. Either upper or lower bound may be specified as 
``""`` or
 ``*`` to specify the lowest possible lower bound or highest possible
 upper bound.
 
+``lastmod`` ranges support negative arguments, interpreted relative to
+the most recent database revision (see :option:`count --lastmod`).
+
 .. _field-table:
 
 .. table:: Fields with supported modifiers
diff --git a/lib/parse-sexp.cc b/lib/parse-sexp.cc
index 0f14d8b7..e9ef4268 100644
--- a/lib/parse-sexp.cc
+++ b/lib/parse-sexp.cc
@@ -575,6 +575,9 @@ _sexp_parse_range (notmuch_database_t *notmuch,  const 
_sexp_prefix_t *prefix,
return NOTMUCH_STATUS_BAD_QUERY_SYNTAX;
}
 
+   if (from_idx < 0)
+   from_idx += notmuch_database_get_revision (notmuch, NULL);
+
try {
if (EMPTY_STRING (to))
to_idx = LONG_MAX;
@@ -585,6 +588,9 @@ _sexp_parse_range (notmuch_database_t *notmuch,  const 
_sexp_prefix_t *prefix,
return NOTMUCH_STATUS_BAD_QUERY_SYNTAX;
}
 
+   if (to_idx < 0)
+   to_idx += notmuch_database_get_revision (notmuch, NULL);
+
output = Xapian::Query (Xapian::Query::OP_VALUE_RANGE, 
NOTMUCH_VALUE_LAST_MOD,
Xapian::sortable_serialise (from_idx),
Xapian::sortable_serialise (to_idx));
diff --git a/test/T081-sexpr-search.sh b/test/T081-sexpr-search.sh
index ce6b11b6..0c7db9c2 100755
--- a/test/T081-sexpr-search.sh
+++ b/test/T081-sexpr-search.sh
@@ -934,6 +934,14 @@ notmuch search lastmod:$revision..$revision | 
notmuch_search_sanitize > EXPECTED
 notmuch search --query=sexp  "(and (lastmod $revision))" | 
notmuch_search_sanitize > OUTPUT
 test_expect_equal_file EXPECTED OUTPUT
 
+test_begin_subtest "lastmod query, one argument (negative)"
+notmuch tag +4efc743a.3060...@april.org id:4efc743a.3060...@april.org
+revision=$(notmuch count --lastmod '*' | cut -f3)
+revision1=$((revision - 1))
+notmuch search lastmod:$revision1..$revision1 | notmuch_search_sanitize > 
EXPECTED
+notmuch search --query=sexp  "(lastmod -1)" | notmuch_search_sanitize > OUTPUT
+test_expect_equal_file_nonempty EXPECTED OUTPUT
+
 test_begin_subtest "lastmod query, two arguments"
 notmuch tag +keithp from:keithp
 revision2=$(notmuch count --lastmod '*' | cut -f3)
@@ -941,16 +949,38 @@ notmuch search lastmod:$revision..$revision2 | 
notmuch_search_sanitize > EXPECTE
 notmuch search --query=sexp  "(and (lastmod $revision $revision2))" | 
notmuch_search_sanitize > OUTPUT
 test_expect_equal_file EXPECTED OUTPUT
 
+test_begin_subtest "lastmod query, two arguments, first negative"
+revdiff=$((revision2 - revision))
+notmuch search lastmod:$revision..$revision2 | notmuch_search_sanitize > 
EXPECTED
+notmuch search --query=sexp  "(lastmod -$revdiff $revision2)" | 
notmuch_search_sanitize > OUTPUT
+test_expect_equal_file EXPECTED OUTPUT
+
+test_begin_subtest "lastmod query, two arguments, second negative"
+revdiff=$((revision2 - revision))
+notmuch search lastmod:..$revision | notmuch_search_sanitize > EXPECTED
+notmuch search --query=sexp  "(lastmod 0 -$revdiff)" | notmuch_search_sanitize 
> OUTPUT
+test_expect_equal_file EXPECTED OUTPUT
+
 test_begin_subtest "lastmod query, lower bound only"
 notmuch search lastmod:$revision.. | notmuch_search_sanitize > EXPECTED
 notmuch search --query=sexp  "(lastmod $revision \"\")" | 
notmuch_search_sanitize > OUTPUT
 test_expect_equal_file_nonempty EXPECTED OUTPUT
 
+test_begin_subtest "lastmod query, lower bound only (negative)"
+notmuch search lastmod:$revision.. | notmuch_search_sanitize > EXPECTED
+notmuch search --query=sexp  "(lastmod -$revdiff \"\")" | 
notmuch_search_sanitize > OUTPUT
+test_expect_equal_file_nonempty EXPECTED OUTPUT
+
 test_begin_subtest "lastmod query, upper bound only"
 notmuch search lastmod:..$revision2 | notmuch_search_sanitize > EXPECTED
 notmuch search --query=sexp  "(lastmod \"\" $revision2)" | 
notmuch_search_sanitize > OUTPUT
 test_expect_equal_file_nonempty EXPECTED OUTPUT
 
+test_begin_subtest "lastmod query, upper bound only (negative)"
+notmuch search lastmod:..$revision | notmuch_search_sanitize > EXPECTED
+notmuch search --query=sexp  "(lastmod \"\" -$revdiff)" | 
notmuch_search_sanitize > OUTPUT
+test_expect_equal_file_nonempty EXPECTED OUTPUT
+
 test_begin_subtest "lastmod query, lower bound only, using *"
 notmuch search lastmod:$revision.. | 

Re: release 0.37 is immanent

2022-08-14 Thread David Bremner
David Bremner  writes:

> It has been a while, and there have been quite a few changes since
> 0.36. I propose feature freeze for 0.37 August 13, with a release around
> a week after that.
>
> d

Release candidate 0.37_rc0 has been tagged and uploaded to
notmuchmail.org. Please report any serious bugs and
regressions that should be fixed before 0.37 is released. 
Also please review NEWS and see if anything should be changed or added.
The only thing that really jumped out at me is the following changes
from jao:

jao (2):
  emacs: notmuch-show-header-line: allow format strings and functions
  emacs: use message-dont-reply-to-names when composing replies


signature.asc
Description: PGP signature
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: [PATCH 8/9] review: Rename variables to better express intention

2022-08-14 Thread David Bremner
Mohsin Kaleem  writes:

> ---
>  emacs/notmuch-hello.el | 18 +-
>  emacs/notmuch-jump.el  |  2 +-
>  emacs/notmuch-lib.el   |  4 ++--
>  emacs/notmuch-tree.el  | 24 
>  emacs/notmuch.el   | 29 +++--
>  5 files changed, 39 insertions(+), 38 deletions(-)

Please apply these fixes to the previous commits in the series, rather
than sending an extra omnibus commit. magit is actually pretty good at
that (c F).
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: [PATCH] emacs: add new option notmuch-search-exclude

2022-08-12 Thread David Bremner
David Bremner  writes:

> To apply patch series, you may want to try mailscripts [1]. The
> description makes it sound debian-centric, but I guess the elisp
> functions like notmuch-extract-thread-patches are portable.

That function is one reason why it's nice to start a new thread with
each version of a patch series.
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: [PATCH] emacs: add new option notmuch-search-exclude

2022-08-12 Thread David Bremner
Mohsin Kaleem  writes:

>
> I'm not sure what you mean by the first two patches occur twice, could
> you clarify so I can fix the issue? I've dropped the reverted patch and
> rebased on top of master so you shouldn't have any issues applying the
> patch series now.
>

For reference, just look at the first and third attachements to your
message. These (somehow) describe the same commit / patch. In any case
it is fixed in the next iteration using git send-email.

>> If possible, please use git send-email to send one-patch-per-message, it
>> makes reviewing in notmuch-emacs much easier for me.
>
> I just used git send-email to send the patch series (I assume it'll be
> sent separately). I'd like to ask:
> + How do you manage git and email workflows like this for reference?
> I haven't found any documentation about it when searching.

Some general advice is at https://git-send-email.io/

> + Is there a way to do this with notmuch involved (ideally through emacs
> and Magit)?

I use git send-email from the command line to send patch series. To
review them, I read the resulting threads and reply to individual
patches / commits / messages.

To apply patch series, you may want to try mailscripts [1]. The
description makes it sound debian-centric, but I guess the elisp
functions like notmuch-extract-thread-patches are portable.

Finally I have some git aliases to apply individual patches:

[alias]
nmam = "!f() { notmuch extract-patch $1 | git am -; }; f"

[alias]
nmam8 = "!f() { notmuch extract-patch $1 | email-to-8bit |  git am -; 
}; f"

[alias]
nmam3 = "!f() { notmuch extract-patch $1 | git am -3 -; }; f"


These versions rely on notmuch-extract-patch, from mailscripts [1], but
if you don't have that "notmuch show --format=raw" works almost as well.

[1]: https://github.com/spwhitton/mailscripts
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: [PATCH 7/9] test: Fix Navigation of notmuch-hello to search results

2022-08-12 Thread David Bremner
Mohsin Kaleem  writes:

> The default value of oldest-first is true so the oldest mail is shown
> first by default. This test case used the tree-from-search function
> which now persists this value of true (previously always defaulting to
> nil in its place) which produced a different tree output where the
> oldest-mail is sorted first despite previously being sorted last. Fixed
> by adding in this output as a separate file and comparing against it
> instead.

Please make sure the test suite passes after every commit. Probably that
means squashing this fix into the previous commit.

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


Re: [PATCH 6/9] test: Add test cases for new exclude option

2022-08-12 Thread David Bremner
Mohsin Kaleem  writes:

This should mention emacs in the commit message. test/emacs: is the
usual convention.

> ---
>  test/T461-emacs-search-exclude.sh | 99 +++
>  .../notmuch-search-tag-inbox-with-excluded| 25 +
>  .../notmuch-search-tag-inbox-without-excluded | 21 
>  .../notmuch-tree-tag-inbox-with-excluded  | 53 ++
>  .../notmuch-tree-tag-inbox-without-excluded   | 49 +
>  5 files changed, 247 insertions(+)
>  create mode 100755 test/T461-emacs-search-exclude.sh
>  create mode 100644 
> test/emacs-exclude.expected-output/notmuch-search-tag-inbox-with-excluded
>  create mode 100644 
> test/emacs-exclude.expected-output/notmuch-search-tag-inbox-without-excluded
>  create mode 100644 
> test/emacs-exclude.expected-output/notmuch-tree-tag-inbox-with-excluded
>  create mode 100644 
> test/emacs-exclude.expected-output/notmuch-tree-tag-inbox-without-excluded
>
> diff --git a/test/T461-emacs-search-exclude.sh 
> b/test/T461-emacs-search-exclude.sh
> new file mode 100755
> index ..bf558847
> --- /dev/null
> +++ b/test/T461-emacs-search-exclude.sh
> @@ -0,0 +1,99 @@
> +#!/usr/bin/env bash
> +
> +test_description="exclude options persist between Emacs search and tree 
> modes"
> +. $(dirname "$0")/test-lib.sh || exit 1
> +. $NOTMUCH_SRCDIR/test/test-lib-emacs.sh || exit 1
> +
> +EXPECTED=$NOTMUCH_SRCDIR/test/emacs-exclude.expected-output
> +
> +test_require_emacs
> +add_email_corpus
> +notmuch config set search.exclude_tags deleted
> +notmuch tag +deleted -- 'from:"Stewart Smith"' or 'from:"Chris Wilson"'
> +
> +# Basic test cases just asserting exclude option is working and consistent.
> +
> +test_begin_subtest "Search doesn't contain excluded mail by default"
> +test_emacs '(notmuch-hello)
> + (goto-char (point-min))
> + (re-search-forward "inbox")
> + (widget-button-press (1- (point)))
> + (notmuch-test-wait)
> + (test-output)
> + (delete-other-windows)'
> +test_expect_equal_file $EXPECTED/notmuch-search-tag-inbox-without-excluded 
> OUTPUT
> +
> +test_begin_subtest "Toggling exclude in search will show excluded mail"
> +test_emacs '(notmuch-hello)
> + (goto-char (point-min))
> + (re-search-forward "inbox")
> + (widget-button-press (1- (point)))
> + (notmuch-test-wait)
> +  (notmuch-search-toggle-exclude)
> + (notmuch-test-wait)
> + (test-output)
> + (delete-other-windows)'
> +test_expect_equal_file $EXPECTED/notmuch-search-tag-inbox-with-excluded 
> OUTPUT
> +
> +test_begin_subtest "Tree search doesn't contain excluded mail by default"
> +test_emacs '(notmuch-hello)
> + (goto-char (point-min))
> + (re-search-forward "inbox")
> + (widget-button-press (1- (point)))
> + (notmuch-test-wait)
> + (notmuch-tree-from-search-current-query)
> + (notmuch-test-wait)
> + (test-output)
> + (delete-other-windows)'
> +test_expect_equal_file $EXPECTED/notmuch-tree-tag-inbox-without-excluded 
> OUTPUT
> +
> +test_begin_subtest "Toggling exclude in tree search will show excluded mail"
> +test_emacs '(notmuch-hello)
> + (goto-char (point-min))
> + (re-search-forward "inbox")
> + (widget-button-press (1- (point)))
> + (notmuch-test-wait)
> + (notmuch-tree-from-search-current-query)
> + (notmuch-test-wait)
> +  (notmuch-tree-toggle-exclude)
> + (notmuch-test-wait)
> + (test-output)
> + (delete-other-windows)'
> +test_expect_equal_file $EXPECTED/notmuch-tree-tag-inbox-with-excluded OUTPUT
> +
> +# Choice of showing excluded mail persists when switching between tree and 
> search
> +# buffers.
> +
> +test_begin_subtest "Value of exclude from search persists into tree search"
> +test_emacs '(notmuch-hello)
> + (goto-char (point-min))
> + (re-search-forward "inbox")
> + (widget-button-press (1- (point)))
> + (notmuch-test-wait)
> +  (notmuch-search-toggle-exclude)
> + (notmuch-test-wait)
> + (notmuch-tree-from-search-current-query)
> + (notmuch-test-wait)
> + (test-output)
> + (delete-other-windows)'
> +test_expect_equal_file $EXPECTED/notmuch-tree-tag-inbox-with-excluded OUTPUT
> +
> +test_begin_subtest "Value of exclude from tree persists into search search"
> +test_emacs '(notmuch-hello)
> + (goto-char (point-min))
> + (re-search-forward "inbox")
> + (widget-button-press (1- (point)))
> + (notmuch-test-wait)
> + (notmuch-tree-from-search-current-query)
> + (notmuch-test-wait)
> +  (notmuch-tree-toggle-exclude)
> + (notmuch-test-wait)
> + (notmuch-search-from-tree-current-query)
> + (notmuch-test-wait)
> + (test-output)
> + (delete-other-windows)'
> +test_expect_equal_file $EXPECTED/notmuch-search-tag-inbox-with-excluded 
> OUTPUT
> +
> +# TODO: Add test 

Re: [PATCH 5/9] feat: Add more interactive specs

2022-08-12 Thread David Bremner


This needs a better commit message. Both the subject (what is actually
happening) and the body (more detail about what, and some explanation
about why).

I'd suggest sticking to emacs: as a tag for the subject, but this is
less important than the other two issues I mentioned.
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: [PATCH 4/9] feat: Allow :exclude configuration in notmuch-hello

2022-08-12 Thread David Bremner
Mohsin Kaleem  writes:

> ---
>  emacs/notmuch-hello.el | 35 ++-
>  1 file changed, 22 insertions(+), 13 deletions(-)

I would suggest describing this change as a change to
notmuch-saved-searches; that variable is used other places in notmuch as
well (mainly notmuch-jump.el)
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: [PATCH 2/9] docs: Update with notmuch-*-toggle-exclude

2022-08-12 Thread David Bremner
Mohsin Kaleem  writes:

> ---
>  devel/emacs-keybindings.org | 2 +-
>  doc/notmuch-emacs.rst   | 5 +
>  2 files changed, 6 insertions(+), 1 deletion(-)

apologies, but this patch will need to be rebased on top of master, as
I've just changed that section of the emacs manual. For now I'm just
skipping it.
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: [Emacs] Using notmuch-address with EUDC, and completion-at-point

2022-08-12 Thread David Bremner
Alexander Adolf  writes:

> Hello David,
>
> thanks for your comments and questions.
>
> David Bremner  writes:
>
>> Alexander Adolf  writes:
>>
>>> As I wanted email address completion via completion-at-point in
>>> message-mode too, I implemented a new EUDC function to go into
>>> completion-at-point-functions [3].
>>>
>>> [1] https://company-mode.github.io
>>> [2] https://github.com/minad/corfu
>>> [3] https://github.com/emacs-mirror/emacs/blob/master/lisp/net/eudc-capf.el
>>>
>>
>> I will have to leave to others to test this, since I'm personally still
>> running emacs 27 (and that is likely to continue for a while, at least
>> on some machines).
>
> You could do
>
>  (require 'eudcb-notmuch-address)
>  (eudc-notmuch-address-set-server "localhost")
>
> and bind the function eudc-expand-inline to a key chord of your choice
> in message-mode-map.
>
> Then you'd no longer have to tweak message-completion-alist.

I stopped my investigations at the point it looked like I needed to edit
notmuch-address.el. I guess another patch or two is needed to do notmuch
integration. And of course we would need tests (in the notmuch test
suite) and documentation before actually merging the functionality, but
those can probably wait until we have a clearer idea what benefits the
change would bring.

> This assumes that eudc-expand-inline is present in Emacs 27, of course,
> which I admittedly haven't checked.

The function exists here in Emacs 27.1.

> What you'd probably lose (or no longer need, whichever way you view it)
> is any company-mode integration.

Unless the UX is very close, some people will strongly prefer to stay
with the existing completion, so I guess we'd need to make it
opt-in. Unfortunately as Tomi already pointed out the configuration is
already a bit of a confusing mess.
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: Overriding mm-inline-override-types in notmuch-show

2022-08-11 Thread David Bremner
David Bremner  writes:

> Al Haji-Ali  writes:
>
>> The variable `mm-inline-override-types` is overridden in `notmuch-show` to 
>> "stop application/* parts from being displayed".
>>
>> This works well, however it means in other places the part *is* expanded. 
>> For example when `(notmuch-show-refresh-view)` is called (after any refresh) 
>> or even when `notmuch-show-reply-sender` is called.
>>
>> To see this behaviour make sure that `mm-inline-override-types` is nil and 
>> open a message with an `application/zip` part. The part is not expanded as 
>> expected.
>> Call `(notmuch-show-refresh-view)` and notice how the part is expanded (on 
>> my Emacs, I even get a warning: "These default coding systems were tried to 
>> encode the following problematic characters in the buffer ‘ *temp*-926949’").
>>
>> I solved this in my config by setting `mm-inline-override-types` to `(list 
>> "application/*")`, but I think notmuch could be more consistent.
>>
>
> Thanks for the report. I can duplicate the issue with
> notmuch-show-refresh-view. I believe with notmuch-show-reply-sender is
> fixed in git master (90a7c1af368a527700dcde9b0dcbd760afc7bd92).

The remaining issues should be fixed as of commit
bf64c48855f41833b57e0a770ad37f6a16a1193b
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: Embed elisp.py from flycheck, use it in notmuch-emacs doc

2022-08-11 Thread David Bremner
Tomi Ollila  writes:

>
> This series is probably good; at least it does not break software
> (and if doc quality (or making of it) gets better then good :D)
>
> Tomi

Applied to master.

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


Re: [PATCH 3/3] doc: add some documentation about duplicate files.

2022-08-11 Thread David Bremner
David Bremner  writes:

> This is mainly motivated by the new emacs-UI features to select
> duplicates, but hopefully it will help demystify things for users of
> the CLI as well.

applied the remaining two patches to master (with a tiny adjustment of
wording for the man output in the second patch).

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


Re: [PATCH 2/2] emacs/show: restrict inlined mimetypes on refresh.

2022-08-11 Thread David Bremner
Tomi Ollila  writes:

> On Mon, Aug 01 2022, David Bremner wrote:
>
>> This fixes the bug reported by Al [1]. Essentially apply the same fix
>> as [2] in a different place.
>>
>> [1]: id:877d41nmr1@gmail.com
>> [2]: 90a7c1af368a527700dcde9b0dcbd760afc7bd92
>
> LGTM.
>
> Tomi

Applied to master.

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


Re: Create tags from folders

2022-08-09 Thread David Bremner
Reto  writes:
>
> Out of interest, how does your workflow look like?
> All based on folder queries?

I don't use folders much anymore. My main searches are defined in terms
of List-ID ORed with tags to sort into mailing-list-like-things (as some
things I think should be part of the list are missing the List-ID
header).

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


[PATCH 3/3] WIP/lib: use common lastmod logic in infix parser

2022-08-09 Thread David Bremner
This allows the support of negative lastmod revisions to be
interpreted as relative to the most recent revision.
---
 lib/lastmod-fp.cc  | 15 +
 lib/lastmod-fp.h   | 39 ++
 lib/open.cc|  4 ++--
 test/T570-revision-tracking.sh |  6 ++
 4 files changed, 62 insertions(+), 2 deletions(-)
 create mode 100644 lib/lastmod-fp.h

diff --git a/lib/lastmod-fp.cc b/lib/lastmod-fp.cc
index 5fdaf281..f85efd28 100644
--- a/lib/lastmod-fp.cc
+++ b/lib/lastmod-fp.cc
@@ -21,6 +21,7 @@
  */
 
 #include "database-private.h"
+#include "lastmod-fp.h"
 
 notmuch_status_t
 _notmuch_lastmod_strings_to_query (notmuch_database_t *notmuch,
@@ -66,3 +67,17 @@ _notmuch_lastmod_strings_to_query (notmuch_database_t 
*notmuch,
Xapian::sortable_serialise (to_idx));
 return NOTMUCH_STATUS_SUCCESS;
 }
+
+Xapian::Query
+LastModRangeProcessor::operator() (const std::string , const std::string 
)
+{
+
+Xapian::Query output;
+std::string msg;
+
+if (_notmuch_lastmod_strings_to_query (notmuch, begin, end, output, msg))
+   throw Xapian::QueryParserError (msg);
+
+return output;
+}
+
diff --git a/lib/lastmod-fp.h b/lib/lastmod-fp.h
new file mode 100644
index ..448241f8
--- /dev/null
+++ b/lib/lastmod-fp.h
@@ -0,0 +1,39 @@
+/* lastmod-fp.h - database revision query glue
+ *
+ * This file is part of notmuch.
+ *
+ * Copyright © 2022 David Bremner
+ *
+ * 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
+ * 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.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see https://www.gnu.org/licenses/ .
+ *
+ * Author: David Bremner 
+ */
+
+#ifndef NOTMUCH_LASTMOD_FP_H
+#define NOTMUCH_LASTMOD_FP_H
+
+#include 
+
+class LastModRangeProcessor : public Xapian::RangeProcessor {
+protected:
+notmuch_database_t *notmuch;
+
+public:
+LastModRangeProcessor (notmuch_database_t *notmuch_, const std::string 
prefix_)
+   :  Xapian::RangeProcessor(NOTMUCH_VALUE_LAST_MOD, prefix_, 0), 
notmuch(notmuch_) { }
+
+Xapian::Query operator() (const std::string , const std::string 
);
+};
+
+#endif /* NOTMUCH_LASTMOD_FP_H */
diff --git a/lib/open.cc b/lib/open.cc
index 30cfcf9e..02ed7285 100644
--- a/lib/open.cc
+++ b/lib/open.cc
@@ -3,6 +3,7 @@
 
 #include "database-private.h"
 #include "parse-time-vrp.h"
+#include "lastmod-fp.h"
 #include "path-util.h"
 
 #if HAVE_XAPIAN_DB_RETRY_LOCK
@@ -431,8 +432,7 @@ _finish_open (notmuch_database_t *notmuch,
notmuch->value_range_processor = new Xapian::NumberRangeProcessor 
(NOTMUCH_VALUE_TIMESTAMP);
notmuch->date_range_processor = new ParseTimeRangeProcessor 
(NOTMUCH_VALUE_TIMESTAMP,
 "date:");
-   notmuch->last_mod_range_processor = new Xapian::NumberRangeProcessor 
(NOTMUCH_VALUE_LAST_MOD,
- 
"lastmod:");
+   notmuch->last_mod_range_processor = new LastModRangeProcessor (notmuch, 
"lastmod:");
notmuch->query_parser->set_default_op (Xapian::Query::OP_AND);
notmuch->query_parser->set_database (*notmuch->xapian_db);
notmuch->stemmer = new Xapian::Stem ("english");
diff --git a/test/T570-revision-tracking.sh b/test/T570-revision-tracking.sh
index aaa45468..067935b2 100755
--- a/test/T570-revision-tracking.sh
+++ b/test/T570-revision-tracking.sh
@@ -103,4 +103,10 @@ if [ $NOTMUCH_HAVE_SFSEXP -eq 1 ]; then
 test_expect_equal 1 "$count"
 fi
 
+test_begin_subtest 'exclude one message using negative lastmod'
+total=$(notmuch count '*')
+notmuch tag +${RANDOM} id:4efc743a.3060...@april.org
+count=$(notmuch count lastmod:-1..)
+test_expect_equal 1 "$count"
+
 test_done
-- 
2.35.2

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


[PATCH 2/3] WIP/lib: factor out lastmod range handling from sexp parser.

2022-08-09 Thread David Bremner
This will permit the re-use of the same logic in the infix query
parser. The location of the shared code in the infix side is just a
convention at this point.
---
 lib/Makefile.local |  3 +-
 lib/database-private.h |  6 
 lib/lastmod-fp.cc  | 68 ++
 lib/parse-sexp.cc  | 37 ---
 4 files changed, 82 insertions(+), 32 deletions(-)
 create mode 100644 lib/lastmod-fp.cc

diff --git a/lib/Makefile.local b/lib/Makefile.local
index 6d67a2a4..4e766305 100644
--- a/lib/Makefile.local
+++ b/lib/Makefile.local
@@ -65,7 +65,8 @@ libnotmuch_cxx_srcs = \
$(dir)/open.cc  \
$(dir)/init.cc  \
$(dir)/parse-sexp.cc\
-   $(dir)/sexp-fp.cc
+   $(dir)/sexp-fp.cc   \
+   $(dir)/lastmod-fp.cc
 
 libnotmuch_modules := $(libnotmuch_c_srcs:.c=.o) $(libnotmuch_cxx_srcs:.cc=.o)
 
diff --git a/lib/database-private.h b/lib/database-private.h
index 419b9fe6..b9be4e22 100644
--- a/lib/database-private.h
+++ b/lib/database-private.h
@@ -381,5 +381,11 @@ _notmuch_sexp_string_to_xapian_query (notmuch_database_t 
*notmuch, const char *q
 notmuch_status_t
 _notmuch_date_strings_to_query (Xapian::valueno slot, const std::string , 
const std::string ,
Xapian::Query , std::string );
+
+/* lastmod-fp.h */
+notmuch_status_t
+_notmuch_lastmod_strings_to_query (notmuch_database_t *notmuch,
+  const std::string , const std::string 
,
+  Xapian::Query , std::string );
 #endif
 #endif
diff --git a/lib/lastmod-fp.cc b/lib/lastmod-fp.cc
new file mode 100644
index ..5fdaf281
--- /dev/null
+++ b/lib/lastmod-fp.cc
@@ -0,0 +1,68 @@
+/* lastmod-fp.cc - lastmod range query glue
+ *
+ * This file is part of notmuch.
+ *
+ * Copyright © 2022 David Bremner
+ *
+ * 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
+ * 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.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see https://www.gnu.org/licenses/ .
+ *
+ * Author: David Bremner 
+ */
+
+#include "database-private.h"
+
+notmuch_status_t
+_notmuch_lastmod_strings_to_query (notmuch_database_t *notmuch,
+  const std::string , const std::string 
,
+  Xapian::Query , std::string )
+{
+long from_idx = 0L, to_idx = LONG_MAX;
+long current;
+std::string str;
+
+/* revision should not change, but for the avoidance of doubt,
+ * grab for both ends of range, if needed*/
+current = notmuch_database_get_revision (notmuch, NULL);
+
+try {
+   if (from.empty ())
+   from_idx = 0L;
+   else
+   from_idx = std::stol (from);
+} catch (std::logic_error ) {
+   msg = "bad 'from' revision: '" + from + "'";
+   return NOTMUCH_STATUS_BAD_QUERY_SYNTAX;
+}
+
+if (from_idx < 0)
+   from_idx += current;
+
+try {
+   if (EMPTY_STRING (to))
+   to_idx = LONG_MAX;
+   else
+   to_idx = std::stol (to);
+} catch (std::logic_error ) {
+   msg = "bad 'to' revision: '" + to + "'";
+   return NOTMUCH_STATUS_BAD_QUERY_SYNTAX;
+}
+
+if (to_idx < 0)
+   to_idx += current;
+
+output = Xapian::Query (Xapian::Query::OP_VALUE_RANGE, 
NOTMUCH_VALUE_LAST_MOD,
+   Xapian::sortable_serialise (from_idx),
+   Xapian::sortable_serialise (to_idx));
+return NOTMUCH_STATUS_SUCCESS;
+}
diff --git a/lib/parse-sexp.cc b/lib/parse-sexp.cc
index e9ef4268..9cadbc13 100644
--- a/lib/parse-sexp.cc
+++ b/lib/parse-sexp.cc
@@ -563,38 +563,13 @@ _sexp_parse_range (notmuch_database_t *notmuch,  const 
_sexp_prefix_t *prefix,
 }
 
 if (strcmp (prefix->name, "lastmod") == 0) {
-   long from_idx, to_idx;
-
-   try {
-   if (EMPTY_STRING (from))
-   from_idx = 0L;
-   else
-   from_idx = std::stol (from);
-   } catch (std::logic_error ) {
-   _notmuch_database_log (notmuch, "bad 'from' revision: '%s'\n", 
from);
-   return NOTMUCH_STATUS_BAD_QUERY_SYNTAX;
-   }
-
-   if (from_idx < 0)
-   from_idx += notmuch_database_get_revision (notmuch, NULL);
-
-   try {
-   if (EMPTY_STRING (to))
-   to_idx = LONG_MAX;
-   else
-   to_idx = std::stol (to);
-   } catch (std::logi

Re: Create tags from folders

2022-08-08 Thread David Bremner
Reto  writes:

>
> Second, I let notmuch index multiple email addresses in the same store,
> meaning my folder queries are then nested rather deep.
>
> So my lovely tag:python query amounts to `notmuch search 
> 'folder:reto@labrat.space/INBOX.lists.python-list'`
>
> Which... is a mouthful.
>
> Regexes aren't a solution, just makes it now two problems as I have
> multiple python lists that could match ;)

Just in case you didn't know, another option is define (with notmuch
config) e.g. query:python as
'folder:reto@labrat.space/INBOX.lists.python-list'

This has the advantage that you don't have to retag when new files are
added, which is often the desired behaviour.

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


Re: matching both accented and non-accented character for non-accented characters?

2022-08-08 Thread David Bremner
Bence Ferdinandy  writes:

> Thanks! I didn't know unicode equivalence existed, but it seems to be the
> feature I want, so at least now I have a name for it :) And yes, actually
> setting the stemmer would also be cool, I saw that Xapian has a Hungarian
> stemmer but I kind of assumed all stemmers are applied somehow (although it
> makes sense they're not). Is stemming done during search or would it affect
> the database as well? Just to have a notion of how complicated a settable
> stemmer feature would be.
>

Stemming happens both during search (unless turned off for given term)
and at indexing time. So yeah, changing the stemming algorithm with
change the database (and require a re-index).
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: matching both accented and non-accented character for non-accented characters?

2022-08-08 Thread David Bremner
Bence Ferdinandy  writes:

> Hi,
>
> I'm in the process of trying to set up reading email in the terminal and
> just installed notmuch, which looks like a pretty awesome tool. I currently
> have one question nagging me:
>
> I have a lot of mail in my native Hungarian, which properly written is full
> of characters like éáűúü, but if someone's writing on a non-Hungarian
> keyboard, or just quickly writing an email from a phone, they often drop
> the accents as it's faster and we'll likely understand anyway. Is it
> possible to set it up that if I search for "lanc" it would also match
> "lánc" other than going `notmuch search lanc OR lánc`?

There is some previous discussion at

  
https://nmbug.notmuchmail.org/nmweb/search/id%3A87efp2b9er.fsf%40tethera.net

I don't think anyone worked on this in the meantime, so I guess the
short answer is that there is currently no support, but people have
tossed around some ideas.

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


[PATCH] WIP: provide relative lastmod sexp queries

2022-08-08 Thread David Bremner
---

I haven't looked carefully at how much work it would be to add to the
infix parser yet. I suspect it means adding a new RangeProcessor class
modelled on ParseTimeRangeProcessor. Maybe some of the logic from
_parse_sexp_range could be shared with the other parser.

 lib/parse-sexp.cc  | 6 ++
 test/T570-revision-tracking.sh | 8 
 2 files changed, 14 insertions(+)

diff --git a/lib/parse-sexp.cc b/lib/parse-sexp.cc
index 0f14d8b7..e9ef4268 100644
--- a/lib/parse-sexp.cc
+++ b/lib/parse-sexp.cc
@@ -575,6 +575,9 @@ _sexp_parse_range (notmuch_database_t *notmuch,  const 
_sexp_prefix_t *prefix,
return NOTMUCH_STATUS_BAD_QUERY_SYNTAX;
}
 
+   if (from_idx < 0)
+   from_idx += notmuch_database_get_revision (notmuch, NULL);
+
try {
if (EMPTY_STRING (to))
to_idx = LONG_MAX;
@@ -585,6 +588,9 @@ _sexp_parse_range (notmuch_database_t *notmuch,  const 
_sexp_prefix_t *prefix,
return NOTMUCH_STATUS_BAD_QUERY_SYNTAX;
}
 
+   if (to_idx < 0)
+   to_idx += notmuch_database_get_revision (notmuch, NULL);
+
output = Xapian::Query (Xapian::Query::OP_VALUE_RANGE, 
NOTMUCH_VALUE_LAST_MOD,
Xapian::sortable_serialise (from_idx),
Xapian::sortable_serialise (to_idx));
diff --git a/test/T570-revision-tracking.sh b/test/T570-revision-tracking.sh
index e1cc684d..aaa45468 100755
--- a/test/T570-revision-tracking.sh
+++ b/test/T570-revision-tracking.sh
@@ -95,4 +95,12 @@ subtotal=$(notmuch count lastmod:..$lastmod)
 result=$(($subtotal == $total-1))
 test_expect_equal 1 "$result"
 
+if [ $NOTMUCH_HAVE_SFSEXP -eq 1 ]; then
+test_begin_subtest 'exclude one message using negative lastmod (sexp)'
+total=$(notmuch count '*')
+notmuch tag +${RANDOM} id:4efc743a.3060...@april.org
+count=$(notmuch count --query=sexp '(lastmod -1 *)')
+test_expect_equal 1 "$count"
+fi
+
 test_done
-- 
2.35.2

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


Re: [PATCH 1/2] test/emacs: add known broken test for stashing duplicate filename

2022-08-07 Thread David Bremner
David Bremner  writes:

> This duplicates (no pun intended) one of the bugs reported by Gregor
> in id:87edxw8jp4.fsf@no.workgroup

applied all 5 patches in this thread to master.

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


Re: [PATCH] NEWS: initial set of NEWS for 0.37.

2022-08-06 Thread David Bremner
David Bremner  writes:

> There are one or two more changes to apply (and potentially document)
> before release, but this covers most of my commits.

applied to master.

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


Re: [PATCH 1/3] doc/notmuch: merge two sections on external commands.

2022-08-06 Thread David Bremner
David Bremner  writes:

> When adding the description of the propagation of NOTMUCH_CONFIG, I
> missed that there was already a section on external commands, with a
> different title.

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


Re: [PATCH 1/6] tests: remove dead code from T055-path-config.sh

2022-08-06 Thread David Bremner
David Bremner  writes:

> This case statement does nothing.
> ---
>  test/T055-path-config.sh | 3 ---
>  1 file changed, 3 deletions(-)

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


Subjects for messages with multiple files

2022-08-06 Thread David Bremner
Gregor Zattler  writes:

> In my particular case the notmuch-search buffer shows two
> lines for two matching threads one of which stands out
> because its date is 1970-01-01 because I was too lazy to
> provide Date: headers in the test case's messages.
>
> In my particular case the Subject: shown on this very line
> for the test case is "two".  But if I place the cursor on
> this line and hit RET, the "first" of the three messages is
> shown, which in my particular case happens to be the one
> with Subject: "one".  Correspondingly the very first line of
> this notmuch-show buffer reads "one".

The underlying issue here is a bit tricky. Each message-id has a subject
value [1] associated with it. This is used to decide what to display
from notmuch search (i.e. it's used to construct the subject threads)
and it is used by the regex search.  Currently (since 2017) we make some
effort to maintain that as the subject of the first file indexed. The
numbering of duplicates on the other hand is by lexicographic order of
the filenames [2].  Probably we want to keep a list of subjects, but
then the question is how to make the order match. Ordering the files by
discovery order could be done (although not as trivially as you might
expect) or ordering the subjects by alphabetical order of filename could
be done. The latter probably requires less intrusive changes to the
database, but the question, for those who made it this far is we care
about keeping track of what the first indexed file is.  I had a quick
look back at the previous discussion [3] and I see some vague reference
to that being desirable as mitigation for some duplicate message-id
attacks, but I'm not sure how convincing that is.

[1]: actually a Xapian value slot, for those familiar with Xapian.

[2]: something like that anyway. The main point is that the database
 doesn't know anything about the order files are indexed
 (discovered).

[3]: see e.g. 
https://nmbug.notmuchmail.org/nmweb/search/id%3A87378dny3d.fsf%40qmul.ac.uk
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: [bug]: notmuch-emacs: notmuch-show: "c F" shows same file name for different instances of duplicate messages

2022-08-04 Thread David Bremner
David Bremner  writes:

> Gregor Zattler  writes:
>
>> Since the emails in this test case differ in Subjects they
>> reveal another problem with showing different instances of
>> seemingly same emails: While cycling through the three
>> emails in notmuch show the Subject line is duly showed as
>> "one", "two", "three", but the very first grey line every
>> time shows "one".  I don't know if that is a bug or not.
>
> I'll have to think about this a bit more, both whether it's a bug or a
> feature and how hard it is to change.

For those following along at home, I think Gregor refers to the "thread
subject" as shown by e.g. "notmuch search". This might or might not be
related to the message being replaced by a different duplicate.

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


Re: [bug]: notmuch-emacs: notmuch-show: "c F" shows same file name for different instances of duplicate messages

2022-08-04 Thread David Bremner
Gregor Zattler  writes:

> Dear notmuch developers,
>
> the new feature of showing different instances of emails
> with same Message-Id is great and very helpful.
>
> But in notmuch-emacs, when hitting "c F" in notmuch show
> always stashes the very same filename, in my case the one
> fitting the search term.
>
> Also hitting "V" in notmuch-show shows the very same raw
> email.

As you probably saw, I sent patches to the list for these two issues.

> Since the emails in this test case differ in Subjects they
> reveal another problem with showing different instances of
> seemingly same emails: While cycling through the three
> emails in notmuch show the Subject line is duly showed as
> "one", "two", "three", but the very first grey line every
> time shows "one".  I don't know if that is a bug or not.

I'll have to think about this a bit more, both whether it's a bug or a
feature and how hard it is to change.
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH 3/3] emacs: add duplicate support to notmuch-show-view-raw-message

2022-08-04 Thread David Bremner
This fixes one of the bugs reported by Gregor in [1]

[1]: id:87edxw8jp4.fsf@no.workgroup
---
 emacs/notmuch-show.el   | 8 ++--
 test/T450-emacs-show.sh | 1 -
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index e9a9ac2c..a6650678 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -2143,12 +2143,16 @@ to show, nil otherwise."
   "View the original source of the current message."
   (interactive)
   (let* ((id (notmuch-show-get-message-id))
-(buf (get-buffer-create (concat "*notmuch-raw-" id "*")))
+(duplicate (notmuch-show-get-duplicate))
+(args (if (> duplicate 1)
+  (list (format "--duplicate=%d" duplicate) id)
+(list id)))
+(buf (get-buffer-create (format "*notmuch-raw-%s-%d*" id duplicate)))
 (inhibit-read-only t))
 (pop-to-buffer-same-window buf)
 (erase-buffer)
 (let ((coding-system-for-read 'no-conversion))
-  (notmuch--call-process notmuch-command nil t nil "show" "--format=raw" 
id))
+  (apply #'notmuch--call-process notmuch-command nil t nil "show" 
"--format=raw" args))
 (goto-char (point-min))
 (set-buffer-modified-p nil)
 (setq buffer-read-only t)
diff --git a/test/T450-emacs-show.sh b/test/T450-emacs-show.sh
index 83e902f1..c4202e0a 100755
--- a/test/T450-emacs-show.sh
+++ b/test/T450-emacs-show.sh
@@ -383,7 +383,6 @@ test_expect_equal_file_nonempty 
$EXPECTED/notmuch-show-duplicate-4 OUTPUT
 
 FILE4=$(notmuch search --output=files --duplicate=4 "id:${ID3}")
 test_begin_subtest "duplicate=4, raw"
-test_subtest_known_broken
 test_emacs "(notmuch-show \"id:${ID3}\")
   (notmuch-show-choose-duplicate 4)
   (notmuch-show-view-raw-message)
-- 
2.35.2

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


[PATCH 2/3] emacs/show: provide a more friendly function to get duplicate num

2022-08-04 Thread David Bremner
There is not much code here, but at least we can fix the indexing as 1
based.
---
 emacs/notmuch-show.el | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 527db4bb..e9a9ac2c 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -1813,7 +1813,7 @@ current thread."
 
 (defun notmuch-show-get-filename ()
   "Return the filename of the current message."
-  (let ((duplicate (or (notmuch-show-get-prop :duplicate) 1)))
+  (let ((duplicate (notmuch-show-get-duplicate)))
 (nth (1- duplicate) (notmuch-show-get-prop :filename
 
 (defun notmuch-show-get-header (header  props)
@@ -1826,6 +1826,10 @@ current thread."
 (defun notmuch-show-get-date ()
   (notmuch-show-get-header :Date))
 
+(defun notmuch-show-get-duplicate ()
+  ;; if no duplicate property exists, assume first file
+  (or (notmuch-show-get-prop :duplicate) 1))
+
 (defun notmuch-show-get-timestamp ()
   (notmuch-show-get-prop :timestamp))
 
-- 
2.35.2

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


[PATCH 1/3] test/emacs: add known broken test for viewing raw duplicate

2022-08-04 Thread David Bremner
This duplicates one of the bugs reported by Gregor in [1].

[1]: id:87edxw8jp4.fsf@no.workgroup
---
 test/T450-emacs-show.sh | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/test/T450-emacs-show.sh b/test/T450-emacs-show.sh
index ab611d56..83e902f1 100755
--- a/test/T450-emacs-show.sh
+++ b/test/T450-emacs-show.sh
@@ -381,4 +381,15 @@ test_emacs "(notmuch-show \"id:${ID3}\")
   (test-visible-output \"OUTPUT\")"
 test_expect_equal_file_nonempty $EXPECTED/notmuch-show-duplicate-4 OUTPUT
 
+FILE4=$(notmuch search --output=files --duplicate=4 "id:${ID3}")
+test_begin_subtest "duplicate=4, raw"
+test_subtest_known_broken
+test_emacs "(notmuch-show \"id:${ID3}\")
+  (notmuch-show-choose-duplicate 4)
+  (notmuch-show-view-raw-message)
+  (test-visible-output \"OUTPUT\")"
+subject4=$(grep '^Subject:' $FILE4)
+subject=$(grep '^Subject:' OUTPUT)
+test_expect_equal "$subject4" "$subject"
+
 test_done
-- 
2.35.2

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


[PATCH 2/2] emacs: update notmuch-show-get-filename to handle duplicates

2022-08-04 Thread David Bremner
This fixes one of the bugs reported by Gregor in [1].

[1]: id:87edxw8jp4.fsf@no.workgroup
---
 emacs/notmuch-show.el   | 4 ++--
 test/T450-emacs-show.sh | 1 -
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 1bc3b319..527db4bb 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -1811,10 +1811,10 @@ current thread."
 
 ;; dme: Would it make sense to use a macro for many of these?
 
-;; XXX TODO figure out what to do about multiple filenames
 (defun notmuch-show-get-filename ()
   "Return the filename of the current message."
-  (car (notmuch-show-get-prop :filename)))
+  (let ((duplicate (or (notmuch-show-get-prop :duplicate) 1)))
+(nth (1- duplicate) (notmuch-show-get-prop :filename
 
 (defun notmuch-show-get-header (header  props)
   "Return the named header of the current message, if any."
diff --git a/test/T450-emacs-show.sh b/test/T450-emacs-show.sh
index 2cebd43d..ab611d56 100755
--- a/test/T450-emacs-show.sh
+++ b/test/T450-emacs-show.sh
@@ -352,7 +352,6 @@ test_expect_equal "$output" "$subject"
 
 FILE3=$(notmuch search --output=files --duplicate=3 "id:${ID3}")
 test_begin_subtest "duplicate=3, stash"
-test_subtest_known_broken
 test_emacs_expect_t \
"(notmuch-show \"id:${ID3}\")
 (notmuch-show-choose-duplicate 3)
-- 
2.35.2

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


  1   2   3   4   5   6   7   8   9   10   >