[no subject]

2022-02-16 Thread David Bremner
Floris wrote: 
> FWIW having spaces between the function name and parentheses is rather
>uncommon for python style.  Though of course complaining about style
>without using an auto-formatter is pretty meh these days :)
>

Yeah fair enough, it's the default in the C code, but we pretty
clearly have different styles going on in different languages.

>> +val_p = capi.lib.notmuch_config_pairs_value (super()._iter_p)
>> +key_p = capi.lib.notmuch_config_pairs_key (super()._iter_p)
>> +key = base.BinString.from_cffi(key_p)
>
>does key_p need a NULL check first or can it never be NULL?

I think it can never be NULL, but if it is, better to raise an exception I 
think.

>>  def test_iter(self, db):
>> -assert list(db.config) == []
>> -db.config['spam'] = 'ham'
>> -db.config['eggs'] = 'bacon'
>> -assert set(db.config) == {'spam', 'eggs'}
>> -assert set(db.config.keys()) == {'spam', 'eggs'}
>> -assert set(db.config.values()) == {'ham', 'bacon'}
>> -assert set(db.config.items()) == {('spam', 'ham'), ('eggs', 
>> 'bacon')}
>> +import re
>> +prefix = re.compile(r"^TEST[.]")
>> +assert [ x for x in list(db.config) if prefix.match(x) ] == []
>
>`x.startswith('TEST.')` is probably lighter weight here, maybe easier to
>read too that's subjective i guess
>
>You can even try something like this to further make it more readable:
>
>has_prefix = lambda x: x.startswith('TEST.')

I did variation on this, defining an inner function instead of using a lambda.

>
>> +db.config['TEST.spam'] = 'TEST.ham'
>> +db.config['TEST.eggs'] = 'TEST.bacon'
>> +assert { x for x in set(db.config) if prefix.match(x) } == 
>> {'TEST.spam', 'TEST.eggs'}
>> +assert { x for x in set(db.config.keys()) if prefix.match (x) } == 
>> {'TEST.spam', 'TEST.eggs'}
>
>I'm not sure why you need to wrap `db.config.keys()` in `set()`?  This
>explicitly creates a set out of things before turning it back into an
>interator while you're fine with the original iterator I think?

Good question. That seems to apply to list(db.config) above also? 

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


[PATCH v2 1/2] test: known broken test for list(db.config) in python-cffi bindings

2022-02-16 Thread David Bremner
As of notmuch 0.34.2 [1], the python-cffi bindings make available the
configuration from both a config file and the database when accessing
Database.config like a dictionary.  It is therefore confusing that the
iterator operations only work on the configuration information stored
in the database.

[1]: d7f95724132bf658fd151630185899737e2ed829
---
 test/T055-path-config.sh | 21 +
 1 file changed, 21 insertions(+)

diff --git a/test/T055-path-config.sh b/test/T055-path-config.sh
index 1df240dd..71823039 100755
--- a/test/T055-path-config.sh
+++ b/test/T055-path-config.sh
@@ -293,6 +293,27 @@ user.primary_email=test_su...@notmuchmail.org
 EOF
test_expect_equal_file EXPECTED OUTPUT
 
+   test_begin_subtest "Config list from python ($config)"
+   test_subtest_known_broken
+   test_python < OUTPUT
+from notmuch2 import Database
+db=Database(config=Database.CONFIG.SEARCH)
+for key in list(db.config):
+print(key)
+EOF
+   cat < EXPECTED
+database.autocommit
+database.backup_dir
+database.hook_dir
+database.mail_root
+database.path
+maildir.synchronize_flags
+new.tags
+user.name
+user.other_email
+user.primary_email
+EOF
+   test_expect_equal_file EXPECTED OUTPUT
case $config in
XDG*)
   test_begin_subtest "Set shadowed config value in database ($config)"
-- 
2.34.1

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


[PATCH v2 2/2] python-cffi: use config_pairs API in ConfigIterator

2022-02-16 Thread David Bremner
This returns all of the config keys with non-empty values, not just
those that happen to be stored in the database.
---
 bindings/python-cffi/notmuch2/_build.py   | 16 -
 bindings/python-cffi/notmuch2/_config.py  | 40 +++
 bindings/python-cffi/tests/test_config.py | 24 --
 test/T055-path-config.sh  |  1 -
 4 files changed, 49 insertions(+), 32 deletions(-)

diff --git a/bindings/python-cffi/notmuch2/_build.py 
b/bindings/python-cffi/notmuch2/_build.py
index a55b484f..349bb79d 100644
--- a/bindings/python-cffi/notmuch2/_build.py
+++ b/bindings/python-cffi/notmuch2/_build.py
@@ -97,7 +97,7 @@ ffibuilder.cdef(
 typedef struct _notmuch_string_map_iterator notmuch_message_properties_t;
 typedef struct _notmuch_directory notmuch_directory_t;
 typedef struct _notmuch_filenames notmuch_filenames_t;
-typedef struct _notmuch_config_list notmuch_config_list_t;
+typedef struct _notmuch_config_pairs notmuch_config_pairs_t;
 typedef struct _notmuch_indexopts notmuch_indexopts_t;
 
 const char *
@@ -325,18 +325,18 @@ ffibuilder.cdef(
 notmuch_database_set_config (notmuch_database_t *db, const char *key, 
const char *value);
 notmuch_status_t
 notmuch_database_get_config (notmuch_database_t *db, const char *key, char 
**value);
-notmuch_status_t
-notmuch_database_get_config_list (notmuch_database_t *db, const char 
*prefix, notmuch_config_list_t **out);
+notmuch_config_pairs_t *
+notmuch_config_get_pairs (notmuch_database_t *db, const char *prefix);
 notmuch_bool_t
-notmuch_config_list_valid (notmuch_config_list_t *config_list);
+notmuch_config_pairs_valid (notmuch_config_pairs_t *config_list);
 const char *
-notmuch_config_list_key (notmuch_config_list_t *config_list);
+notmuch_config_pairs_key (notmuch_config_pairs_t *config_list);
 const char *
-notmuch_config_list_value (notmuch_config_list_t *config_list);
+notmuch_config_pairs_value (notmuch_config_pairs_t *config_list);
 void
-notmuch_config_list_move_to_next (notmuch_config_list_t *config_list);
+notmuch_config_pairs_move_to_next (notmuch_config_pairs_t *config_list);
 void
-notmuch_config_list_destroy (notmuch_config_list_t *config_list);
+notmuch_config_pairs_destroy (notmuch_config_pairs_t *config_list);
 """
 )
 
diff --git a/bindings/python-cffi/notmuch2/_config.py 
b/bindings/python-cffi/notmuch2/_config.py
index 29de6495..603fdcbf 100644
--- a/bindings/python-cffi/notmuch2/_config.py
+++ b/bindings/python-cffi/notmuch2/_config.py
@@ -13,27 +13,42 @@ class ConfigIter(base.NotmuchIter):
 def __init__(self, parent, iter_p):
 super().__init__(
 parent, iter_p,
-fn_destroy=capi.lib.notmuch_config_list_destroy,
-fn_valid=capi.lib.notmuch_config_list_valid,
-fn_get=capi.lib.notmuch_config_list_key,
-fn_next=capi.lib.notmuch_config_list_move_to_next)
+fn_destroy=capi.lib.notmuch_config_pairs_destroy,
+fn_valid=capi.lib.notmuch_config_pairs_valid,
+fn_get=capi.lib.notmuch_config_pairs_key,
+fn_next=capi.lib.notmuch_config_pairs_move_to_next)
 
 def __next__(self):
-item = super().__next__()
-return base.BinString.from_cffi(item)
-
+# skip pairs whose value is NULL
+while capi.lib.notmuch_config_pairs_valid(super()._iter_p):
+val_p = capi.lib.notmuch_config_pairs_value(super()._iter_p)
+key_p = capi.lib.notmuch_config_pairs_key(super()._iter_p)
+if key_p == capi.ffi.NULL:
+# this should never happen
+raise errors.NullPointerError
+key = base.BinString.from_cffi(key_p)
+capi.lib.notmuch_config_pairs_move_to_next(super()._iter_p)
+if val_p != capi.ffi.NULL and base.BinString.from_cffi(val_p) != 
"":
+return key
+self._destroy()
+raise StopIteration
 
 class ConfigMapping(base.NotmuchObject, collections.abc.MutableMapping):
-"""The config key/value pairs stored in the database.
+"""The config key/value pairs loaded from the database, config file,
+and and/or defaults.
 
 The entries are exposed as a :class:`collections.abc.MutableMapping` 
object.
 Note that setting a value to an empty string is the same as deleting it.
 
+Mutating (deleting or updating values) in the map persists only in
+the database, which can be shadowed by config files.
+
 :param parent: the parent object
 :param ptr_name: the name of the attribute on the parent which will
return the memory pointer.  This allows this object to
access the pointer via the parent's descriptor and thus
trigger :class:`MemoryPointer`'s memory safety.
+
 """
 
 def __init__(self, parent, ptr_name):
@@ -77,11 +92,10 @@ class ConfigMapping(base.NotmuchObject, 
collections.abc.MutableMapping):
 
  

Re: [PATCH] emacs: escape quote in notmuch-search-result-format docstring

2022-02-16 Thread David Bremner
Tomi Ollila  writes:

> On Wed, Feb 16 2022, David Bremner wrote:
>
> LGTM, now I remeber this syntax...
>
> Tomi
>

OK, the docstring is fixed in commit 6286b76a, which should be in the
next major release (0.36).

Thanks for the report,

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


Re: [PATCH] test: allow to use --full-sync

2022-02-16 Thread Tomi Ollila
On Wed, Feb 16 2022, Tomi Ollila wrote:

>
> I'd not merge this NOTMUCH_NEW_OPTIONS=--full-scan ;D too eagerly
> ... I'd like we really knew the reason (which is then written in
> commit message)

I seem I did not get my message above (or why the ;D is there)
expressed clear enough -- the idea there was that also

NOTMUCH_NEW_OPTIONS=--full-scan make test
would have worked

(or, NOTMUCH_NEW_OPTIONS=--verbose, to get noisy output -- and lot of
failed tests ;D)

(to disable such a leakage of environment variable into test run 
NOTMUCH_NEW_OPTIONS= should have been there before checking that variable
 -- OTOH just adding NOTMUCH_NEW_OPTIONS=... as way to provide any options
to notmuch new (for users to experiment) could be an option (or
something...))

Anyway, I am not proposing adding such...now... but better concentrate 
figuring out what is happening there and why...

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


Re: [PATCH] test: allow to use --full-sync

2022-02-16 Thread Tomi Ollila
On Wed, Feb 16 2022, Michael J. Gruber wrote:

> David Bremner venit, vidit, dixit 2022-02-16 14:04:17:
>> Michael J Gruber  writes:
>> 
>> > Some build infrastructure appears to habe problems with mtime/stat,
>> 
>> have
>
> Huh, this looks as if my mother tongue slipped in, while it's just key
> proximity.
>
>> > leading to spurious failures (noticed on s390x and aarch64 with epel8).
>> > Allow the test suite to be run with --full-sync so that release builds
>> > can use the test suite while avoiding spurious failures.
>> >
>> > Signed-off-by: Michael J Gruber 
>> > ---
>> >  test/README | 8 
>> >  test/test-lib-common.sh | 7 ++-
>> >  test/test-lib.sh| 2 +-
>> >  3 files changed, 15 insertions(+), 2 deletions(-)
>> >
>> > diff --git a/test/README b/test/README
>> > index 10f127cb..1de79b78 100644
>> > --- a/test/README
>> > +++ b/test/README
>> > @@ -110,6 +110,14 @@ printed on screen. This printing can be disabled by 
>> > setting the
>> >  NOTMUCH_TEST_QUIET variable to a non-null value. Message on test
>> >  failures and skips are still printed.
>> 
>> typo in variable name.
>
> Not here, but in fact in the actual patch ;)
>
>
>> How confident are you that this actually fixes your intermittent
>> failures?  There are quite a few literal invocations of "notmuch new" in
>> the test suite. Would those need to be changed as well?
>
> About 80% confident ... The patch covers all areas in which I've ever
> witnessed the spurious FAILs. I have not had a single failure with the
> patch. Many of the other invocations are not immediately after message
> creation.
>
> Some of them are immediately after, and - given that notmuch new catches
> the case of same time - I do not understand why this happens at all.
> That accounts for the other 20%.
>
> I don't mind carrying this locally and retrying without for the next
> round of notmuch updates. Having the patch here on-list may help
> someone else in the future in any case.

I'd not merge this NOTMUCH_NEW_OPTIONS=--full-scan ;D too eagerly
... I'd like we really knew the reason (which is then written in
commit message)

>
> Michael

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


Re: [PATCH] emacs: escape quote in notmuch-search-result-format docstring

2022-02-16 Thread Tomi Ollila
On Wed, Feb 16 2022, David Bremner wrote:

LGTM, now I remeber this syntax...

Tomi

> Prevent Emacs' mangling of quotes, which breaks the code sample.
> ---
>  emacs/notmuch.el | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/emacs/notmuch.el b/emacs/notmuch.el
> index 6abb17ff..c9cf80dc 100644
> --- a/emacs/notmuch.el
> +++ b/emacs/notmuch.el
> @@ -93,7 +93,7 @@
>  Supported fields are: date, count, authors, subject, tags.
>  For example:
>  (setq notmuch-search-result-format
> -  '((\"authors\" . \"%-40s\")
> +  \\='((\"authors\" . \"%-40s\")
>  (\"subject\" . \"%s\")))
>  
>  Line breaks are permitted in format strings (though this is
> -- 
> 2.34.1
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: [PATCH 2/2] python-cffi: use config_pairs API in ConfigIterator

2022-02-16 Thread Floris Bruynooghe
On Fri 11 Feb 2022 at 09:04 -0400, David Bremner wrote:

> This returns all of the config keys with non-empty values, not just
> those that happen to be stored in the database.
> ---
>  bindings/python-cffi/notmuch2/_build.py   | 16 +-
>  bindings/python-cffi/notmuch2/_config.py  | 37 +++
>  bindings/python-cffi/tests/test_config.py | 22 --
>  test/T055-path-config.sh  |  1 -
>  4 files changed, 44 insertions(+), 32 deletions(-)
>
> diff --git a/bindings/python-cffi/notmuch2/_build.py 
> b/bindings/python-cffi/notmuch2/_build.py
> index a55b484f..349bb79d 100644
> --- a/bindings/python-cffi/notmuch2/_build.py
> +++ b/bindings/python-cffi/notmuch2/_build.py
> @@ -97,7 +97,7 @@ ffibuilder.cdef(
>  typedef struct _notmuch_string_map_iterator notmuch_message_properties_t;
>  typedef struct _notmuch_directory notmuch_directory_t;
>  typedef struct _notmuch_filenames notmuch_filenames_t;
> -typedef struct _notmuch_config_list notmuch_config_list_t;
> +typedef struct _notmuch_config_pairs notmuch_config_pairs_t;
>  typedef struct _notmuch_indexopts notmuch_indexopts_t;
>  
>  const char *
> @@ -325,18 +325,18 @@ ffibuilder.cdef(
>  notmuch_database_set_config (notmuch_database_t *db, const char *key, 
> const char *value);
>  notmuch_status_t
>  notmuch_database_get_config (notmuch_database_t *db, const char *key, 
> char **value);
> -notmuch_status_t
> -notmuch_database_get_config_list (notmuch_database_t *db, const char 
> *prefix, notmuch_config_list_t **out);
> +notmuch_config_pairs_t *
> +notmuch_config_get_pairs (notmuch_database_t *db, const char *prefix);
>  notmuch_bool_t
> -notmuch_config_list_valid (notmuch_config_list_t *config_list);
> +notmuch_config_pairs_valid (notmuch_config_pairs_t *config_list);
>  const char *
> -notmuch_config_list_key (notmuch_config_list_t *config_list);
> +notmuch_config_pairs_key (notmuch_config_pairs_t *config_list);
>  const char *
> -notmuch_config_list_value (notmuch_config_list_t *config_list);
> +notmuch_config_pairs_value (notmuch_config_pairs_t *config_list);
>  void
> -notmuch_config_list_move_to_next (notmuch_config_list_t *config_list);
> +notmuch_config_pairs_move_to_next (notmuch_config_pairs_t *config_list);
>  void
> -notmuch_config_list_destroy (notmuch_config_list_t *config_list);
> +notmuch_config_pairs_destroy (notmuch_config_pairs_t *config_list);
>  """
>  )
>  
> diff --git a/bindings/python-cffi/notmuch2/_config.py 
> b/bindings/python-cffi/notmuch2/_config.py
> index 29de6495..d73539c5 100644
> --- a/bindings/python-cffi/notmuch2/_config.py
> +++ b/bindings/python-cffi/notmuch2/_config.py
> @@ -13,27 +13,39 @@ class ConfigIter(base.NotmuchIter):
>  def __init__(self, parent, iter_p):
>  super().__init__(
>  parent, iter_p,
> -fn_destroy=capi.lib.notmuch_config_list_destroy,
> -fn_valid=capi.lib.notmuch_config_list_valid,
> -fn_get=capi.lib.notmuch_config_list_key,
> -fn_next=capi.lib.notmuch_config_list_move_to_next)
> +fn_destroy=capi.lib.notmuch_config_pairs_destroy,
> +fn_valid=capi.lib.notmuch_config_pairs_valid,
> +fn_get=capi.lib.notmuch_config_pairs_key,
> +fn_next=capi.lib.notmuch_config_pairs_move_to_next)
>  
>  def __next__(self):
> -item = super().__next__()
> -return base.BinString.from_cffi(item)
> -
> +# skip pairs whose value is NULL
> +while capi.lib.notmuch_config_pairs_valid (super()._iter_p):

FWIW having spaces between the function name and parentheses is rather
uncommon for python style.  Though of course complaining about style
without using an auto-formatter is pretty meh these days :)

> +val_p = capi.lib.notmuch_config_pairs_value (super()._iter_p)
> +key_p = capi.lib.notmuch_config_pairs_key (super()._iter_p)
> +key = base.BinString.from_cffi(key_p)

does key_p need a NULL check first or can it never be NULL?

> +capi.lib.notmuch_config_pairs_move_to_next (super()._iter_p)
> +if val_p != capi.ffi.NULL and base.BinString.from_cffi(val_p) != 
> "":
> +return key
> +self._destroy()
> +raise StopIteration
>  
>  class ConfigMapping(base.NotmuchObject, collections.abc.MutableMapping):
> -"""The config key/value pairs stored in the database.
> +"""The config key/value pairs loaded from the database, config file,
> +and and/or defaults.
>  
>  The entries are exposed as a :class:`collections.abc.MutableMapping` 
> object.
>  Note that setting a value to an empty string is the same as deleting it.
>  
> +Mutating (deleting or updating values) in the map persists only in
> +the database, which can be shadowed by config files.
> +
>  :param parent: the parent object
>  :param 

Re: Python binding SIGABRT/SIGSEGV

2022-02-16 Thread Floris Bruynooghe
On Thu 10 Feb 2022 at 13:16 +0100, Michael J Gruber wrote:

> Austin Lund venit, vidit, dixit 2022-02-10 06:56:12:
>> I'm clearly doing this python code wrong by not using the iterator correctly:
>> 
>> > import notmuch2
>> > 
>> > d = notmuch2.Database()
>> > m = list(d.messages("since:today"))
>> > p = m[0].path
>> > print(p)
>> 
>> But I seem to be getting a SIGABRT instead of a python stack trace.  Is
>> this the expected behaviour?
>
> You didn't expect it :)
>
> And this can be confusing. d.messages() returns an iterator through
> Message objects whose lifetime depends on the iterator. In contrast,
> thread.get_messages() returns on iterator through OwnedMessage objects
> whose lifetime depends on the thread.
>
> As soon as the iterator is depleted, the returned objects are (possibly)
> gone. (Well, because it's return by reference in Python, and ...)
>
> If you're interested in m[0] only you can "cheat" by not depleting the
> iterator:
>
> mm = next(d.messages("since:today"))
>
> p = mm.path
>
> This never frees the object (I think).
>
> My attempts with notmuch2._message.OwnedMessage (and db as parent)
> failed. There must be a better way, possibly using a context manager or
> search.
>
> I guess usually people just use the iterator in a for loop and do
> something with the message inside the loop (while the iterator is not
> depleted), such as converting it into a proper email.Message object
> (i.e. instantiating a new object from it).

Hum, to be fair I consider this a serious bug in the notmuch2 bindings.
You should not be able to crash whatever you do and not need to
understand the internal notmuch memory model.  I tried to build the
bindings so they would keep alive what they need, but it seems it fails
here.  It would be good to figure out if this can be fixed.

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


Re: [PATCH] test: allow to use --full-sync

2022-02-16 Thread Michael J Gruber
David Bremner venit, vidit, dixit 2022-02-16 14:04:17:
> Michael J Gruber  writes:
> 
> > Some build infrastructure appears to habe problems with mtime/stat,
> 
> have

Huh, this looks as if my mother tongue slipped in, while it's just key
proximity.

> > leading to spurious failures (noticed on s390x and aarch64 with epel8).
> > Allow the test suite to be run with --full-sync so that release builds
> > can use the test suite while avoiding spurious failures.
> >
> > Signed-off-by: Michael J Gruber 
> > ---
> >  test/README | 8 
> >  test/test-lib-common.sh | 7 ++-
> >  test/test-lib.sh| 2 +-
> >  3 files changed, 15 insertions(+), 2 deletions(-)
> >
> > diff --git a/test/README b/test/README
> > index 10f127cb..1de79b78 100644
> > --- a/test/README
> > +++ b/test/README
> > @@ -110,6 +110,14 @@ printed on screen. This printing can be disabled by 
> > setting the
> >  NOTMUCH_TEST_QUIET variable to a non-null value. Message on test
> >  failures and skips are still printed.
> 
> typo in variable name.

Not here, but in fact in the actual patch ;)


> How confident are you that this actually fixes your intermittent
> failures?  There are quite a few literal invocations of "notmuch new" in
> the test suite. Would those need to be changed as well?

About 80% confident ... The patch covers all areas in which I've ever
witnessed the spurious FAILs. I have not had a single failure with the
patch. Many of the other invocations are not immediately after message
creation.

Some of them are immediately after, and - given that notmuch new catches
the case of same time - I do not understand why this happens at all.
That accounts for the other 20%.

I don't mind carrying this locally and retrying without for the next
round of notmuch updates. Having the patch here on-list may help
someone else in the future in any case.

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


Re: [PATCH] test: allow to use --full-sync

2022-02-16 Thread David Bremner
Michael J Gruber  writes:

> Some build infrastructure appears to habe problems with mtime/stat,

have

> leading to spurious failures (noticed on s390x and aarch64 with epel8).
> Allow the test suite to be run with --full-sync so that release builds
> can use the test suite while avoiding spurious failures.
>
> Signed-off-by: Michael J Gruber 
> ---
>  test/README | 8 
>  test/test-lib-common.sh | 7 ++-
>  test/test-lib.sh| 2 +-
>  3 files changed, 15 insertions(+), 2 deletions(-)
>
> diff --git a/test/README b/test/README
> index 10f127cb..1de79b78 100644
> --- a/test/README
> +++ b/test/README
> @@ -110,6 +110,14 @@ printed on screen. This printing can be disabled by 
> setting the
>  NOTMUCH_TEST_QUIET variable to a non-null value. Message on test
>  failures and skips are still printed.

typo in variable name.

How confident are you that this actually fixes your intermittent
failures?  There are quite a few literal invocations of "notmuch new" in
the test suite. Would those need to be changed as well?

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


[PATCH] emacs: escape quote in notmuch-search-result-format docstring

2022-02-16 Thread David Bremner
Prevent Emacs' mangling of quotes, which breaks the code sample.
---
 emacs/notmuch.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index 6abb17ff..c9cf80dc 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -93,7 +93,7 @@
 Supported fields are: date, count, authors, subject, tags.
 For example:
 (setq notmuch-search-result-format
-  '((\"authors\" . \"%-40s\")
+  \\='((\"authors\" . \"%-40s\")
 (\"subject\" . \"%s\")))
 
 Line breaks are permitted in format strings (though this is
-- 
2.34.1

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


[PATCH] test: allow to use --full-sync

2022-02-16 Thread Michael J Gruber
Some build infrastructure appears to habe problems with mtime/stat,
leading to spurious failures (noticed on s390x and aarch64 with epel8).
Allow the test suite to be run with --full-sync so that release builds
can use the test suite while avoiding spurious failures.

Signed-off-by: Michael J Gruber 
---
 test/README | 8 
 test/test-lib-common.sh | 7 ++-
 test/test-lib.sh| 2 +-
 3 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/test/README b/test/README
index 10f127cb..1de79b78 100644
--- a/test/README
+++ b/test/README
@@ -110,6 +110,14 @@ printed on screen. This printing can be disabled by 
setting the
 NOTMUCH_TEST_QUIET variable to a non-null value. Message on test
 failures and skips are still printed.
 
+File system/mtime issues
+
+Normally, `notmuch new` uses directory modification times, and the test
+suite checks that this works. If you encounter spurious test failures
+where messages added by one subtest appear to show up in the next subtest
+only (indicating mtime/stat problems) you can set NOTMUCH_TEST_FULLSYNC
+so that the test suite uses the --full-sync option of notmuch new.
+
 Skipping Tests
 --
 If, for any reason, you need to skip one or more tests, you can do so
diff --git a/test/test-lib-common.sh b/test/test-lib-common.sh
index ebbf4cdf..91039478 100644
--- a/test/test-lib-common.sh
+++ b/test/test-lib-common.sh
@@ -29,6 +29,11 @@ if [[ -z "$NOTMUCH_SRCDIR" ]] || [[ -z "$NOTMUCH_BUILDDIR" 
]]; then
exit 1
 fi
 
+if test -n "$NOTMUCH_TEST_FULLSCAN"
+then
+   NOTMUCH_NEW_OPTIONS="--full-scan"
+fi
+
 backup_database () {
 test_name=$(basename $0 .sh)
 rm -rf $TMP_DIRECTORY/notmuch-dir-backup."$test_name"
@@ -226,7 +231,7 @@ EOF
 # are also supported here, so see that function for details.
 add_message () {
 generate_message "$@" &&
-notmuch new > /dev/null
+notmuch new $NOTMUCH_NEW_OPTIONS > /dev/null
 }
 
 if test -n "$valgrind"
diff --git a/test/test-lib.sh b/test/test-lib.sh
index 833bf5fe..0167b95f 100644
--- a/test/test-lib.sh
+++ b/test/test-lib.sh
@@ -521,7 +521,7 @@ test_json_nodes () {
 }
 
 NOTMUCH_NEW () {
-notmuch new "${@}" | grep -v -E -e '^Processed [0-9]*( total)? file|Found 
[0-9]* total file'
+notmuch new $NOTMUCH_NEW_OPTIONS "${@}" | grep -v -E -e '^Processed 
[0-9]*( total)? file|Found [0-9]* total file'
 }
 
 NOTMUCH_DUMP_TAGS () {
-- 
2.35.1.476.gacce7e407c

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


Re: [BUG] Bad quote in help

2022-02-16 Thread Tomi Ollila
On Wed, Feb 16 2022, Rudolf Adamkovič wrote:

> Repro steps:
>
> 1. C-h v
> 2. notmuch-search-result-format
> 3. RET
>
> See:
>
> For example:
> (setq notmuch-search-result-format
>   ’(("authors" . "%-40s")
> ("subject" . "%s")))
>
> The quote ’ needs changed to ', otherwise the example does not work.

The code in question in notmuch.el is:

(setq notmuch-search-result-format
  '((\"authors\" . \"%-40s\")
(\"subject\" . \"%s\")))

In this particular case it is unfortunate emacs modifies the output.

Tried to chage that to  \'((\"autho...

did not help (also renamed the defcustom to make a new definition so
that the content would be evaluated when doing c-x c-e in buffer...)

In rstdoc.el we have (text-quoting-style 'grave) to not do such docstring
modifications for display, but that is not applicable in this context...

Tomi

>
> Rudy
> -- 
> "Thinking is a momentary dismissal of irrelevancies."
> -- Richard Buckminster Fuller, 1969
>
> Rudolf Adamkovič  [he/him]
> Studenohorská 25
> 84103 Bratislava
> Slovakia
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org