Re: WIP: promote nmbug to user sync tool

2022-04-30 Thread Sean Whitton
[please keep me CCed]

Hello David,

On Sat 23 Apr 2022 at 10:38am -03, David Bremner wrote:

> One of the things that new (and old) users of notmuch often miss is a
> way to sync tags between hosts. muchsync exists, but it's a third
> party tool, and (if I understand correctly) it directly modifies the
> notmuch database. Meanwhile we ship a moderately complex python script
> called 'nmbug' which can be used to sync arbitrary tags between hosts.
> This series is my (first pass at an) attempt to promote nmbug to a
> notmuch subcommand "notmuch git". My plan is to replace my own
> homebrew "commit notmuch dump output to git" script with this new
> command; I think it may appeal to other users as well. As a bonus, it
> provides a simple (for the user) way to do incremental backups of the
> notmuch database.
>
> I had to add a couple of caching tricks to make the script usable for
> my database, but it is now reasonably fast (say 20s) to commit a days
> worth of changes on my machine.

I think I'm the person who's already been using nmbug for personal tags
for an appreciable length of time.  It is great to see these caching
improvements and the addition of a test suite.

> There are still some rough edges, mainly due to the heritage of the
> script. Some I am aware of include:
>
> - the (new) man page is inadequate
> - notmuch git doesn't understand the common arguments to notmuch (--config 
> and friends)
> - the defaults for prefix and git repo are wrong for most users. I was 
> thinking about either a
>   --nmbug argument to set the old defaults, or having the script recognize if 
> it is invoked as nmbug.
> - There are a few too many global variables
> - I just remembered, MAX_LASTMOD is unused, leftover from a previous design 
> for querying tags.

Just looking at my current usage, there are two cases where I've wrapped
nmbug in some additional myrepos scripting.  The first is a status
command:

status =
nmbug-spw status | grep -v "^U\s" || true
# `nmbug status` does not catch committed but unpushed changes
git --no-pager log --branches \
--not --remotes \
--simplify-by-decoration --decorate --oneline

Possibly notmuch-git could learn how to do this?

Secondly, I've got this auto-commit command:

autoci =
nmbug-spw status | perl -ne'/^[AD][ad]?\s/ and $i++ > 500 and exit 1' \
  && nmbug-spw commit

The guard has two purposes.  Firstly, it avoids wiping out git as part
of a cronjob auto-commit because the nmbug repo has just been cloned but
'nmbug checkout' hasn't been run.  Secondly, it avoids doing any
committing if there are any known remote changes that haven't been
integrated.  The latter thing is probably just a personal preference.

As for the former thing, I wonder if instead there could be some
mechanism, connected with the new caching, to associate nmbug repos with
the notmuch database, and refuse to operate unless that association
already exists?  So, 'nmbug checkout' would mark it as safe to sync back
and forth between the database and that repo no matter the number of
changes.

On Sat 23 Apr 2022 at 03:49pm -03, David Bremner wrote:

> Related, the current script does not understand NOTMUCH_PROFILE. That
> would be a natural way to locate the default git repo.

It would, but it wouldn't help with configuring a default prefix.
Perhaps an entry in .notmuch-config for that?  Currently I use a tiny
wrapper script:

#!/bin/sh

NMBGIT="$HOME/lib/nmbug-spw" NMBPREFIX="spw::" nmbug "$@"

but it would be great to just be able to type 'notmuch git ...'.

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


[PATCH 2/2] doc/sexp-queries: be more consistent about ending example text

2022-04-30 Thread David Bremner
Most, but not all of the the explanatory texts already end in
'.'. This makes the remainder match.
---
 doc/man7/notmuch-sexp-queries.rst | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/doc/man7/notmuch-sexp-queries.rst 
b/doc/man7/notmuch-sexp-queries.rst
index a20943c6..1d7e0ae9 100644
--- a/doc/man7/notmuch-sexp-queries.rst
+++ b/doc/man7/notmuch-sexp-queries.rst
@@ -221,7 +221,7 @@ EXAMPLES
 
 ``(not Bob Marley)``
 
-Match messages containing neither "Bob" nor "Marley", nor their stems,
+Match messages containing neither "Bob" nor "Marley", nor their stems.
 
 ``"quick fox"`` ``quick-fox`` ``quick@fox``
 
@@ -230,11 +230,11 @@ EXAMPLES
 
 ``(folder (of (id 1234@invalid)))``
 
-Match any message in the same folder as the one with Message-Id 
"1234\@invalid"
+Match any message in the same folder as the one with Message-Id 
"1234\@invalid".
 
 ``(id 1234@invalid blah@test)``
 
-Matches Message-Id "1234\@invalid" *or* Message-Id "blah\@test"
+Matches Message-Id "1234\@invalid" *or* Message-Id "blah\@test".
 
 ``(and (infix "date:2009-11-18..2009-11-18") (tag unread))``
 
@@ -260,13 +260,13 @@ EXAMPLES
 
 ``(thread (of (id 1234@invalid)))``
 
-Match any message in the same thread as the one with Message-Id 
"1234\@invalid"
+Match any message in the same thread as the one with Message-Id 
"1234\@invalid".
 
 ``(thread (matching (from b...@example.com) (to b...@example.com)))``
 
 Match any (messages in) a thread containing a message from
 "bob\@example.com" and a (possibly distinct) message to
-"bob\@example.com"
+"bob\@example.com".
 
 ``(to (or b...@example.com mall...@example.org))`` ``(or (to b...@example.com) 
(to mall...@example.org))``
 
@@ -281,7 +281,7 @@ EXAMPLES
 ``(List *)``
 
 Match messages with a non-empty List-Id header, assuming
-configuration ``index.header.List=List-Id``
+configuration ``index.header.List=List-Id``.
 
 .. _macro_examples:
 
-- 
2.35.2

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


[PATCH 1/2] doc/sexp-queries: fix example

2022-04-30 Thread David Bremner
Update the explanatory text to match the query.
---
 doc/man7/notmuch-sexp-queries.rst | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/doc/man7/notmuch-sexp-queries.rst 
b/doc/man7/notmuch-sexp-queries.rst
index 0eb86734..a20943c6 100644
--- a/doc/man7/notmuch-sexp-queries.rst
+++ b/doc/man7/notmuch-sexp-queries.rst
@@ -265,8 +265,8 @@ EXAMPLES
 ``(thread (matching (from b...@example.com) (to b...@example.com)))``
 
 Match any (messages in) a thread containing a message from
-"bob\@example.com" and a (possibly distinct) message to "bob at
-example.com")
+"bob\@example.com" and a (possibly distinct) message to
+"bob\@example.com"
 
 ``(to (or b...@example.com mall...@example.org))`` ``(or (to b...@example.com) 
(to mall...@example.org))``
 
-- 
2.35.2

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


Re: [PATCH] doc/sexp-queries: escape @ in non-verbatim text

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

> This prevents sphinx-doc from creating spurious mailto: links. Thanks
> to Jakub Wilk for telling me about the fix.

applied to master.

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


Re: [PATCH 1/1] emacs: Make notmuch-show-next-thread return nil on failure

2022-04-30 Thread David Bremner
Leo  writes:

> From: Leo Okawa Ericson 
>
> Having notmuch-show-next-thread return non-nil on success and nil on
> failure makes it easier for users to interact with notmuch via elisp.

You talk about notmuch-show-next-thread, but you seem to be modifying
notmuch-search-show-thread. That actually seems like a bit of a strange
function to invoke programatically, since it deduces the argument from
the current buffer.  It might be better for your code to call
notmuch-show directly, since notmuch-search-show-thread is pretty tied
to the internals of notmuch-search-mode.

In any case:

If you change the API to have a meaningful return value, please update
the docstring for the function

We generally need a test for any new feature, and this is arguably a new
feature. If you need help constructing a test, feel free to ask. There
are several examples in  test/T*emacs*.sh.
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: [PATCH 1/1] emacs: Make notmuch-show-next-thread return nil on failure

2022-04-30 Thread David Bremner
Leo Okawa Ericson  writes:

> Tomi Ollila  writes:
>
>>
>> I don't see why this indentation change is happening...
>>
>
> I thought the indentation was inconsistent with the rest of the file.  I
> tried running the auto-indenter on a other more complex functions which
> changed nothing, but it did change it on this function so I assumed it
> was good to include it.  If it's bad etiquette, wrong or unnecessary I'm happy
> to amend the patch.

In general indentation (and whitespace) cleanup is fine, but should be
seperate commits labelled as such.

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