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

2022-08-20 Thread jao
Hook run when the tree insertion process finishes its job.

--
This patch supersedes , but
changing the new variable name.

Right now, it can be used for silly things like removing or changing
the the "End of search." hardcoded message in the tree buffer.  But
also for more sophisticated things like folding all threads in add-ons
like my outline mode for tree buffers (to be submitted).

Signed-off-by: jao 
---
 emacs/notmuch-tree.el | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el
index f63ac9a5..7ceddee2 100644
--- a/emacs/notmuch-tree.el
+++ b/emacs/notmuch-tree.el
@@ -1084,6 +1084,12 @@ Complete list of currently available key bindings:
   (setq buffer-read-only t)
   (setq truncate-lines t))
 
+(defvar notmuch-tree-process-exit-functions nil
+  "Functions called when the process inserting a tree of results finishes.
+
+Functions in this list are called with one argument, the process
+object, and with the tree results buffer as the current buffer.")
+
 (defun notmuch-tree-process-sentinel (proc _msg)
   "Add a message to let user know when \"notmuch tree\" exits."
   (let ((buffer (process-buffer proc))
@@ -1102,7 +1108,8 @@ Complete list of currently available key bindings:
(insert "End of search results.")
(unless (= exit-status 0)
  (insert (format " (process returned %d)" exit-status)))
-   (insert "\n")
+   (insert "\n"
+ (run-hook-with-args 'notmuch-tree-process-exit-functions proc))
 
 (defun notmuch-tree-process-filter (proc string)
   "Process and filter the output of \"notmuch show\" for tree view."
-- 
2.37.2

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


[announce] Bower 1.0

2022-08-20 Thread Peter Wang
Hi,

Bower is a curses frontend for the Notmuch email system.
I wrote it for me, but you might like it, too.

https://github.com/wangp/bower

Bower 1.0 (2022-08-21)
==
The first commit to this project was made 11 years ago. Let's call this v1.0.

* index: Use Alt+Enter to open a thread in "obscured" mode.
  Messages that did not match the search query are displayed differently and
  not interactable.
* thread/pager: Use 'M' key to toggle obscured mode.
* Allow omitting "+" prefix when entering tag additions.
* Support tag editing on compose screen.
* Inherit tags from message being replied to or forwarded.
* Also apply tags to sent message when using a custom post_sendmail action.
* Use domain of From address for right part of Message-ID.
* Expand ~ in config values.
* Expand ~ in interactively entered commands.
* config: Add ui.default_save_directory option.
* Remove lynx as the default HTML-to-text filter.
* Improve search string parser.
* Fix bug where "body:(foo bar)" was unparsed as "body: ( foo bar )".
* Restrict places in search string where "~" names a Bower search term alias
  to after whitespace or open parenthesis/brace.
* Accept mailto: argument on command line.
* Accept --help and --version options.


BTW, you may also be interested in my IMAP/Maildir synchronisation tool:
https://github.com/wangp/pushpull
It doesn't synchronise notmuch tags, though.

Peter
___
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