Re: [PATCH v2] emacs: drop C-tab binding in hello mode, document .

2021-11-03 Thread Tomi Ollila
On Sat, Oct 30 2021, David Bremner wrote:

> The  binding has always been there, but the docs were
> apparently mistakenly changed to say  [1]
>
> Revert to  in the documentation.
>
> The commit also drops the C- binding, since it seems redundant
> and it interferes with tab-bar-mode.
>
> [1]: 703dec7754da477b5683867c88cb940b8553be91.

I am not against :D

> ---
>  doc/notmuch-emacs.rst  | 2 +-
>  emacs/notmuch-hello.el | 1 -
>  2 files changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/doc/notmuch-emacs.rst b/doc/notmuch-emacs.rst
> index 12ee25e5..22aee340 100644
> --- a/doc/notmuch-emacs.rst
> +++ b/doc/notmuch-emacs.rst
> @@ -56,7 +56,7 @@ notmuch-hello key bindings
>  
>  Move to the next widget (button or text entry field)
>  
> -
> +
>  Move to the previous widget.
>  
>  
> diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
> index 71487bd9..acd48c9b 100644
> --- a/emacs/notmuch-hello.el
> +++ b/emacs/notmuch-hello.el
> @@ -702,7 +702,6 @@ with `notmuch-hello-query-counts'."
>;; that when we modify map it does not modify widget-keymap).
>(let ((map (make-composed-keymap (list (make-sparse-keymap) 
> widget-keymap
>  (set-keymap-parent map notmuch-common-keymap)
> -(define-key map (kbd "") 'widget-backward)
>  map)
>"Keymap for \"notmuch hello\" buffers.")
>  
> -- 
> 2.33.0
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: [PATCH 4/4] python-cffi: switch to notmuch_database_{open,create}_with_config

2021-11-03 Thread Tomi Ollila
On Tue, Nov 02 2021, David Bremner wrote:

> Floris Bruynooghe  writes:
>
>> On Sat 30 Oct 2021 at 13:22 -0300, David Bremner wrote:
>>> +
>>> +.. deprecated:: 0.35
>>> +   Use the ``cfg_path`` parameter instead.
>>
>> Do you mean the ``config`` parameter to :meth:`__init__` or
>> :meth:`__create__` here instead of ``cfg_path``?
>>
>
> Good catch, that is indeed what I meant.
>
>
> [rest of patch snipped]
>
>> LGTM I think.
>>
>> As an aside, what is the oldest python version we still want to support?
>> I'm wondering if we can get rid of this `if not hasattr(os, 'PathLike')`
>> construct which only exists because of python 3.5.
>
> I usually go by what is in Debian oldstable, which is 3.7.x at this
> point. But maybe Tomi wants to comment, he is usually expert at finding
> old distros to run notmuch on ;)

I run nmbug using python 2.7 >;D

Last time I recall python 3.6 is the oldest supported version
(i.e. python 3.5 is EOL'd).

>
> d
>
> PS: I took the liberty of replying to the list, hope that's OK.

Tomi

Remembered this after spending some time creating svg image -- so
backupping it too :D

⠠⢄⣀⡀⠀⢾⡷
⢀⣠⣣⣉⠙⢺⡗⠦⢤⣀⡀
⠸⣌⣋⡼⠀⣸⡇⠀⠀⡜⡌⠁
⠀⣿⣷⠀⠺⠶⠾⠂
⠀⣿⣿
⠀⠀⣠⣴⣶⣿⣿⣶⣦⣄

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


[RFC PATCH] emacs: add notmuch-logo.svg

2021-11-01 Thread Tomi Ollila
handcrafted scalable vector graphics version of the notmuch logo

for sharper image
---

Loads in emacs, on my screen letter was white on white background
(emacs dark background) so hints how to make it look better on
dark mode emacs (i.e. white lines instead of black) and how to
have transparent background for everyone...

(did not run (xml) conformity check (just realized should do) -- anyway
I did not see anything non-conforming there ;D

 emacs/notmuch-logo.svg | 26 ++
 1 file changed, 26 insertions(+)
 create mode 100644 emacs/notmuch-logo.svg

diff --git a/emacs/notmuch-logo.svg b/emacs/notmuch-logo.svg
new file mode 100644
index ..6625e651
--- /dev/null
+++ b/emacs/notmuch-logo.svg
@@ -0,0 +1,26 @@
+
+http://www.w3.org/2000/svg; height="220" width="200">
+  
+  
+
+
+
+  
+  
+  
+
+
+
+
+  
+  
+  
+  
+
+
+  
+
-- 
2.25.1

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


Re: [PATCH] rename built_with.sexpr_query to built_with.sexp_queries

2021-11-01 Thread Tomi Ollila
On Sat, Oct 30 2021, David Bremner wrote:

> It is confusing to use two different names (sexp vs sexpr) when
> compared with the command line option --query=sexp and (furthermore)
> singular vs plural when compared with the man page title.

like wrote before -- fine by me...

Tomi


> ---
>  doc/man7/notmuch-sexp-queries.rst | 2 +-
>  lib/built-with.c  | 2 +-
>  notmuch-config.c  | 4 ++--
>  test/T030-config.sh   | 2 +-
>  test/T055-path-config.sh  | 2 +-
>  5 files changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/doc/man7/notmuch-sexp-queries.rst 
> b/doc/man7/notmuch-sexp-queries.rst
> index d3b18593..3c33232f 100644
> --- a/doc/man7/notmuch-sexp-queries.rst
> +++ b/doc/man7/notmuch-sexp-queries.rst
> @@ -21,7 +21,7 @@ build of notmuch supports it with
>  
>  ::
>  
> -   $ notmuch config get built_with.sexpr_query
> +   $ notmuch config get built_with.sexp_queries
>  
>  
>  S-EXPRESSIONS
> diff --git a/lib/built-with.c b/lib/built-with.c
> index 89958e12..275e72b8 100644
> --- a/lib/built-with.c
> +++ b/lib/built-with.c
> @@ -32,7 +32,7 @@ notmuch_built_with (const char *name)
>   return HAVE_XAPIAN_DB_RETRY_LOCK;
>  } else if (STRNCMP_LITERAL (name, "session_key") == 0) {
>   return true;
> -} else if (STRNCMP_LITERAL (name, "sexpr_query") == 0) {
> +} else if (STRNCMP_LITERAL (name, "sexp_queries") == 0) {
>   return HAVE_SFSEXP;
>  } else {
>   return false;
> diff --git a/notmuch-config.c b/notmuch-config.c
> index db00a26c..11d8d68b 100644
> --- a/notmuch-config.c
> +++ b/notmuch-config.c
> @@ -680,9 +680,9 @@ _notmuch_config_list_built_with ()
>  printf ("%sretry_lock=%s\n",
>   BUILT_WITH_PREFIX,
>   notmuch_built_with ("retry_lock") ? "true" : "false");
> -printf ("%ssexpr_query=%s\n",
> +printf ("%ssexp_queries=%s\n",
>   BUILT_WITH_PREFIX,
> - notmuch_built_with ("sexpr_query") ? "true" : "false");
> + notmuch_built_with ("sexp_queries") ? "true" : "false");
>  }
>  
>  static int
> diff --git a/test/T030-config.sh b/test/T030-config.sh
> index 3a585d1b..b99eb9e7 100755
> --- a/test/T030-config.sh
> +++ b/test/T030-config.sh
> @@ -51,7 +51,7 @@ cat < EXPECTED
>  built_with.compact=something
>  built_with.field_processor=something
>  built_with.retry_lock=something
> -built_with.sexpr_query=something
> +built_with.sexp_queries=something
>  database.autocommit=8000
>  database.mail_root=MAIL_DIR
>  database.path=MAIL_DIR
> diff --git a/test/T055-path-config.sh b/test/T055-path-config.sh
> index ef22e964..38f72e5e 100755
> --- a/test/T055-path-config.sh
> +++ b/test/T055-path-config.sh
> @@ -277,7 +277,7 @@ EOF
>  built_with.compact=something
>  built_with.field_processor=something
>  built_with.retry_lock=something
> -built_with.sexpr_query=something
> +built_with.sexp_queries=something
>  database.autocommit=8000
>  database.backup_dir
>  database.hook_dir
> -- 
> 2.33.0
>
> ___
> notmuch mailing list -- notmuch@notmuchmail.org
> To unsubscribe send an email to notmuch-le...@notmuchmail.org
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: [PATCH 4/4] python-cffi: switch to notmuch_database_{open,create}_with_config

2021-10-31 Thread Tomi Ollila
On Sat, Oct 30 2021, David Bremner wrote:

> Since release 0.32, libnotmuch provides searching for database and
> configuration paths. This commit changes the python module notmuch2 to
> use those facilities.
>
> This fixes the bug reported in [1], along with a couple of the
> deprecation warnings in the python bindings.
>
> Database.default_path is deprecated, since it no longer faithfully
> reflects what libnotmuch is doing, and it is also no longer used in
> the bindings themselves.
>
> This commit choose the default of config=CONFIG.EMPTY (equivalent to
> passing "" to notmuch_database_open_with_config).  This makes the
> change upward compatible API-wise (at least as far as the test suite
> verifies), but changing the default to CONFIG.SEARCH would probably be
> more convenient for bindings users.

Generally this series looks good to me -- some suspicious newlines I see,
some (if not all) of those might be ok...

>
> [1]: id:87h7d4wp6b@tethera.net
> ---
>  bindings/python-cffi/notmuch2/_build.py| 26 ---
>  bindings/python-cffi/notmuch2/_database.py | 81 --
>  doc/man1/notmuch-config.rst|  2 +
>  test/T055-path-config.sh   |  5 +-
>  test/T391-python-cffi.sh   |  8 ++-
>  5 files changed, 82 insertions(+), 40 deletions(-)
>
> diff --git a/bindings/python-cffi/notmuch2/_build.py 
> b/bindings/python-cffi/notmuch2/_build.py
> index 24df939e..f6184b97 100644
> --- a/bindings/python-cffi/notmuch2/_build.py
> +++ b/bindings/python-cffi/notmuch2/_build.py
> @@ -103,20 +103,18 @@ ffibuilder.cdef(
>  notmuch_status_to_string (notmuch_status_t status);
>  
>  notmuch_status_t
> -notmuch_database_create_verbose (const char *path,
> - notmuch_database_t **database,
> - char **error_message);
> -notmuch_status_t
> -notmuch_database_create (const char *path, notmuch_database_t 
> **database);
> -notmuch_status_t
> -notmuch_database_open_verbose (const char *path,
> -   notmuch_database_mode_t mode,
> -   notmuch_database_t **database,
> -   char **error_message);
> -notmuch_status_t
> -notmuch_database_open (const char *path,
> -   notmuch_database_mode_t mode,
> -   notmuch_database_t **database);
> +notmuch_database_create_with_config (const char *database_path,
> + const char *config_path,
> + const char *profile,
> + notmuch_database_t **database,
> + char **error_message);
> +notmuch_status_t
> +notmuch_database_open_with_config (const char *database_path,
> +   notmuch_database_mode_t mode,
> +   const char *config_path,
> +   const char *profile,
> +   notmuch_database_t **database,
> +   char **error_message);
>  notmuch_status_t
>  notmuch_database_close (notmuch_database_t *database);
>  notmuch_status_t
> diff --git a/bindings/python-cffi/notmuch2/_database.py 
> b/bindings/python-cffi/notmuch2/_database.py
> index c1fb88eb..92bfdef2 100644
> --- a/bindings/python-cffi/notmuch2/_database.py
> +++ b/bindings/python-cffi/notmuch2/_database.py
> @@ -31,6 +31,9 @@ class Mode(enum.Enum):
>  READ_ONLY = capi.lib.NOTMUCH_DATABASE_MODE_READ_ONLY
>  READ_WRITE = capi.lib.NOTMUCH_DATABASE_MODE_READ_WRITE
>  
> +class ConfigFile(enum.Enum):
> +EMPTY = b''
> +SEARCH = capi.ffi.NULL
>  
>  class QuerySortOrder(enum.Enum):
>  OLDEST_FIRST = capi.lib.NOTMUCH_SORT_OLDEST_FIRST
> @@ -71,6 +74,9 @@ class Database(base.NotmuchObject):
>  :cvar EXCLUDE: Which messages to exclude from queries, ``TRUE``,
> ``FLAG``, ``FALSE`` or ``ALL``.  See the query documentation
> for details.
> +:cvar CONFIG: Control loading of config file. Enumeration of
> +   ``EMPTY`` (don't load a config file), and ``SEARCH`` (search as
> +   in :ref:`config_search`)
>  :cvar AddedMessage: A namedtuple ``(msg, dup)`` used by
> :meth:`add` as return value.
>  :cvar STR_MODE_MAP: A map mapping strings to :attr:`MODE` items.
> @@ -81,9 +87,8 @@ class Database(base.NotmuchObject):
> still open.
>  
>  :param path: The directory of where the database is stored.  If
> -   ``None`` the location will be read from the user's
> -   configuration file, respecting the ``NOTMUCH_CONFIG``
> -   environment variable if set.
> +   ``None`` the location will be searched according to
> +   :ref:`database`
>  :type path: str, bytes, os.PathLike or pathlib.Path
>  :param mode: The 

Re: [PATCH] emacs: don't add space to tag completion candidates.

2021-10-31 Thread Tomi Ollila
On Sat, Oct 30 2021, David Bremner wrote:

> "inwit"  writes:
>
>> Works as expected under selectrum! Thanks!
>>
>>
>
> right, I guess the question is how annoying it is for users of standard
> emacs completion. I generally enter one tag at a time, so it won't
> really affect me.

I recall doing adding many tags, but very seldom. I'd guess the need to
press space before entering next is tolerable (basing my guess on my
experiences w/ various experiences w/ filename completion...)


>
> d

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


Re: [RFC PATCH] python-cffi out-of-tree build

2021-10-31 Thread Tomi Ollila
On Sun, Oct 31 2021, David Bremner wrote:

> Tomi Ollila  writes:
>
>> setup.py and _build.py to refer some other files based on directory
>> where setup.py is located (os.path.dirname(sys.argv[0]).
>>
>> Dropped bindings/python-cffi/version.txt and refer ../../version.txt
>> instead -- _build.py already refers ../../lib so why have version.txt
>> twice (with identical content).
>>
>> Dropped copying of bindings/python-cffi source files to the build
>> directory bindings/python-cffi in configure.
>
> Apologies, I think I did not read this discussion very carefully
> before. I guess [1] is an alternative to the first two points. I'm not
> sure which approach is better. Mine is a bigger hammer, but maybe that
> could be useful in the future?
>
> The patch at [1] does not (by itself) allow the third change, but
> probably some similar hacking of setup.py, but using the newly created
> _notmuch_config.py would work.
>
> Tomi, did you happen to test "pip install ." with your approach? I'm
> afraid your patch doesn't (easily) apply anymore so I was too lazy to
> test myself.

IIRC my approaches had quite a few problems which I thought soon after
emailing so probablhy your versions are better. Have to look...

Tomi

>
> Cheers,
>
> db
>
> [1]: id:20211031100354.1697379-1-da...@tethera.net
> ___
> notmuch mailing list -- notmuch@notmuchmail.org
> To unsubscribe send an email to notmuch-le...@notmuchmail.org
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: [PATCH] NEWS: fix typo in 0.34 news.

2021-10-27 Thread Tomi Ollila
On Wed, Oct 27 2021, David Bremner wrote:

> David Bremner  writes:
>
>> Thanks to jrm on IRC for finding the typo.
>
> Applied to release and master.
>
> It (belatedly) occurs to me that it's a bit confusing to that the
> built_with option is sexpr_query, while the man page is
> notmuch-sexp-queries, and the option is --query=sexp
>
> What do people think about changing the built_with option to
> sexp_queries, to more or less match the man page?

I was thinking the same (when modifying wiki a few days ago...).

I'd say yes.

>
> d

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


Re: [PATCH] test/libconfig: use 'export' when restoring NOTMUCH_CONFIG

2021-10-27 Thread Tomi Ollila
On Wed, Oct 27 2021, David Bremner wrote:

> This is required when NOTMUCH_CONFIG has been unset, and is harmless
> otherwise.

LGTM.

Tested w/ the following than the commit message is correct:

(works the same way w/ dash, bash and zsh)

--8<8<8<8<--
export FOO

FOO=1

sh -c 'echo $FOO'

FOO=2

sh -c 'echo $FOO'
--8<8<8<8<--


> ---
>  test/T590-libconfig.sh | 14 +++---
>  1 file changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/test/T590-libconfig.sh b/test/T590-libconfig.sh
> index 59b82a6f..a9566c13 100755
> --- a/test/T590-libconfig.sh
> +++ b/test/T590-libconfig.sh
> @@ -461,7 +461,7 @@ cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR} %NULL% 
> %NULL%
>  }
>  EOF
>  rm -f ${ovconfig}
> -NOTMUCH_CONFIG=${old_NOTMUCH_CONFIG}
> +export NOTMUCH_CONFIG=${old_NOTMUCH_CONFIG}
>  cat <<'EOF' >EXPECTED
>  == stdout ==
>  test.key1 = overridden-home
> @@ -488,7 +488,7 @@ cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR} %NULL% 
> %NULL%
>  }
>  EOF
>  rm -f ${ovconfig}
> -NOTMUCH_CONFIG=${old_NOTMUCH_CONFIG}
> +export NOTMUCH_CONFIG=${old_NOTMUCH_CONFIG}
>  cat <<'EOF' >EXPECTED
>  == stdout ==
>  test.key1 = overridden-xdg
> @@ -515,7 +515,7 @@ cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR} %NULL% 
> work
>  }
>  EOF
>  rm -f ${ovconfig}
> -NOTMUCH_CONFIG=${old_NOTMUCH_CONFIG}
> +export NOTMUCH_CONFIG=${old_NOTMUCH_CONFIG}
>  cat <<'EOF' >EXPECTED
>  == stdout ==
>  test.key1 = overridden-xdg-profile
> @@ -541,7 +541,7 @@ cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR} %NULL% 
> work
>  }
>  EOF
>  #rm -f ${ovconfig}
> -NOTMUCH_CONFIG=${old_NOTMUCH_CONFIG}
> +export NOTMUCH_CONFIG=${old_NOTMUCH_CONFIG}
>  cat <<'EOF' >EXPECTED
>  == stdout ==
>  test.key1 = overridden-profile
> @@ -559,7 +559,7 @@ cat c_head - c_tail <<'EOF' | test_C %NULL% '' %NULL%
> printf("NOT RUN");
>  }
>  EOF
> -NOTMUCH_CONFIG=${old_NOTMUCH_CONFIG}
> +export NOTMUCH_CONFIG=${old_NOTMUCH_CONFIG}
>  cat <<'EOF' >EXPECTED
>  == stdout ==
>  == stderr ==
> @@ -604,7 +604,7 @@ cat c_head - c_tail <<'EOF' | test_C %NULL% '' %NULL%
> printf("test.key2 = %s\n", val);
>  }
>  EOF
> -NOTMUCH_CONFIG=${old_NOTMUCH_CONFIG}
> +export NOTMUCH_CONFIG=${old_NOTMUCH_CONFIG}
>  unset NOTMUCH_DATABASE
>  cat <<'EOF' >EXPECTED
>  == stdout ==
> @@ -783,7 +783,7 @@ cat c_head2 - c_tail <<'EOF' | test_C ${MAIL_DIR} %NULL% 
> %NULL%
>  }
>  EOF
>  rm -f ${ovconfig}
> -NOTMUCH_CONFIG=${old_NOTMUCH_CONFIG}
> +export NOTMUCH_CONFIG=${old_NOTMUCH_CONFIG}
>  cat <<'EOF' >EXPECTED
>  == stdout ==
>  test.key1 = overridden-home
> -- 
> 2.33.0
>
> ___
> notmuch mailing list -- notmuch@notmuchmail.org
> To unsubscribe send an email to notmuch-le...@notmuchmail.org
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: [PATCH 2/2] test/new: replace use of gdb in vanishing file test

2021-10-25 Thread Tomi Ollila
On Sun, Oct 24 2021, David Bremner wrote:

> Because the file to be removed has a predictable name, we can hard
> code it in the generated shim.

I am not sure about the message above -- the file name is as predictable
as it was before -- and the shim code is created dynamically, with same
amout of flexibility as it was w/ the gdb script

Anyway I ignore if the same message appears in style-fixed email
(see below)...

Tomi

> ---
>  test/T050-new.sh| 44 
>  test/notmuch-test.h |  1 +
>  2 files changed, 25 insertions(+), 20 deletions(-)
>
> diff --git a/test/T050-new.sh b/test/T050-new.sh
> index 1141c1e3..5a03998b 100755
> --- a/test/T050-new.sh
> +++ b/test/T050-new.sh
> @@ -368,31 +368,35 @@ chmod u+w ${MAIL_DIR}/.notmuch/xapian/*.*
>  test_expect_equal "$output" "A Xapian exception occurred opening database"
>  
>  
> +make_shim dif-shim< +#include 
> +notmuch_status_t
> +notmuch_database_index_file (notmuch_database_t *database,
> +  const char *filename,
> +  notmuch_indexopts_t *indexopts,
> +  notmuch_message_t **message)
> +{
> +  static notmuch_status_t (*orig_notmuch_database_index_file)
> +(notmuch_database_t *database,
> + const char *filename,
> + notmuch_indexopts_t *indexopts,
> + notmuch_message_t **message) = NULL;
> +  TEST_SAVE_ORIG(notmuch_database_index_file);
> +
> +  if (unlink("${MAIL_DIR}/vanish")) {
> + fprintf(stderr, "unlink failed\n");
> + exit(42);

style not 'exit (42)' like in sources, and in previous change -- mostly
in previous change, there was also at least one fn() use, which I failed
to comment... anyway, asking for consistent style.

> +  }
> +  return orig_notmuch_database_index_file(database, filename, indexopts, 
> message);
> +}
> +EOF
> +
>  test_begin_subtest "Handle files vanishing between scandir and add_file"
>  
>  # A file for scandir to find. It won't get indexed, so can be empty.
>  touch ${MAIL_DIR}/vanish
> -
> -# Breakpoint to remove the file before indexing
> -cat < notmuch-new-vanish.gdb
> -set breakpoint pending on
> -set logging file notmuch-new-vanish-gdb.log
> -set logging on
> -break notmuch_database_index_file
> -commands
> -shell rm -f ${MAIL_DIR}/vanish
> -continue
> -end
> -run
> -EOF
> -
> -${TEST_GDB} --batch-silent --return-child-result -x notmuch-new-vanish.gdb \
> ---args notmuch new 2>OUTPUT 1>/dev/null
> +notmuch_with_shim dif-shim new 2>OUTPUT 1>/dev/null
>  echo "exit status: $?" >> OUTPUT
> -
> -# Clean up the file in case gdb isn't available.
> -rm -f ${MAIL_DIR}/vanish
> -
>  cat < EXPECTED
>  Unexpected error with file ${MAIL_DIR}/vanish
>  add_file: Something went wrong trying to read or write a file
> diff --git a/test/notmuch-test.h b/test/notmuch-test.h
> index 8613a299..94348d69 100644
> --- a/test/notmuch-test.h
> +++ b/test/notmuch-test.h
> @@ -7,6 +7,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  
>  inline static void
>  expect0 (int line, notmuch_status_t ret)
> -- 
> 2.33.0
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: [PATCH 1/2] test/count: replace use of gdb with a LD_PRELOAD shim

2021-10-25 Thread Tomi Ollila
On Sun, Oct 24 2021, David Bremner wrote:

> There is a certain amount of boilerplate to pass the call on the
> original function, so abstract it out as a C preprocessor macro, plus
> some extra includes in notmuch-test.h

Looks like good progress -- some comments...

> ---
>  test/T060-count.sh  | 29 +
>  test/notmuch-test.h | 22 ++
>  2 files changed, 39 insertions(+), 12 deletions(-)
>
> diff --git a/test/T060-count.sh b/test/T060-count.sh
> index 6ad80df9..acf51d88 100755
> --- a/test/T060-count.sh
> +++ b/test/T060-count.sh
> @@ -102,22 +102,27 @@ output=$(sed 's/^\(A Xapian exception [^:]*\):.*$/\1/' 
> OUTPUT)
>  test_expect_equal "${output}" "A Xapian exception occurred opening database"
>  restore_database
>  
> -cat < count-files.gdb
> -set breakpoint pending on
> -set logging file count-files-gdb.log
> -set logging on
> -break count_files
> -commands
> -shell cp /dev/null ${MAIL_DIR}/.notmuch/xapian/postlist.*
> -continue
> -end
> -run
> +make_shim qsm-shim< +#include 
> +notmuch_status_t
> +notmuch_query_search_messages (notmuch_query_t *query, notmuch_messages_t 
> **messages) {
> +  static notmuch_status_t (*orig_notmuch_query_search_messages)
> + (notmuch_query_t *query, notmuch_messages_t **messages) = NULL;
> +  TEST_SAVE_ORIG(notmuch_query_search_messages);

The C preprocessor macro could do both of the lines above, deduplicating
orig_notmuch_query_search_messages and notmuch_query_search_messages to
one, but perhaps this way is clearer...(?)

> +
> +  /* XXX WARNING THIS CORRUPTS THE DATABASE */
> +  int fd = open("target_postlist",O_WRONLY|O_TRUNC);
missing space after ,

> +  if (fd < 0)
> +exit (8);

close(fd) ?

> +
> +  return orig_notmuch_query_search_messages(query, messages);
> +}
>  EOF
>  
>  backup_database
>  test_begin_subtest "error message from query_search_messages"
> -${TEST_GDB} --batch-silent --return-child-result -x count-files.gdb \
> ---args notmuch count --output=files '*' 2>OUTPUT 1>/dev/null
> +ln -s ${MAIL_DIR}/.notmuch/xapian/postlist.* target_postlist
> +notmuch_with_shim qsm-shim count --output=files '*' 2>OUTPUT 1>/dev/null
>  cat < EXPECTED
>  notmuch count: A Xapian exception occurred
>  A Xapian exception occurred performing query
> diff --git a/test/notmuch-test.h b/test/notmuch-test.h
> index 34dbb8e0..8613a299 100644
> --- a/test/notmuch-test.h
> +++ b/test/notmuch-test.h
> @@ -3,6 +3,10 @@
>  #include 
>  #include 
>  #include 
> +#include 
> +#include 
> +#include 
> +#include 
>  
>  inline static void
>  expect0 (int line, notmuch_status_t ret)
> @@ -14,4 +18,22 @@ expect0 (int line, notmuch_status_t ret)
>  }
>  
>  #define EXPECT0(v)  expect0 (__LINE__, v);
> +
> +#define TEST_SAVE_ORIG(func) \
> +  if (! orig_##func) { \
> +void *handle; \
> +char *error; \
> +handle = dlopen("libnotmuch.so", RTLD_LAZY); \

could have void *handle = dlopen... to reduce one macro line

> +if (! handle) { \
> +  fputs(dlerror(), stderr); \
> +  exit(1); \
> +} \
> +orig_##func = dlsym(handle, #func); \
> +if ((error = dlerror()) != NULL) { \
> +  fprintf(stderr, "%s\n", error); \
> +  exit(1); \
> +} \
> +  }
> +
> +
>  #endif
> -- 
> 2.33.0
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: Emacs notmuch extracts text attachments as if they had Windows (CRLF) encoding

2021-10-14 Thread Tomi Ollila
On Wed, Oct 13 2021, Martin Jambor wrote:

> Hi,
>
> I have stumbled upon strange behavior of emacs-notmuch.  When I extract
> (some?) plain text attachments into files using notmuch-show-save-part
> (by pressing ".s"), the file they end up in has Windows encoding of line
> ends (CRLF) even though both the machine used to send and receive the
> email are Linux ones.
>
> I can reproduce the issue with the attached example email.  Emacs
> notmuch extracts the attachment into a windows encoding file while mutt
> or metamail does not.
>
> Can anyone else reproduce this behavior?  Any ideas how to fix it?

Are you talking about this attachment in the gzipped email content:

  ---1609908220-525021627-1633684545=:5930
  Content-Type: text/plain; charset=US-ASCII; name=status
  Content-Transfer-Encoding: BASE64
  Content-Description: test
  Content-Disposition: attachment; filename=status

  U3RhdHVzDQo9PT09PT0NCg0KVGhlIEdDQyBkZXZlbG9wbWVudCBicmFuY2gg
  ...
  NTgzMS5odG1sDQo=

  ---1609908220-525021627-1633684545=:5930--

I manually extracted the BASE64 content, it does have the 
CRLF line endings...

>
> Thanks a lot,
>
> Martin
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: [RFC 2/5] lib: remove enum names from typedefs

2021-10-13 Thread Tomi Ollila
On Wed, Oct 13 2021, David Bremner wrote:

> Jani Nikula  writes:
>
>> Given the named enum typedef:
>>
>> typedef enum _name_t { ... } name_t;
>>
>> Hawkmoth uses _name_t as the name for documentation. Typedef the
>> anonymous enum:
>>
>> typedef enum { ... } name_t;
>>
>> instead to use name_t. We don't really need the enum names for
>> anything, and not all of the enum typedefs have them anyway.
>> ---
> I guess that change would be fine independent of the rest?

I had the same thought.

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


Re: [RFC 1/5] doc: replace doxygen with hawkmoth sphinx extension for api docs

2021-10-13 Thread Tomi Ollila

Interesting stuff...

On Tue, Oct 12 2021, Jani Nikula wrote:

> Hawkmoth is a Sphinx extension for incorporating documentation
> comments from C source to Sphinx. For Notmuch API documentation needs,
> Doxygen is overkill, and Hawkmoth also directly integrates with
> Sphinx.

// stuff deleted //

> +
>  # -- Options for HTML output --
>  
>  # The theme to use for HTML and HTML Help pages.  See the documentation for
> @@ -172,6 +178,13 @@ man_pages = [
>   [notmuch_authors], 1),
>  ]
>  
> +if tags.has('WITH_API_DOCS'):
> +man_pages += [
> +('man3/notmuch', 'notmuch',
> + u'notmuch library',

öld stuff...??? (the u'' i mean) :O

Tomi 


> + [notmuch_authors], 3),
> +]
> +
>  # If true, show URL addresses after external links.
>  #man_show_urls = False
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: [PATCH] configure: whitespace cleanup

2021-10-10 Thread Tomi Ollila
On Sat, Oct 09 2021, David Bremner wrote:

> In order to make it easier to keep the whitespace consistent in the
> configure script, use the same style defined in devel/STYLE for
> C/C++.
>
>   Specifically, a line should begin with zero or more tabs followed
>   by fewer than eight spaces.
>
> Presumably this will be no more difficult for people editing configure
> than for people editing the C and C++ code.

LGTM. 

Tomi


> ---
>  configure | 136 +++---
>  1 file changed, 68 insertions(+), 68 deletions(-)
>
> diff --git a/configure b/configure
> index e2d40d11..6c3a38f1 100755
> --- a/configure
> +++ b/configure
> @@ -496,16 +496,16 @@ int main () {
>  }
>  EOF
>  if ! TEMP_GPG=$(mktemp -d "${TMPDIR:-/tmp}/notmuch.XX"); then
> -printf 'No.\nCould not make tempdir for testing session-key 
> support.\n'
> -errors=$((errors + 1))
> + printf 'No.\nCould not make tempdir for testing session-key support.\n'
> + errors=$((errors + 1))
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: [PATCH v2] devel: script for checking a commit (series)

2021-10-10 Thread Tomi Ollila
On Sun, Oct 10 2021, David Bremner wrote:

> 'check-notmuch-commit' is an updated version of a script I have been
> using (although not always as consistently as I should) before sending
> patches to the list.
>
> Although it requires a bit more tooling, encouraging people to use
> check-notmuch-commit might reduce the number of round trips to the
> list for style nitpicks.
> ---
>  devel/check-notmuch-commit | 32 
>  1 file changed, 32 insertions(+)
>  create mode 100755 devel/check-notmuch-commit
>
> Changes since last round:
>
> ~ '--quick' argument to avoid expensive build/test
> ~ use Tomi's trick to avoid multiple calls to dirname
> ~ merge reindent-lisp into the main script. This eases development
>   (only one script to put in path) and reduces execs.
> ~ include quoting fix for call to emacs  
> ~ add diff-filter option
>
> diff --git a/devel/check-notmuch-commit b/devel/check-notmuch-commit
> new file mode 100755
> index ..99ed229d
> --- /dev/null
> +++ b/devel/check-notmuch-commit
> @@ -0,0 +1,32 @@
> +#!/bin/sh
> +
> +# Usage suggestion:
> +#   git rebase -i --exec devel/check-notmuch-commit origin/master
> +
> +set -e
> +
> +quick=0
> +case "$1" in
> +-q|-Q|--quick)
> +quick=1
> +;;
> +esac
> +
> +if [ $quick = 0 ]; then
> +make test
> +fi
> +
> +unset uconf
> +for file in $(git diff --name-only --diff-filter=AM HEAD^); do
> +case $file in
> + *.c|*.h|*.cc|*.hh)
> +uncrustify --replace -c "${uconf=$(dirname 
> "$0")/uncrustify.cfg}" "$file"

The above line does not have TAB, otherwise looks good to me.

(there might be other tab/spaces inconsistencies, but this was local enough for 
me
to notice ;/)

Tomi

> + ;;
> + *.el)
> + emacs -Q --batch "$file" --eval '(indent-region (point-min) 
> (point-max) nil)' -f save-buffer
> + ;;
> +esac
> +done
> +
> +git diff --quiet
> +
> -- 
> 2.33.0
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: [PATCH] configure: check explicitely for python dev (include) files

2021-10-08 Thread Tomi Ollila
On Thu, Oct 07 2021, David Bremner wrote:

> As discussed at [1] we have received reports that the implicit check
> using cffi.FFI().verify() is not reliable in all environments. Since
> we already use pkg-config, and the python dev package should include a
> .pc file [2], add an extra check using pkg-config.  On at least
> Debian, we have to know which version of python dev files with are
> looking for, so calculate that first.
>
> [1]: id:87im1g35ey.fsf@tethera.netid:87im1g35ey@tethera.net,
> [2]: checked on Debian and Fedora
> ---
>  configure | 16 
>  1 file changed, 16 insertions(+)
>
> diff --git a/configure b/configure
> index 4262d122..fc9512f9 100755
> --- a/configure
> +++ b/configure
> @@ -777,7 +777,23 @@ fi
>  
>  have_python3_cffi=0
>  have_python3_pytest=0

Works and look good (but some style mismatches) -- but move the whole added
block before the 2  variables set abobe to zero -- those does not need to
be defined before the code below is executed and it is more consistent that
way... 

> +have_python3_dev=0
>  if [ $have_python3 -eq 1 ]; then
> +printf "Checking for python3 version ..."
 --- extra space here -^
> +python3_version=$("$python" -c 'import sysconfig; 
> print(sysconfig.get_python_version());')
> +printf "(%s)\n" $python3_version
> +
> +printf "Checking for python $python3_version development files..."
> +if pkg-config --exists "python-$python3_version"; then
> + have_python3_dev=1
> + printf "Yes.\n"
> +else
> + have_python3_dev=0
> +printf "No (will not install CFFI-based python bindings).\n"
--- tabs vs spaces difference above (use only spaces above for local 
consistency) ---
> +fi
> +fi

...i.e. the lines 'have_python3_cffi=0' and 'have_python3_pytest=0' to appear 
here

> +
> +if [ $have_python3_dev -eq 1 ]; then
>  printf "Checking for python3 cffi and setuptools... "
>  if "$python" -c 'import cffi,setuptools; cffi.FFI().verify()' >/dev/null 
> 2>&1; then
>  printf "Yes.\n"
> -- 
> 2.33.0


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


Re: configure checks for python3-notmuch2 module

2021-10-06 Thread Tomi Ollila
On Wed, Oct 06 2021, Tomi Ollila wrote:

>
> So, on Fedora 34, without python3-devel installed
>
> $ python3 -c 'import cffi,setuptools; cffi.FFI().verify()'
> __pycache__/_cffi__xd915627fxd88346ae.c:2:10: fatal error: Python.h: No
> such file or directory
> 2 | #include 
>   |  ^~
> compilation terminated.
>
> (as of now python3-devel-3.9.7-1.fc34 provides 
> /usr/include/python3.9/Python.h)
>
> (debian systems may work differently -- w/ strace the above command
> line did not show any access to Python.h...)


The reason for the above was probably that something was cached; got
exactly the same problem when tried in debian:11 (podman) container 
w/o libpython3-dev (*) -- and after apt-get install libpython3-dev
the above cffi.FFI().verify() worked

Tomi


(*) executed the following on top of docker.io/library/debian:11
and then ./configure in notmuch source dir...

  export DEBIAN_FRONTEND=noninteractive
  apt-get update
  apt-get install -y -q build-essential emacs-nox gdb git man \
  dtach libxapian-dev libgmime-3.0-dev libtalloc-dev \
  python3-sphinx python3-cffi python3-pytest \
  python3-setuptools gpgsm parallel
  apt-get -y autoremove
  apt-get -y clean
  rm -rf /var/lib/apt/lists/

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


Re: configure checks for python3-notmuch2 module

2021-10-06 Thread Tomi Ollila
On Wed, Oct 06 2021, David Bremner wrote:

> Tomi Ollila  writes:
>
>>
>> Have to check how all this behaves on Fedora 34 machine when I 
>> have access to one (currently away from such machines and from
>> power grid also (laptop battery power, which I have to preserve,
>> mobile devices gets charged by small solar panels so no problem
>> there ;D))
>
> Since winter is coming, I hope you are back in civilization :P. Did you
> get a chance to try this?

Yes, come back -- due to climate change outside temperature is not a
problem, just that sun is so low it is hard to get any electricity ;/
-- now I have power and network -- civilization is harder to find...


So, on Fedora 34, without python3-devel installed

$ python3 -c 'import cffi,setuptools; cffi.FFI().verify()'  
__pycache__/_cffi__xd915627fxd88346ae.c:2:10: fatal error: Python.h: No
such file or directory
2 | #include 
  |  ^~
compilation terminated.

(as of now python3-devel-3.9.7-1.fc34 provides /usr/include/python3.9/Python.h)

(debian systems may work differently -- w/ strace the above command
line did not show any access to Python.h...)

>
> cheers,
>
> d

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


Re: [PATCH] test/T355-smime: Use key as exported by gpgsm

2021-09-28 Thread Tomi Ollila
On Mon, Sep 27 2021, David Bremner wrote:

> As reported in id:87h7pxiek3@tethera.net, the previous version of
> the test is flaky. There is some so-far undebugged interaction between
> openssl and gpgsm that causes the keys to fail to import. As a
> potential workaround, use the key as exported by gpgsm, and eliminate
> openssl from this particular pipeline.

The change looks tolerable to me (and your test run sounds convincing) ;D

Tomi

> ---
>  test/smime/0xE0972A47.p12 | 62 +++
>  test/test-lib.sh  |  6 ++--
>  2 files changed, 64 insertions(+), 4 deletions(-)
>  create mode 100644 test/smime/0xE0972A47.p12
>
> diff --git a/test/smime/0xE0972A47.p12 b/test/smime/0xE0972A47.p12
> new file mode 100644
> index ..2c4a6d17
> --- /dev/null
> +++ b/test/smime/0xE0972A47.p12
> @@ -0,0 +1,62 @@
> +Issuer ...: /CN=Notmuch Test Suite
> +Serial ...: 6F748C94BD0C67A9
> +Subject ..: /CN=Notmuch Test Suite
> +aka ..: test_su...@notmuchmail.org
> +Keygrip ..: 1727B9C7108D50333614F3B1DD0807F624B31130
> +
> +-BEGIN PKCS12-
> +MIIJ+AIBAzCCCb4GCSqGSIb3DQEHAaCCCa8EggmrMIIJpzCCBAcGCSqGSIb3DQEH
> +BqCCA/gwggP0AgEAMIID7QYJKoZIhvcNAQcBMBwGCiqGSIb3DQEMAQYwDgQIcfMY
> +MS7tOpcCAggAgIIDwFu7ZRNrXCb0eKei44aeBZPRs9YI/5EpMcFuc8j4/8T1HkIt
> +GuRe/HzRmoiLZcAMOzGC/hF8TkHlNeUZ7rOSpCg4UlBVWJS6avTMHHsakDvTV/7q
> +X5VNi4pLUuyEToGTAPHV+s5P/gYYG6mFPkwG/pDDlAcgMhgtuPY/lQp6IS/E6CaR
> +fhcnQiPq9ySTqO7UNwIyMwtAtSHkgBaje8UbOkQch4lg51i97rm9m4EMvklKtjXc
> +Ud4aTEuoZguPmdBdLvF5QxqJf6Bm9lHa1Awhru2gBWQf9TjX8bwK9Xsv8G6gPOwc
> +LVpIR9fMZtgBbc+heeJTjfn6VqEy881ckbkz+38hiN3pbLMuATM7QAY3u3N4whM6
> +Hmfyl3iqba84Pl93zaUzqazAUeFdqcqSpAUGkS4gU6klr9qi3NicaGbry1DySYU7
> +2h4xy3j7eiHxqdWaibdPoBC8CEbPaFj2qnOVsZykxG6zPvbEB+5sJ/a+T6xm1Btx
> +N6vXR7ObbXlpC4pRkS32ehuRbY6wc6H2KKepOMCu7x10tN0Up5ccNxvkT26QIrEE
> +LW296ijCLbsRhWymDtopWAZHcXXIu0fJ4tocSp2c3lojSEYu1jlMXR+Pa4R8EtgZ
> +lb5+NqISxjUlMMWzGDyhrp9ImcsZmpv6N8zPcZVyU+M1/h+p9ur/IOVZU9P1vIKy
> +kcM4pslr0JhLfnZCLZ+3Ux1yKAcndGZFPb1vZ83jyZKR38BVSGu53ODaBJBqSMHu
> +Mv2Na/qzvQBSVJuWF9cAhiVd7v9R/EvT0zmljN4w7l4EXsB5wRsO1wvlL+MhwaET
> +dIHbRH2GD3gERX6oTc3t3cgritVePk70rCxQDxn5zUbjW7dNIlIobAumLHBfgSxR
> +QCE6gxdTm5MW2O9hnfTSQvliVaGU1gd0M3BRiqeNpPPxnloGKnOEODM381F4HxyR
> +CzO2r/2aKJP+U5HxSf4cljp3/Lripxykzfqc9/xZshl+jGixsSSm+Ul916Hpj2Rt
> +j9vHg4H9YfJTGdvzxZcvZCvNSy3ygtjx0++SrI5hGHKjpVJIK2/9Wi39q5s6LkiA
> +RCjvuoBBcQXm++69X7QGWSsGFtwerCGnq3nAxGpHVKVGTvFYMAg6y1RR0zvE0SuM
> +MZegD8w45QyrmiPqSRM7/RtqVdA+r/wiJwWerUBq+mrCvJHB2NRcjiUiCJY1bjRU
> +ATMfB0uZaNInUXiLDGxp2mdBgdFVq7sYTbq+OvprzxeAjIvodxl3J9ThvJnt1fzK
> +RPCJw5COI60ibE3XTTCCBZgGCSqGSIb3DQEHAaCCBYkEggWFMIIFgTCCBX0GCyqG
> +SIb3DQEMCgECoIIE7jCCBOowHAYKKoZIhvcNAQwBAzAOBAiEe8CcxIIv9wICCAAE
> +ggTIujut93lYPUsKc/JNhZhUWS/RHHog6d8ZAjpFvXpyD8Z2z4A4PpgIn8eUSRW5
> +Gwp8izR+16Tj3ht52pJ5Y1x27/S3l3sDlekEZ/33X/AdLFWAXbcibmwtRea1ucKZ
> +ze3DJM7CvuRvVSBG8XubPGi3pZkEjHBGQqgtsTnxlBp0PXl7wxfyT7F6gOH2DGYP
> +bYzNa2fnY8twEcUYhuksI/eh9Zwj9TrF0HWq1hwp0tDCfqutzshSX2GQ/p0raL3B
> +C2stHBjl0OVUfDHpqQ5OJWbQvGcJntECqu4gmSJohunObaUKcN8xs+FzB5czpmsT
> +W/pyR58nc8QhTttByqZN3EerhEogWDZj4tQ6dK8p6bqLO/0qqBehZGchfof5Evwj
> +VFsvVGD8xVLQWWAFnrQs5+U56NQEbmZzN5RCI7FEK2VVOeG03dpXyoAQyxuYrsYU
> +3znmoSleIqDDBFD21YePUcJZ0R8AQsvgV11tdwPWqr1hk0bIazLQ9rappGrTgkK8
> +DFdQKSH1dRvjqtbuDyY7j5PXXJTXthVv9T9N7Vp6qU+pWBQ1Mz30J+fHX2ilEnbi
> +tQ49hwt1+/2Zkmwz3reoEnxYOKzCg/ySIpQ27/Hx4xZ+ecEzX/0IxCkHeAV3V3bB
> +1z8wFxWEh1s9hL6C8lRk/wQ9KsKaxM7BdLw7RjiqEwR4HgeCqMPdCVQQpILARDC8
> +Poz8xUmjv7HyIvvyBUP12YdIj74Jjj0Mm2r/FDj7nsXxkjXMZEMMKK3oVaAMq8Bd
> +cO4VQXDd7bgNzLF9PKxWNjoCuQcPJXwMPqlFoc06BLPstEaR4enafv0Pd4l0pyME
> +YgezyVW+3yFEsbbB2UUs0r7oqxsDFU9/iHf8O3nu3NuKTJkux4uMlOTBKsm6sY7k
> +GduP2UA+WU27jHrf4zQQbkDLG1lJFfcaKzlcOmz5B9iZwugBz9Y28w5f2/12Kqrh
> +4tibFBUG0E85KAb1wnFUNUx06OMX229U1M0E1LHbcUJ9mcRipONPVn0FRi8XzaLK
> +023XRoihuoWhVUiB1OJ2eZW1JnUYRztfa3nfmGjXv4VGkxYlnTkE9z0PAAhf6t5A
> +7Ir0y1JUeOlBITTcojOp6qQ8tMQQ5wRk1oncHiw3WwJvFN6fOa9Q/+4ZmULHz0vV
> +Xl+Qio8B7/4jqZoT4e/gK6U/zHriznLzqp63LjP47eFRXTfuXslaCt7YF75Mq2J6
> +VPA+qfYRw0K5BvDUkr8c+nLP2AiDaEYVBHGdBRTlWO9UkcB1F4cuZZiU5MZbxVrb
> +Db+zGWW6AT+4XTO4z9KmAqgTTv1+BQrLxNI+RG8JfQapUKQyB794F4kXK2yhd1P3
> +XS9cwh24COiqbOpI1nB5qn7cn4RRHW156LWGF+VJFdxR6Wu3vZx/kZGevG9o1ARF
> +z1l9mbGyhwnUJO1EQwjbppvRou1bZuNbuRgLmHKEVPAv+J+7hLXZAnRdwoV0x91t
> +bpmy4qyxA/90DHguIhRVcKsYBrdShY7LXdZArECBhMY9R41D6v1yyhC6fL6PKR5g
> +DaluN2K9TBALzZH7NnNdE14l+56+kLc9Fq8JXsq3rxdeBTsNl09fHPf9w5VLkq4I
> +doNcPPlta0Q0xJNa/RYENCJpAMZdMFIJ558uMXwwVQYJKoZIhvcNAQkUMUgeRgBH
> +AG4AdQBQAEcAIABlAHgAcABvAHIAdABlAGQAIABjAGUAcgB0AGkAZgBpAGMAYQB0
> +AGUAIABlADAAOQA3ADIAYQA0ADcwIwYJKoZIhvcNAQkVMRYEFGFvRs1zg0xjhHdW
> +rw37ZKbglypHMDEwITAJBgUrDgMCGgUABBSluQBa+tVpYVYmB/zAZuPE9NnargQI
> +XWSQTDEONWgCAggA
> +-END PKCS12-
> diff --git a/test/test-lib.sh b/test/test-lib.sh
> index dc4962f5..32f710a5 100644
> --- a/test/test-lib.sh
> +++ b/test/test-lib.sh
> @@ -143,10 +143,8 @@ add_gpgsm_home () {
>  _gnupg_exit () { gpgconf --kill all 2>/dev/null || true; }
>  

Re: performance in emacs displaying a huge thread

2021-09-22 Thread Tomi Ollila
On Wed, Sep 22 2021, Alan Schmitt wrote:

> On 2021-09-21 21:27, Tomi Ollila  writes:
>
>> I'd be interested to know if changing max-lisp-eval-depth to a larger value
>> made difference.
>> 
>> e.g (set max-lisp-eval-depth 1600)
>
> Thank you for the suggestion. I tried with 1600, and I get a different
> error (and the numbers are larger now).
>
> Debugger entered--Lisp error: (error "Variable binding depth exceeds
> max-specpdl-size")

Now it failed due to exceeding max-specpdl-size (which seems to be 1600
by default)

W/o knowing better I'd try (setq max-specpdl-size 3200) now...

(further tries could be enlarging the values discussed 10-fold...)

Tomi

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


Re: performance in emacs displaying a huge thread

2021-09-21 Thread Tomi Ollila
On Tue, Sep 21 2021, Alan Schmitt wrote:

> On 2021-09-21 09:42, David Bremner  writes:
>
>> That's not completely unexpected. The change in question only really fixes 
>> it for
>> unthreaded view. Try notmuch-unthreaded-from-search-current-query (bound
>> to 'U' by default).
>
> Thank you for bearing with me. I confirm that I can see messages at the
> beginning of the thread using both an unthreaded search and
> notmuch-show-only-matching-messages set to t. Unfortunately, messages
> later in the thread still result in an error:
>
> Debugger entered--Lisp error: (error "Lisp nesting exceeds
> ‘max-lisp-eval-depth’")

I'd be interested to know if changing max-lisp-eval-depth to a larger value
made difference.

--8<8<8<8<8<8<8<8<8<8<8<8<---
  max-lisp-eval-depth is a variable defined in ‘C source code’.
  Its value is 800

This variable may be risky if used as a file-local variable.

  Documentation:
  Limit on depth in ‘eval’, ‘apply’ and ‘funcall’ before error.

  This limit serves to catch infinite recursions for you before they cause
  actual stack overflow in C, which would be fatal for Emacs.
  You can safely make it considerably larger than its default value,
  if that proves inconveniently small.  However, if you increase it too far,
  Emacs could overflow the real C stack, and crash.
--8<8<8<8<8<8<8<8<8<8<8<8<---

e.g (set max-lisp-eval-depth 1600)

(more interesting thing is what causes such a deep recursion...)

Tomi


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


Re: Cannot Start Notmuch (invalid-read-syntax "#")

2021-09-13 Thread Tomi Ollila
On Mon, Sep 13 2021, Charles-André Roy wrote:

> Hello David,
>
> I have removed and purged the notmuch-emacs package.
>
> elpa-notmuch/stable,now 0.31.4-2 was already installed.
>
> On the notmuchmail.org Web site, I looked at the pages "Notmuch Emacs
> Interface" and "Tips and Tricks".  The only configuration file mentioned
> on these pages is ~/.emacs.d/notmuch-config.el
>
> And I agree with you that the backtrace reports a Lisp reading error. I
> created an empty ~/.emacs.d/notmuch-config.el, tried to start Notmuch
> and it WORKED.  I could see the beautiful notmuch-hello screen again.
>
> I wanted to make sure it was a steady fix.  I closed all my opened Emacs
> and started them again.  On the first try I got the same *Backtrace*.
> On the second try it worked.  So the fix does not seem too stable.
>
> In one session, does Notmuch en Emacs first try to look at the file in
> ~/.  On another try, does it skip that step and go directly to the
> programme ?  That would also explain why some time ago a small
> change in the file made a difference.  The change in the file would not have 
> made the difference but
> the second try would.  I wonder ?
>
> I am wondering also how come I did not have a the
> ~/.emacs.d/notmuch-config.el Notmuch is trying to read.
>
> In trying to solve the problem I deleted the ~/.notmuch-config file.
> Notmuch produced the message that it was not setup.  I did the command
> "notmuch setup" in a terminal.  It created again the config file that
> starts with the character # and placed it in ~/.
>
> C-h a did not show any setup command inside Emacs, how is the
> notmuch-config.el file created and what goes in it ?  Is it what I put
> about Notmuch in my .emacs file ?


The notmuch-config.el file is created by user; if it exists, notmuch emacs
mua loads it.

The following defines it (no notmuch.el)

(defcustom notmuch-init-file (locate-user-emacs-file "notmuch-config")
 ...)

In this case (locate-user-emacs-file new-file) tries to look notmuch-config
files in user-emacs-directory (being ~/.emacs.d by default).

As an example: when I tried: (locate-user-emacs-file ".zshrc") emacs
printed "~/.emacs.d/.zshrc".

... anyway, whatever the user-emacs-directory is defined the combination
of it and "notmuch-config" cannot resolve to ~/.notmuch-config...

(I tried:
   (setq user-emacs-directory ".")
   (locate-user-emacs-file "zshrc")
 output was "~/zshrc"  -- no . there)


At the end of notmuch.el notmuch-config.el is attempted to be read with

(when init-file-user ; don't load init file if the -q option was used.
  (load notmuch-init-file t t nil t))

load defined as:
  (load FILE  NOERROR NOMESSAGE NOSUFFIX MUST-SUFFIX)

which, if I understand(*) correctly, wants the .el or .elc suffix

(*) and understood correctly, 2014-03-29 when I added this feature


The purpose of notmuch-config.el is to put notmuch emacs configuration
so that only those instances of emacs that load notmuch will configure.
Also, notmuch-config.el is loaded *after* notmuch is loaded (so one
can e.g. overwrite functions (which I have done...)).


Tomi


>
> Thank you !
>
>
> Charles
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: [PATCH] lib: use 'localhost' rather than fqdn for default mail address.

2021-09-09 Thread Tomi Ollila
On Thu, Sep 09 2021, David Bremner wrote:

> As discussed in the thread starting at [1], the fully qualified domain
> name is a bit tricky to get reproducibly, might reveal information
> people prefer to keep private, and somewhat unlikely to provide
> reliable mail routing.
>
> The new approach of $current_username@localhost is better for the
> first two considerations, and probably at least as good as a test mail
> address.
>
> [1]: id:87sfyibqhj@tethera.net
> ---
>  lib/config.cc  | 17 ++---
>  test/T590-libconfig.sh | 10 --
>  2 files changed, 6 insertions(+), 21 deletions(-)
>
> diff --git a/lib/config.cc b/lib/config.cc
> index 7ecc3c7b..408570bc 100644
> --- a/lib/config.cc
> +++ b/lib/config.cc
> @@ -543,25 +543,12 @@ _get_username_from_passwd_file (void *ctx)
>  static const char *
>  _get_email_from_passwd_file (void *ctx)
>  {
> -
> -char hostname[256];
> -struct hostent *hostent;
> -const char *domainname;
>  char *email;
>  
>  char *username = _get_username_from_passwd_file (ctx);
>  
> -gethostname (hostname, 256);
> -hostname[255] = '\0';
> -
> -hostent = gethostbyname (hostname);
> -if (hostent && (domainname = strchr (hostent->h_name, '.')))
> - domainname += 1;
> -else
> - domainname = "(none)";
> -
> -email = talloc_asprintf (ctx, "%s@%s.%s",
> -  username, hostname, domainname);
> +email = talloc_asprintf (ctx, "%s@localhost",
> +  username);

perhaps the above 2 lines as one:

> +email = talloc_asprintf (ctx, "%s@localhost", username);

LGTM in any way.

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


Re: Is default email address in notmuch setup / lib useful?

2021-09-07 Thread Tomi Ollila
On Mon, Sep 06 2021, David Bremner wrote:

> Tomi Ollila  writes:
>
>>
>> Agreed. I tried to look whether we could get rid of user.name and
>> user.primary_email config values (and then emacs/other email clients
>> would need to resolve that information elsewhere). I don't know if
>> that can ever be done (or should), but the the current beaviour
>> is flaky (and I agree potentially insecure).
>
> Would that involve getting rid of notmuch-reply, or something else?

I did not think/remember that. Are there any users (am I a user >;D) ?

Anyway, localhost ftw (for now)

>
> d

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


[PATCH] NEWS: typo fix; some trailing periods

2021-09-06 Thread Tomi Ollila
The trailing periods to smaller diff between devel/news2wiki.pl
output and what has been pushed to notmuch-wiki.
---
 NEWS | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/NEWS b/NEWS
index 2ce632f0..c6a372e7 100644
--- a/NEWS
+++ b/NEWS
@@ -4,7 +4,7 @@ Notmuch 0.33 (2021-09-03)
 Library
 ---
 
-Correct documentatation about transactions.
+Correct documentation about transactions.
 
 Add a configurable automatic commit of transactions. See
 `database.autocommit` in notmuch-config(1).
@@ -173,7 +173,7 @@ notmuch_database_remove_message or notmuch_message_delete 
in one
 session has been fixed.
 
 As always, the canonical source of API documentation is
-`lib/notmuch.h`, or the doxygen formatted documentation in `notmuch(3)`
+`lib/notmuch.h`, or the doxygen formatted documentation in `notmuch(3)`.
 
 CLI
 ---
@@ -239,12 +239,12 @@ Fix for exclude tags in notmuch2 bindings.
 Build
 -
 
-Portability update for T360-symbol-hiding
+Portability update for T360-symbol-hiding.
 
 Library
 ---
 
-Fix for memory error in notmuch_database_get_config_list
+Fix for memory error in notmuch_database_get_config_list.
 
 Notmuch 0.31.2 (2020-11-08)
 ===
@@ -459,7 +459,7 @@ Command Line Interface
 --
 
 `notmuch show` now supports --body=false and --include-html with
---format=text
+--format=text.
 
 Fix several performance problems with `notmuch reindex`.
 
-- 
2.25.1

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


Re: Is default email address in notmuch setup / lib useful?

2021-09-06 Thread Tomi Ollila
On Mon, Sep 06 2021, Alexander Adolf wrote:

> David Bremner  writes:
>
>> Currently notmuch tries to make a guess for a default email address
>> based on the "fully qualified hostname" of the host it is running
>> on. This is roughly equivalent to running "hostname -f". I have observed
>> two things
>> [...]
>> If people agree it's generally not useful, I'd propose to replace it
>> with some simpler default like "localhost" [1], equally useful to for
>> testing, but simpler to implement and test.
>> [...]
>
> I'd support David's suggestion to just default it to "localhost".
>
> If an unsuspecting user tries to send their first email with notmuch,
> the current behaviour could reveal information about the user's local
> infrastructure in the message. "localhost" is a much safer default, IMO.

Agreed. I tried to look whether we could get rid of user.name and
user.primary_email config values (and then emacs/other email clients
would need to resolve that information elsewhere). I don't know if
that can ever be done (or should), but the the current beaviour
is flaky (and I agree potentially insecure).


>
>   --alex

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


Re: [PATCH] CLI: define and use format version 5

2021-08-22 Thread Tomi Ollila
On Sat, Aug 21 2021, David Bremner wrote:

> This is a bit of a cheat, since the format does not actually
> change. On the other hand it is fairly common to do something like
> this to shared libary SONAMEs when the ABI changes in some subtle way.
> It does rely on the format-version argument being early enough on the
> command line to generate a sensible error message.

looks 0.33 to me.

Tomi


> ---
>  devel/schemata   | 6 +-
>  emacs/notmuch-address.el | 2 +-
>  emacs/notmuch-mua.el | 2 +-
>  emacs/notmuch-query.el   | 2 +-
>  emacs/notmuch-tree.el| 2 +-
>  emacs/notmuch.el | 2 +-
>  notmuch-client.h | 2 +-
>  test/T310-emacs.sh   | 2 +-
>  test/T450-emacs-show.sh  | 2 +-
>  9 files changed, 13 insertions(+), 9 deletions(-)
>
> diff --git a/devel/schemata b/devel/schemata
> index ae84a528..01e3a3df 100644
> --- a/devel/schemata
> +++ b/devel/schemata
> @@ -14,7 +14,7 @@ are interleaved. Keys are printed as keywords (symbols 
> preceded by a
>  colon), e.g. (:id "123" :time 54321 :from "foobar"). Null is printed as
>  nil, true as t and false as nil.
>  
> -This is version 4 of the structured output format.
> +This is version 5 of the structured output format.
>  
>  Version history
>  ---
> @@ -36,6 +36,10 @@ v4
>  - (notmuch 0.29) added message.crypto to identify overall message
>cryptographic state
>  
> +v5
> +- sorting support for notmuch show (no change to actual schema,
> +  just new command line argument)
> +
>  Common non-terminals
>  
>  
> diff --git a/emacs/notmuch-address.el b/emacs/notmuch-address.el
> index f0af6667..9fc13bc5 100644
> --- a/emacs/notmuch-address.el
> +++ b/emacs/notmuch-address.el
> @@ -308,7 +308,7 @@ execution, CALLBACK is called when harvesting finishes."
>   (and config-query
>(format " and (%s)" config-query)))
> from-or-to-me-query))
> -  (args `("address" "--format=sexp" "--format-version=4"
> +  (args `("address" "--format=sexp" "--format-version=5"
>,(if sent "--output=recipients" "--output=sender")
>"--deduplicate=address"
>,query)))
> diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el
> index 17954fb3..f510c043 100644
> --- a/emacs/notmuch-mua.el
> +++ b/emacs/notmuch-mua.el
> @@ -235,7 +235,7 @@ Typically this is added to `notmuch-mua-send-hook'."
>  ;;; Mua reply
>  
>  (defun notmuch-mua-reply (query-string  sender reply-all)
> -  (let ((args '("reply" "--format=sexp" "--format-version=4"))
> +  (let ((args '("reply" "--format=sexp" "--format-version=5"))
>   (process-crypto notmuch-show-process-crypto)
>   reply
>   original)
> diff --git a/emacs/notmuch-query.el b/emacs/notmuch-query.el
> index d7349b77..5c7f4f8d 100644
> --- a/emacs/notmuch-query.el
> +++ b/emacs/notmuch-query.el
> @@ -31,7 +31,7 @@
>  A thread is a forest or list of trees. A tree is a two element
>  list where the first element is a message, and the second element
>  is a possibly empty forest of replies."
> -  (let ((args '("show" "--format=sexp" "--format-version=4")))
> +  (let ((args '("show" "--format=sexp" "--format-version=5")))
>  (when notmuch-show-process-crypto
>(setq args (append args '("--decrypt=true"
>  (setq args (append args search-terms))
> diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el
> index ef1ca4c5..ec803294 100644
> --- a/emacs/notmuch-tree.el
> +++ b/emacs/notmuch-tree.el
> @@ -1101,7 +1101,7 @@ the same as for the function notmuch-tree."
>  (notmuch-tag-clear-cache)
>  (let ((proc (notmuch-start-notmuch
>"notmuch-tree" (current-buffer) #'notmuch-tree-process-sentinel
> -  "show" "--body=false" "--format=sexp" "--format-version=4"
> +  "show" "--body=false" "--format=sexp" "--format-version=5"
>sort-arg message-arg search-args))
> ;; Use a scratch buffer to accumulate partial output.
> ;; This buffer will be killed by the sentinel, which
> diff --git a/emacs/notmuch.el b/emacs/notmuch.el
> index 351334aa..739cb93b 100644
> --- a/emacs/notmuch.el
> +++ b/emacs/notmuch.el
> @@ -1020,7 +1020,7 @@ the configured default sort order."
>(save-excursion
>   (let ((proc (notmuch-start-notmuch
>"notmuch-search" buffer #'notmuch-search-process-sentinel
> -  "search" "--format=sexp" "--format-version=4"
> +  "search" "--format=sexp" "--format-version=5"
>(if oldest-first
>"--sort=oldest-first"
>  "--sort=newest-first")
> diff --git a/notmuch-client.h b/notmuch-client.h
> index 8227fea4..8643a63f 100644
> --- a/notmuch-client.h
> +++ b/notmuch-client.h
> @@ -137,7 +137,7 @@ chomp_newline (char *str)
>   * this.  New (required) map fields can be added without increasing
>   * this.
>   */
> -#define NOTMUCH_FORMAT_CUR 4
> 

Re: [PATCH 1/3] emacs/rstdoc: escape '*'

2021-08-22 Thread Tomi Ollila


series LGTM.

Tomi

On Sat, Aug 21 2021, David Bremner wrote:

> This is just a regular character in docstrings (as it is fairly often
> used in lisp identifiers and buffer names) but is the start of
> emphasis in rst. This change is needed to quell a noisy warning when
> including notmuch-tree.rsti
> ---
>  emacs/rstdoc.el | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/emacs/rstdoc.el b/emacs/rstdoc.el
> index c7c13015..5b8a9d01 100644
> --- a/emacs/rstdoc.el
> +++ b/emacs/rstdoc.el
> @@ -71,6 +71,7 @@
>   ("`" . "`")
>   ("\001" . "'")
>   ("\002" . "`")
> + ("[*]" . "*")
>   ("^[[:space:]]*$" . "|br|")
>   ("^[[:space:]]" . "|indent| "))
>  "list of (regex . replacement) pairs")
> -- 
> 2.32.0
> ___
> notmuch mailing list -- notmuch@notmuchmail.org
> To unsubscribe send an email to notmuch-le...@notmuchmail.org
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: [PATCH 4/7] test/path-config: use test_expect_equal_file_nonempty

2021-08-21 Thread Tomi Ollila
On Wed, Aug 04 2021, David Bremner wrote:

> This is more robust against crashes when the expected output is also
> generated by notmuch. In the case where the expected output is
> explicit, it seems like overkill.

1,2,3 and 4 in this series look good to me

Tomi (on mobile device)



> ---
>  test/T055-path-config.sh | 11 +--
>  1 file changed, 5 insertions(+), 6 deletions(-)
>
> diff --git a/test/T055-path-config.sh b/test/T055-path-config.sh
> index bb3bf665..8271579f 100755
> --- a/test/T055-path-config.sh
> +++ b/test/T055-path-config.sh
> @@ -141,13 +141,13 @@ EOF
>  notmuch tag -inbox '*'
>  notmuch restore < EXPECTED
>  notmuch dump > OUTPUT
> -test_expect_equal_file EXPECTED OUTPUT
> +test_expect_equal_file_nonempty EXPECTED OUTPUT
>  
>  test_begin_subtest "reindex ($config)"
>  notmuch search --output=messages '*' > EXPECTED
>  notmuch reindex '*'
>  notmuch search --output=messages '*' > OUTPUT
> -test_expect_equal_file EXPECTED OUTPUT
> +test_expect_equal_file_nonempty EXPECTED OUTPUT
>  
>  test_begin_subtest "use existing database ($config)"
>  output=$(notmuch new)
> @@ -169,7 +169,7 @@ EOF
>  test_begin_subtest "Show a raw message ($config)"
>  add_message
>  notmuch show --format=raw id:$gen_msg_id > OUTPUT
> -test_expect_equal_file $gen_msg_filename OUTPUT
> +test_expect_equal_file_nonempty $gen_msg_filename OUTPUT
>  rm -f $gen_msg_filename
>  
>  test_begin_subtest "reply ($config)"
> @@ -198,14 +198,13 @@ EOF
>  mkdir -p "$MAIL_DIR"/{cur,new,tmp}
>  notmuch insert < "$gen_msg_filename"
>  cur_msg_filename=$(notmuch search --output=files 
> "subject:insert-subject")
> -test_expect_equal_file "$cur_msg_filename" "$gen_msg_filename"
> -
> +test_expect_equal_file_nonempty "$cur_msg_filename" "$gen_msg_filename"
>  
>  test_begin_subtest "compact+search ($config)"
>  notmuch search --output=messages '*' | sort > EXPECTED
>  notmuch compact
>  notmuch search --output=messages '*' | sort > OUTPUT
> -test_expect_equal_file EXPECTED OUTPUT
> +test_expect_equal_file_nonempty EXPECTED OUTPUT
>  
>  test_begin_subtest "upgrade backup ($config)"
>  features=$(xapian-metadata get $XAPIAN_PATH features | grep -v 
> "^relative directory paths")
> -- 
> 2.30.2
> ___
> notmuch mailing list -- notmuch@notmuchmail.org
> To unsubscribe send an email to notmuch-le...@notmuchmail.org
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: [PATCH] emacs: honour notmuch-show-text/html-blocked-images in w3m messages

2021-08-19 Thread Tomi Ollila
On Tue, Aug 17 2021, David Edmondson wrote:

> On Tuesday, 2021-08-17 at 09:07:53 -07, Jonathan Wilner wrote:
>
>> Apologies in advance for thread-jacking this patch !
>>
>> No matter what I try to do, I can't configure notmuch/emacs to show
>> any inline images. That's using any of the renderer options, from shr
>> to the various w3ms, other than html2text. I've set every possible
>> variable to allow things, to no avail.
>>
>> Using w3m under Emacs on the same machine pulls in local and network images 
>> fine.
>>
>> Does anyone either have this working as the default or even using a
>> toggle ("T") to enable images one message at time?
>
> I use (with shr):
>
> (defun dme:notmuch-show-refresh-show-images ()
>   "Refresh the current buffer with external images enabled."
>   (interactive)
>   (make-local-variable 'notmuch-show-text/html-blocked-images)
>   (setq notmuch-show-text/html-blocked-images nil)

How does let-bind differ with the above ?

>   (notmuch-show-refresh-view))
> (define-key notmuch-show-mode-map "I" 'dme:notmuch-show-refresh-show-images)
>

Tomi

>>
>> Thanks in advance,
>>
>> Jonathan
>>
>> David Bremner  writes:
>>
>>> jao  writes:
>>>
 When mm-text-html-renderer is set to 'w3m, the variable playing the
 role of a regular expression for blocked images is
 w3m-ignored-image-url-regexp.  We bind it when the renderer is not
 'shr.
 ---
>>> applied to master
>>> ___
>>> notmuch mailing list -- notmuch@notmuchmail.org
>>> To unsubscribe send an email to notmuch-le...@notmuchmail.org
>> ___
>> notmuch mailing list -- notmuch@notmuchmail.org
>> To unsubscribe send an email to notmuch-le...@notmuchmail.org
> ___
> notmuch mailing list -- notmuch@notmuchmail.org
> To unsubscribe send an email to notmuch-le...@notmuchmail.org
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: dealing with a lot of emails in single dir

2021-08-17 Thread Tomi Ollila
On Tue, Aug 17 2021, Aurélien Aptel wrote:

> Hi,
>
> How do you deal with a maildir with a billion file in it? I'm on ext4
> which should handle it but I can already feel some programs struggle
> with a dir with that many entries (noticeable slow down).

That reminded me:

http://be-n.com/spw/you-can-list-a-million-files-in-a-directory-but-not-with-ls.html

that talks about 8 million files in a dir and already that requires special
attention (i.e. readdir(3) slow, have to use getdents(2) syscall directly...

>
> I was thinking of archiving emails in yearly folders. How does notmuch
> deal with moving emails around? Will I still be able to open them or
> should I recreate the db?

cannot remember how how notmuch detect renames -- so before doing so you
should backup tags with notmuch-dump...

Tomi
 

>
> If anyone is using lieer with gmail (https://github.com/gauteh/lieer)
> will this trigger pulls of all the moved emails again?
>
> Thanks
> ___
> notmuch mailing list -- notmuch@notmuchmail.org
> To unsubscribe send an email to notmuch-le...@notmuchmail.org
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[RFC WIP PATCH] test: use GNU make instead of parallel(1) to run tests in parallel

2021-08-17 Thread Tomi Ollila
quick try -- more to follow if there is interest :D

moreutils parallel and gnu parallel are fine tools, but if tests
can be run in parallel with gnu make (which is required anyway)
those are not needed to be installed -- not in linux nor in any
other system where such tools may be harder to install...

current version:
make test   - use nproc(1) to choose how many in pa
NOTMUCH_TEST_PARALLEL= make test- don't run tests in parallel
NOTMUCH_TEST_PARALLEL=1 make test   - like above, but uses make in between
NOTMUCH_TEST_PARALLEL=99 make test  - run 99 (all, as we have 90+) in paral

(the latests did execute OK in 10 year old laptop with 4 gig of memory)

todo:
 - how to choose gnu make on non-linux systems (gmake, $MAKE ...?)
 - whether to use -O (output-sync -- and how new make needed for that)
 - check decisions made in this...
 - unverbose test run (from make execution instead of @env... in makefile)
 - whether to have user-env-defined NOTMUCH_TEST_PARALLEL or something else
---
 test/notmuch-test | 23 ---
 test/parallel.mk  | 13 +
 2 files changed, 25 insertions(+), 11 deletions(-)
 create mode 100644 test/parallel.mk

diff --git a/test/notmuch-test b/test/notmuch-test
index 14747bdb..f8ab676a 100755
--- a/test/notmuch-test
+++ b/test/notmuch-test
@@ -46,21 +46,22 @@ else
 TEST_TIMEOUT_CMD=""
 fi
 
+# if NOTMUCH_TEST_PARALLEL is unset, set it to the number of cores
+# if NOTMUCH_TEST_PARALLEL is set but empty, don't run tests in parallel
+# user can set NOTMUCH_TEST_PARALLEL to a numeric value...
+: ${NOTMUCH_TEST_PARALLEL=`exec nproc`} || : # nproc may not be available in 
all systems...
+
 META_FAILURE=
 RES=0
 # Run the tests
-if test -z "${NOTMUCH_TEST_SERIALIZE-}" && command -v parallel >/dev/null ; 
then
-test -t 1 && export COLORS_WITHOUT_TTY=t || :
-if parallel --minversion 0 >/dev/null 2>&1 ; then
-echo "INFO: running tests with GNU parallel"
-printf '%s\n' $TESTS | $TEST_TIMEOUT_CMD parallel || RES=$?
-else
-echo "INFO: running tests with moreutils parallel"
-$TEST_TIMEOUT_CMD parallel -- $TESTS || RES=$?
-fi
-if [ $RES != 0 ]; then
+if test "$NOTMUCH_TEST_PARALLEL"; then
+test -t 1 && export COLORS_WITHOUT_TTY=t
+echo "INFO: running tests parallel, $NOTMUCH_TEST_PARALLEL tests..."
+make -k -f $NOTMUCH_SRCDIR/test/parallel.mk -j $NOTMUCH_TEST_PARALLEL \
+TIMEOUT_CMD="$TEST_TIMEOUT_CMD" $TESTS || {
+RES=$?
 META_FAILURE="parallel test suite returned error code $RES"
-fi
+}
 else
 trap 'e=$?; trap - 0; kill ${!-}; exit $e' 0 HUP INT TERM
 for test in $TESTS; do
diff --git a/test/parallel.mk b/test/parallel.mk
new file mode 100644
index ..4002f499
--- /dev/null
+++ b/test/parallel.mk
@@ -0,0 +1,13 @@
+#
+# named as parallel.mk to show what is the purpose, as
+# the contents of this makefile looks more generic
+#
+
+TIMEOUT_CMD := # could not figure out good generic name for this
+
+.PHONY: $(MAKECMDGOALS)
+$(MAKECMDGOALS):
+   env -u MAKEFLAGS $(TIMEOUT_CMD) $@
+
+.SUFFIXES:
+MAKEFLAGS += --no-builtin-rules --warn-undefined-variables
-- 
2.31.1

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


Re: BUG: Backward compatibility breakage by --sort argument

2021-08-17 Thread Tomi Ollila
On Sun, Aug 15 2021, David Bremner wrote:

> YUE Daian  writes:
>
>>>
>> Maybe check version compatibility when notmuch is invoked from Emacs?
>>
>> So the user (like me) immediately know that it is time to upgrade my
>> system...
>
> Yes, that would be fine if someone wants to implement it.

Who volunteer to maintain it ? ;/

>
> d

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


Re: notmuch-tag failing on trailing space

2021-08-16 Thread Tomi Ollila
On Mon, Aug 16 2021, David Edmondson wrote:

> On Monday, 2021-08-16 at 08:17:56 -07, David Bremner wrote:
>
>> Alan Schmitt  writes:
>>
>>>
>>> #+begin_src emacs-lisp
>>>   (defun trim-tag-changes (args)
>>> (list (car args) (mapcar #'s-trim-right (cadr args
>>>   (advice-add 'notmuch-tag :filter-args #'trim-tag-changes)
>>> #+end_src
>>>
>>> Could it be integrated directly in the notmuch-tag function?
>>>
>>
>> That particular function won't work for us because it would introduce a
>> new dependency on s.el. But if someone wants to make an equivalent using
>> only core emacs functions and integrate it into notmuch-tag, that seems
>> likely OK to me.
>
> What if someone has trailing spaces on their tags deliberately?
>
> This seems like an oddity of the code in `notmuch-read-tag-changes' that
> appends a space to every possible completion. It would probably be a
> more annoying change to some users, but I'd be more inclined to remove
> that code than this change.

I'd also fix the source of the problem rather than the outcome...

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


Re: Why some characters are not displayed correctly when setting mm-text-html-renderer to links

2021-08-09 Thread Tomi Ollila
On Fri, Aug 06 2021, David Bremner wrote:

> Wenlong Dai  writes:
>
>>
>> After some research, I found that setting mm-text-html-renderer to links
>> would reduce the load time from 
>> to around 2 seconds or less. But one small issue with this is some
>> characters are not displayed correctly, for example the
>> RIGHT SINGLE QUOTATION MARK, which would be displayed as \342\200\231
>>
>
> I didn't have time to debug this yet, but I did duplicate the problem on
> Emacs 27.1 on Debian, so it is not Windows or gccemacs specific. As far
> as I can tell links is outputing non-utf8 characters, but it could also
> be other issues like double decoding.

setting those "coding-systems" is somewhat hard to understand (or it is
just me) -- i recall wondering these

  (let ((coding-system-for-read 'no-conversion))

iirc in related code...

One thing could be to wrap the 'links' command in a shell script
which executes 

  exec strace -o /tmp/strace.$$ -e trace=open /path/to/links "$@"'

(name that script as 'links' and point first entry in PATH to the 
directory that exists)

then one can check the logs what is links outputting (i'd guess it
would output utf-8 characters but one cannot know for sure...)

Tomi

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


Re: should notmuch handle or generate message responses (RFC 9078) (or, "why can't i  an e-mail message?")

2021-08-09 Thread Tomi Ollila
On Thu, Aug 05 2021, Daniel Kahn Gillmor wrote:

> Hi notmuch folks--
>
> RFC 9078 is an experimental draft "Reaction: Indicating Summary Reaction
> to a Message":
>
> https://www.rfc-editor.org/rfc/rfc9078.html
>
> In short form, this lets you "thumbs up" an e-mail message without
> sending a longer reply.
>
> Basically, it formalizes a way to respond to an e-mail with a single
> emoji sequence [0] by sending a message using the following headers:
>
>  - In-Reply-To: 
>  - Content-Type: text/plain; charset=utf-8
>  - Content-Disposition: reaction
>
>
> [0] https://www.unicode.org/reports/tr51/#def_emoji_sequence Note that
> "emoji sequence" is *not* just "a series of emoji characters", but
> rather it is a sequence of codepoints that is typically expected to
> render as a single emoji, for example a raised hand with dark skin
> tone is U+270B RAISED HAND followed by U+1F3FF EMOJI MODIFIER
> FITZPATRICK TYPE-6
>
>
> Currently in Notmuch these responses would be rendered as simple, short
> one-line text replies.
>
> Some questions for notmuch to consider:
>
>  0) Should a message that conforms to this standard be treated
> differently by notmuch than any other message?  If the answer is
> "nope" then the rest of the questions don't make sense :P
>
>  1) does the database need any modification to store/report these things
> as distinct responses?
>
>  2) should "notmuch new" treat the message differently upon ingestion?
>
>  3) should message threading information count the list of messages in
> the thread differently depending on how many messages are
> "response" messages?
>
>  4) How should a notmuch frontend decide when to clear the "unread" flag
> from such a response message?
>
>  5) Should notmuch frontends facilitate creation of this kind of
> response?
>
>  6) how should a frontend render the summaries of these responses?

I'd wait for "standards track" ;D (or de-facto usage it that takes too long...)

Tomi

>
> Interesting times,
>
>  --dkg
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: [PATCH] perf-test: fix for verbose

2021-08-09 Thread Tomi Ollila
On Thu, Aug 05 2021, David Bremner wrote:

> Felipe Contreras  writes:
>
>> Signed-off-by: Felipe Contreras 
>
> applied to master.
>
> shout out to Tomi for the review.

I guess I was the one who dropped the needs-review...

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


Re: [PATCH] emacs: Refine scope of notmuch-jump-key face

2021-08-09 Thread Tomi Ollila
On Thu, Aug 05 2021, David Bremner wrote:

> Protesilaos Stavrou  writes:
>
>> The intent of the 'notmuch-jump-key' face is to allow users/themes to
>> differentiate the text of the minibuffer prompt from the keys that are
>> associated with jump actions.  Commit 5cc106b0 correctly introduced the
>> 'notmuch-jump-key' face for keys, but mistakenly applied it to the
>> prompt as well.
>
> applied to master.
>
> Shout out to Tomi for the review.

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


Re: [PATCH] test: use --minversion to detect GNU Parallel.

2021-08-03 Thread Tomi Ollila
On Mon, Aug 02 2021, David Bremner wrote:

> Based on a suggestion of Ole Tange [1].
>
> [1]: id:CA+4vN7x6jp4HCiEybZ=5g+2X6Pa7etBFX3Bbd=uyty37gr6...@mail.gmail.com
> ---
>  test/notmuch-test | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/test/notmuch-test b/test/notmuch-test
> index ce142f7c..eefdf091 100755
> --- a/test/notmuch-test
> +++ b/test/notmuch-test
> @@ -51,7 +51,7 @@ RES=0
>  # Run the tests
>  if test -z "${NOTMUCH_TEST_SERIALIZE-}" && command -v parallel >/dev/null ; 
> then
>  test -t 1 && export COLORS_WITHOUT_TTY=t || :
> -if parallel --version 2>&1 | grep -q GNU ; then
> +if parallel --minversion 0 1>/dev/null 2>&1  ; then

fix the 2 spaces ;D

the 1 before >/dev/null is a bit confusing, fast reader reads parallel 
--minversion 0 1
as the arguments. so I'd suggest to drop the '1'.

Tomi


>  echo "INFO: running tests with GNU parallel"
>  printf '%s\n' $TESTS | $TEST_TIMEOUT_CMD parallel || RES=$?
>  else
> -- 
> 2.30.2
> ___
> notmuch mailing list -- notmuch@notmuchmail.org
> To unsubscribe send an email to notmuch-le...@notmuchmail.org
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: notmuch-tag failing on trailing space

2021-07-27 Thread Tomi Ollila
On Tue, Jul 27 2021, alan schmitt wrote:

> Hello,
>
> I have an issue when using the vertico completion system to add tags to
> messages that boils down to the following: the notmuch-tag function is
> called like this:
>   notmuch-tag("id:CA+b3G33ad9PX5SuOwqaWS8TWBTtZcdguKtcQ3XmPvzSCsU..." ("+cwn 
> "))
> and it fails because of the extra space at the end.
>
> Could notmuch-tag be modified to accept trailing spaces?

$ notmuch tag '+foo ' id:87im0w6u5r@m4x.org

works -- the tag is 'foo ' in this case.

The following fails (what I tried first based on your sample above):

$ notmuch tag id:87im0w6u5r@m4x.org '+foo '
Error: 'notmuch tag' requires at least one tag to add or remove.

(i.e. tags first then search terms)

>
> Thanks,
>
> Alan

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


Re: [PATCH 1/1] python/notmuch2: provide binding for database_get_directory()

2021-07-26 Thread Tomi Ollila
On Sun, Jul 25 2021, Ludovic LANGE wrote:

// stuff deleted //

>  Le 25/07/2021 à 22:18, Floris Bruynooghe a écrit :

// stuff deleted ... //

>>
>> Anyway, I'm curious what other people think of this as well.
>
> Copy/paste (!!) of the previous bindings. As I don't know how people are
> using them, I was expecting to make as little changes as necessary, so
> that code change would be kept to a minimal when porting from old
> bindings to new bindings.

If such an implementation is more inconsistent w/ the new bindings, then
-- for sure -- have implementation that differs more from old bindings.
(and from copy-paste point of view, mistakes lurk easily if changes are
applied w/o doing even more careful post-inspection before committing...) 
>
> Waiting for other feedback also.
>
>
>>> +def get_child_files(self):
>> Style-wise I'd name this `def files(self):`, I think it follows the
>> style of the API more.
>
> Same reasoning as before - not wanting to make too much changes from old
> to new bindings.
>
> But if the consensus is on having a new style, we will of course adapt.

IMO the def files(self): (and def directories(self):) are the way to go !

Tomi

// stuff deleted //

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


Re: configure checks for python3-notmuch2 module

2021-07-25 Thread Tomi Ollila
On Mon, Jul 12 2021, Michael J. Gruber wrote:

> David Bremner venit, vidit, dixit 2021-07-11 23:29:57:
>> 
>> It turns out we need pyconfig.h to build the (new) python bindings.  I
>> don't think this is adequately checked for by the configure script,
>> since I had a Fedora user report a build failure (during make install,
>> which I found odd) missing pyconfig.h
>> 
>> On Debian this is on libpython3.x-dev, which is not a dependency of the
>> python3-cffi package.
>
> You need python3-cffi to run python code which uses cffi bindings -
> think of it as the "lib" part. You need the devel package to generate a
> python module using cffi (i.e. binding for a specific c library).
>
> So, it makes sense for the lib package not to depend on the devel
> package (which is python3-devel on Fedora).
>
> I can't help with adapting configure to the header requirement, though.

In case of python3-devel missing in Fedora, the compilation should not pass
as far as shown in David's email (and in log below) as it is needed for 

Checking for python3 cffi and setuptools... 

configure part to complete with 'Yes'

But the message could be better. Perhaps

Checking for python3 dev(el), cffi and setuptools...

(although this may not be clear enough for debian users as the package
there is libpython3-dev, cannot say...)

For me, to figure out what was needed in Fedora 34 (ok, 33, but now tested
in upgraded fedora 34 host in running fedora:34 podman container) was to run
script -c 'sh -x ./configure'; less typescript; and then do internet search
how to install missing 'Python.h' include file...

Tomi

>
> Michael
>
>> log follows.
>> --
>> 
>> cd bindings/python-cffi && \
>> python3 setup.py build --build-lib build/stage && \
>> mkdir -p build/stage/tests && cp tests/*.py build/stage/tests
>> running build
>> running build_py
>> running build_ext
>> generating cffi module 'build/temp.linux-x86_64-3.9/notmuch2._capi.c'
>> creating build/temp.linux-x86_64-3.9
>> building 'notmuch2._capi' extension
>> creating build/temp.linux-x86_64-3.9/build
>> creating build/temp.linux-x86_64-3.9/build/temp.linux-x86_64-3.9
>> gcc -pthread -Wno-unused-result -Wsign-compare 
>> -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -O2 -fexceptions -g 
>> -grecord-gcc-switches -pipe -Wall -Werror=format-security 
>> -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fstack-protector-strong 
>> -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection 
>> -fcf-protection -D_GNU_SOURCE -fPIC -fwrapv -O2 -fexceptions -g 
>> -grecord-gcc-switches -pipe -Wall -Werror=format-security 
>> -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fstack-protector-strong 
>> -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection 
>> -fcf-protection -D_GNU_SOURCE -fPIC -fwrapv -O2 -fexceptions -g 
>> -grecord-gcc-switches -pipe -Wall -Werror=format-security 
>> -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fstack-protector-strong 
>> -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection 
>> -fcf-protection -D_GNU_SOURCE -fPIC -fwrapv -fPIC -I../../lib 
>> -I/usr/include/python3.9 -c build/temp.linux-x86_64-3.9/notmuch2._capi.c -o 
 b
>  ui
>>  ld/temp.linux-x86_64-3.9/build/temp.linux-x86_64-3.9/notmuch2._capi.o
>> build/temp.linux-x86_64-3.9/notmuch2._capi.c:50:14: fatal error: pyconfig.h: 
>> No such file or directory
>>50 | #include 
>>   |  ^~~~
>> compilation terminated.
>> error: command '/usr/bin/gcc' failed with exit code 1
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: [PATCH 0/5] Use closures and other emacs cleanup

2021-07-23 Thread Tomi Ollila
On Mon, Jul 19 2021, Jonas Bernoulli wrote:

> Some assorted emacs cleanup and fixes.  The big one is the switch to
> using closures instead of backquoted lambdas.  The other commits for
> the most part just deal with things the compiler complained about.
>
> Jonas Bernoulli (5):
>   emacs: use closures instead of backquoted lambdas
>   emacs: add some function declarations
>   emacs: fix some option type declarations
>   emacs: notmuch-show-pipe-message: cosmetics
>   emacs: shorten lines in two doc-strings

This series *looks* good to me (especially the 1st change -- I hope it
works >;D). I don't understand why byte compiler would complain
about too long lines but perhaps the changed docstrings are better
(2 weeks in island w/o exposion to english language so can say notmuch
about the content (if i could otherwise >;)))

Tomi

>
>  emacs/notmuch-draft.el |  2 +-
>  emacs/notmuch-hello.el | 24 ---
>  emacs/notmuch-jump.el  | 30 +++
>  emacs/notmuch-show.el  | 26 -
>  emacs/notmuch-tag.el   |  2 +-
>  emacs/notmuch-tree.el  | 66 +-
>  emacs/notmuch.el   | 13 +
>  7 files changed, 93 insertions(+), 70 deletions(-)
>
> -- 
> 2.31.1
> ___
> notmuch mailing list -- notmuch@notmuchmail.org
> To unsubscribe send an email to notmuch-le...@notmuchmail.org
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: [PATCH] devel: two scripts for checking proposed changes

2021-07-23 Thread Tomi Ollila
On Tue, Jun 29 2021, David Bremner wrote:

> Tomi Ollila  writes:
>
>>> +
>>> +set -e
>>> +make test
>>
>> This may fail miserably (or is painfully slow (doing configure and make...)
>>
>
> At least for my use case, running the tests for each commit is the main
> point. The formatting stuff is nice to have, but only if the tests run.
> I could invoke the notmuch-test script directly, but that is
> arguably slightly less robust because of the need to create test-binaries.
>
>>> +for file in $(git diff --name-only HEAD^); do
>>
>> is this also mentioning deleted files... ? (--diff-filter=AM) ?
>
> Oh, good point.
>
>>
>>> +case $file in
>>> +   *.c|*.h|*.cc|*.hh)
>>> +uncrustify --replace -c $(dirname "$0")/uncrustify.cfg "$file"
>>
>> dirname "$0" could be resolved once before loop.
>>
>
> yes, although I'm not sure it's a win?

actually (IMO) the 'winnest' option is to:

first have

unset dn0

and then in all cases of $(dirname "$0") to be replaced with

"${dn0=$(dirname "$0")}"

In this case $(dirname "$0") is executed at most once -- but zero times
in case the result is never used. (note also quotes around the whole
expression :)

Tomi

>
>>> +   ;;
>>> +   *.el)
>>> +$(dirname "$0")/reindent-elisp "$file"
>>> +   ;;
>>> +esac
>>> +done
>>> +
>>> +git diff --quiet
>>> +
>>> diff --git a/devel/reindent-elisp b/devel/reindent-elisp
>>> new file mode 100755
>>> index ..f6ce3844
>>> --- /dev/null
>>> +++ b/devel/reindent-elisp
>>> @@ -0,0 +1,8 @@
>>> +#!/bin/sh
>>> +
>>> +if [ $# -lt 1 ]; then
>>
>> if [ $# -ne 1 ] ... (see at the end)
>>
> OK
>>> +printf "usage: $0 \n"
>>
>> Angle brackets are bad in example -- if copy-pasted to terminal (and badly
>> edited) does redirections...
>
> ack
>
>>
>>> +exit 1
>>> +fi
>>> +
>>> +emacs -Q --batch $1 --eval '(indent-region (point-min) (point-max) nil)'
>>> -f save-buffer
>>
>> ... as here is $1 -- which should be quoted as "$1"
>
> OK
>
>>
>>> -- 
>>> 2.30.2
> ___
> notmuch mailing list -- notmuch@notmuchmail.org
> To unsubscribe send an email to notmuch-le...@notmuchmail.org
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: configure checks for python3-notmuch2 module

2021-07-15 Thread Tomi Ollila
On Sun, Jul 11 2021, David Bremner wrote:

> It turns out we need pyconfig.h to build the (new) python bindings.  I
> don't think this is adequately checked for by the configure script,
> since I had a Fedora user report a build failure (during make install,
> which I found odd) missing pyconfig.h
>
> On Debian this is on libpython3.x-dev, which is not a dependency of the
> python3-cffi package.
>
> log follows.
> --
>
> cd bindings/python-cffi && \
>   python3 setup.py build --build-lib build/stage && \
>   mkdir -p build/stage/tests && cp tests/*.py build/stage/tests
> running build
> running build_py
> running build_ext
> generating cffi module 'build/temp.linux-x86_64-3.9/notmuch2._capi.c'
> creating build/temp.linux-x86_64-3.9
> building 'notmuch2._capi' extension
> creating build/temp.linux-x86_64-3.9/build
> creating build/temp.linux-x86_64-3.9/build/temp.linux-x86_64-3.9
> gcc -pthread -Wno-unused-result -Wsign-compare 
> -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -O2 -fexceptions -g 
> -grecord-gcc-switches -pipe -Wall -Werror=format-security 
> -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fstack-protector-strong 
> -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection 
> -fcf-protection -D_GNU_SOURCE -fPIC -fwrapv -O2 -fexceptions -g 
> -grecord-gcc-switches -pipe -Wall -Werror=format-security 
> -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fstack-protector-strong 
> -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection 
> -fcf-protection -D_GNU_SOURCE -fPIC -fwrapv -O2 -fexceptions -g 
> -grecord-gcc-switches -pipe -Wall -Werror=format-security 
> -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fstack-protector-strong 
> -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection 
> -fcf-protection -D_GNU_SOURCE -fPIC -fwrapv -fPIC -I../../lib 
> -I/usr/include/python3.9 -c build/temp.linux-x86_64-3.9/notmuch2._capi.c -o b
 ui
>  ld/temp.linux-x86_64-3.9/build/temp.linux-x86_64-3.9/notmuch2._capi.o
> build/temp.linux-x86_64-3.9/notmuch2._capi.c:50:14: fatal error: pyconfig.h: 
> No such file or directory
>50 | #include 
>   |  ^~~~
> compilation terminated.
> error: command '/usr/bin/gcc' failed with exit code 1

While me trying (Fedora 34 .. ooh no, 33 (but anyway ;D)):

$ ./configure
...
Checking for python3 cffi and setuptools...
No (will not install CFFI-based python bindings).
...

OK, why -- I do have cffi and setuptools python packages installed
..so:

$ script -c 'sh -x ./configure'

reveals (after trying w/ python 3.9 repl) that cffi.FFI().verify()
fails due to missing Python.h... let's hunt (again, I recall solving
this like a year ago or so..) ... apparently python3-devel needed.

$ sudo dnf install python3-devel
$ make distclean
$ ./configure --prefix=$PWD/TTT
$ make
$ make install

... hmm all worked pyconfig.h is part of python3-devel package

Have to check how all this behaves on Fedora 34 machine when I 
have access to one (currently away from such machines and from
power grid also (laptop battery power, which I have to preserve,
mobile devices gets charged by small solar panels so no problem
there ;D))

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


Re: Repeat last tagging

2021-07-14 Thread Tomi Ollila
On Wed, Jul 14 2021, in...@sindominio.net wrote:

> Hi,
>
> While using notmuch in emacs (which I love, thank you so much!!) I was
> wondering if there's a way to repeat the last tagging operation for a
> different message or thread.
>
> My usecase is that, in tree-mode, sometimes I need to tag several emails
> from different threads, and it would come very handy if, after the first
> tag change, I could use a shortcut (I'd choose '.', as in vim/evil)
> which would apply the same tag change to other emails. Does this make
> sense?

It does, what it would require is saving last-tag-change to a variable
and then bind function to a key... 
I personally am not too interested for such a binding (It could be
"dangerous" to do accidental undesired change (but I also could be
wrong and like such a feature >;D)

for reference I have the following bindings added to my configuration file

(define-key notmuch-show-user-map "u"
  (lambda () "mark message unread" (interactive)
(notmuch-show-tag-message "+unread")))

(define-key notmuch-show-user-map "i"
  (lambda () "remove inbox tag" (interactive)
(notmuch-show-tag-message "-inbox")))

which means uu restores "unread" and ui removes "inbox".

one can bind to notmuch-show-mode-map in order for just one keypress
to do tag-change... storing last-tag-change may provide hard if there
is no central place to execute "notmuch tag" command in notmuch emacs
source code...


Tomi
 
> I know I could perform a search for all the emails that I need
> to tag and tag them all at the same time, but the criteria to select
> them is usually not obvious. Another option would be to be able to mark
> emails, then tag them (I've seen the emacs-region thing, but it's not
> the same).
>
> Thanks in advance. And cheers again for the good work!
>
> Regards,
> ___
> notmuch mailing list -- notmuch@notmuchmail.org
> To unsubscribe send an email to notmuch-le...@notmuchmail.org
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: [PATCH v2] cli/show: add --format=pretty

2021-07-04 Thread Tomi Ollila
On Fri, Jul 02 2021, Hannu Hartikainen wrote:

> The rationale for this feature is twofold:
>
> 1. It is useful to be able to view messages in as human-friendly format
>as possible.
> 2. The same format should still be machine-readable, too.
>
> The email format is mostly human-readable as is. The things difficult
> for a human eye are the huge amount of headers that are common these
> days and telling different messages apart when there are many.
>
> This commit adds the display format `pretty`. It recognizes if the
> output is a TTY and if so, applies coloring to headers. This turns out
> to be a good visual message separator. Additionally it only shows the
> most important headers, similarly to `--format=text`, and only displays
> plaintext parts (ie. text/* but not text/html).
>
> While human readability is the main goal, another design goal was that
> piping the output to `git am` works, at least for individual messages
> sent with `git send-email`.
> ---
>
> I wrote a v2 of this patch. I've been dogfooding for a while now and
> wanted a couple of enhancements, and also had learned about the notmuch
> test harness. The differences to the first version are:
>
> - add a unit test
> - show Message-ID, making replying etc. much easier
> - print a newline after each part, which helps a lot with messages that
>   do not end in a newline
>
> I'm using this as a daily driver and am happy with it.
>
>  NEWS   |  7 
>  completion/notmuch-completion.bash |  2 +-
>  completion/zsh/_notmuch|  2 +-
>  doc/man1/notmuch-show.rst  |  8 +++-
>  notmuch-show.c | 67 ++
>  test/T520-show.sh  | 32 ++
>  6 files changed, 115 insertions(+), 3 deletions(-)
>
> diff --git a/NEWS b/NEWS
> index 3e776009..f5142ff1 100644
> --- a/NEWS
> +++ b/NEWS
> @@ -1,6 +1,13 @@
>  Notmuch 0.33 (UNRELEASED)
>  =
>  
> +CLI
> +---
> +
> +`notmuch show` now has `--format=pretty`, optimized for reading plain
> +text emails on the command line. It only shows the most important
> +headers and plain text parts and uses colors for headers.
> +
>  Emacs
>  -
>  
> diff --git a/completion/notmuch-completion.bash 
> b/completion/notmuch-completion.bash
> index 15425697..86cbbcdc 100644
> --- a/completion/notmuch-completion.bash
> +++ b/completion/notmuch-completion.bash
> @@ -514,7 +514,7 @@ _notmuch_show()
>   return
>   ;;
>   --format)
> - COMPREPLY=( $( compgen -W "text json sexp mbox raw" -- "${cur}" ) )
> + COMPREPLY=( $( compgen -W "text pretty json sexp mbox raw" -- 
> "${cur}" ) )
>   return
>   ;;
>   --exclude|--body)
> diff --git a/completion/zsh/_notmuch b/completion/zsh/_notmuch
> index e920f10b..5cc386e2 100644
> --- a/completion/zsh/_notmuch
> +++ b/completion/zsh/_notmuch
> @@ -237,7 +237,7 @@ _notmuch_search() {
>  _notmuch_show() {
>_arguments -S \
>  '--entire-thread=[output entire threads]:show thread:(true false)' \
> -'--format=[set output format]:output format:(text json sexp mbox raw)' \
> +'--format=[set output format]:output format:(text pretty json sexp mbox 
> raw)' \
>  '--format-version=[set output format version]:format version: ' \
>  '--part=[output a single decoded mime part]:part number: ' \
>  '--verify[verify signed MIME parts]' \
> diff --git a/doc/man1/notmuch-show.rst b/doc/man1/notmuch-show.rst
> index fc6bec62..1fe4dcc7 100644
> --- a/doc/man1/notmuch-show.rst
> +++ b/doc/man1/notmuch-show.rst
> @@ -34,7 +34,7 @@ Supported options for **show** include
> the matching messages. For ``--format=json`` and ``--format=sexp``
> this defaults to true. For other formats, this defaults to false.
>  
> -.. option:: --format=(text|json|sexp|mbox|raw)
> +.. option:: --format=(text|pretty|json|sexp|mbox|raw)
>  
> **text** (default for messages)
>   The default plain-text format has all text-content MIME parts
> @@ -46,6 +46,12 @@ Supported options for **show** include
>   '}'), to either open or close the component. For a multipart
>   MIME message, these parts will be nested.
>  
> +   **pretty**
> + The plain-text parts of all matching messages are printed in a
> + format optimized for readability. Only the most important
> + headers are displayed. If the output is to a TTY, the headers
> + are colored.
> +
> **json**
>   The output is formatted with Javascript Object Notation
>   (JSON). This format is more robust than the text format for
> diff --git a/notmuch-show.c b/notmuch-show.c
> index 232557d5..c417ec00 100644
> --- a/notmuch-show.c
> +++ b/notmuch-show.c
> @@ -606,6 +606,65 @@ format_part_text (const void *ctx, sprinter_t *sp, 
> mime_node_t *node,
>  return NOTMUCH_STATUS_SUCCESS;
>  }
>  
> +static notmuch_status_t
> +format_part_pretty (const void *ctx, sprinter_t *sp, mime_node_t *node,
> + int 

Re: [PATCH 2/2] test: known broken test for emacs display of message/rfc822 parts

2021-07-04 Thread Tomi Ollila
On Sat, Jul 03 2021, David Bremner wrote:

> There are at least 3 bugs present.
>
> 1) notmuch-show-insert-part-message/rfc822 assumes that message/rfc822
> parts will have a ":content" property, but that turns out not to be
> the case.
>
> 2) something deep in gnus wants gnus-newsgroup-charset, but that is
> defined in gnus-sum, which is not loaded by default.
>
> 3) If gnus-sum is loaded, then the display of the message/rfc822 part
> succeeds, but the buffer gets put into gnus-article-mode, which means
> that, inter alia, notmuch text properties and keybindings get wiped.
> ---
>  test/T450-emacs-show.sh | 7 +++
>  1 file changed, 7 insertions(+)
>
> diff --git a/test/T450-emacs-show.sh b/test/T450-emacs-show.sh
> index 9d08d2cc..bf7c1fe0 100755
> --- a/test/T450-emacs-show.sh
> +++ b/test/T450-emacs-show.sh
> @@ -219,6 +219,13 @@ test_emacs '(notmuch-show 
> "id:basic-encryp...@crypto.notmuchmail.org")
>  (test-visible-output)'
>  test_expect_equal_file $EXPECTED/notmuch-show-decrypted-message OUTPUT
>  
> +test_begin_subtest "show encrypted rfc822 message"
> +test_subtest_known_broken
> +test_emacs '(notmuch-show 
> "id:encrypted-rfc822-attachm...@crypto.notmuchmail.org")
> +(test-visible-output)'
> +fgrep '!!!' OUTPUT > OUTPUT.err
> +test_expect_equal_file /dev/null OUTPUT.err

In this case one could just do 

test_expect_code 1 "fgrep -q '!!!' OUTPUT" 

(these file comparisons w/ /dev/null (currently 5) annoys me ;/
so if I am biased the current suggestion is fine)

Tomi

> +
>  test_begin_subtest "show undecryptable message"
>  test_emacs '(notmuch-show "id:simple-encryp...@crypto.notmuchmail.org")
>  (test-visible-output)'
> -- 
> 2.30.2
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: [PATCH] devel: two scripts for checking proposed changes

2021-06-28 Thread Tomi Ollila
On Mon, Jun 28 2021, David Bremner wrote:

> It took me a bit of effort to get the correct oneliner to reindent
> elisp from the command line, so I saved the results as
> 'reindent-elisp'.
>
> 'check-notmuch-commit' is an updated version of a script I have been
> using (although not always as consistently as I should) before sending
> patches to the list.
>
> Although it requires a bit more tooling, encouraging people to use
> check-notmuch-commit might reduce the number of round trips to the
> list for style nitpicks.
> ---
>  devel/check-notmuch-commit | 20 
>  devel/reindent-elisp   |  8 
>  2 files changed, 28 insertions(+)
>  create mode 100755 devel/check-notmuch-commit
>  create mode 100755 devel/reindent-elisp
>
> diff --git a/devel/check-notmuch-commit b/devel/check-notmuch-commit
> new file mode 100755
> index ..98a19a64
> --- /dev/null
> +++ b/devel/check-notmuch-commit
> @@ -0,0 +1,20 @@
> +#!/bin/sh
> +
> +# Usage suggestion:
> +#   git rebase -i --exec devel/check-notmuch-commit origin/master
> +
> +set -e
> +make test

This may fail miserably (or is painfully slow (doing configure and make...)

> +for file in $(git diff --name-only HEAD^); do

is this also mentioning deleted files... ? (--diff-filter=AM) ?

> +case $file in
> + *.c|*.h|*.cc|*.hh)
> +uncrustify --replace -c $(dirname "$0")/uncrustify.cfg "$file"

dirname "$0" could be resolved once before loop.

> + ;;
> + *.el)
> +$(dirname "$0")/reindent-elisp "$file"
> + ;;
> +esac
> +done
> +
> +git diff --quiet
> +
> diff --git a/devel/reindent-elisp b/devel/reindent-elisp
> new file mode 100755
> index ..f6ce3844
> --- /dev/null
> +++ b/devel/reindent-elisp
> @@ -0,0 +1,8 @@
> +#!/bin/sh
> +
> +if [ $# -lt 1 ]; then

if [ $# -ne 1 ] ... (see at the end)

> +printf "usage: $0 \n"

Angle brackets are bad in example -- if copy-pasted to terminal (and badly
edited) does redirections...

> +exit 1
> +fi
> +
> +emacs -Q --batch $1 --eval '(indent-region (point-min) (point-max) nil)'
> -f save-buffer

... as here is $1 -- which should be quoted as "$1"

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


Re: [PATCH] test/libconfig: make indexing more consistent

2021-06-20 Thread Tomi Ollila
On Sat, Jun 19 2021, David Bremner wrote:

> The other tests have converted to two digit decimal, the commit does
> the same to the remaining test that was printing out indices in hex.

LGTM.

Tomi

> ---
>  test/T590-libconfig.sh | 24 
>  1 file changed, 12 insertions(+), 12 deletions(-)
>
> diff --git a/test/T590-libconfig.sh b/test/T590-libconfig.sh
> index bc7298f8..189381f7 100755
> --- a/test/T590-libconfig.sh
> +++ b/test/T590-libconfig.sh
> @@ -713,23 +713,23 @@ cat c_head2 - c_tail <<'EOF' | test_C ${MAIL_DIR} 
> %NULL% %NULL%
>key < NOTMUCH_CONFIG_LAST;
>key = (notmuch_config_key_t)(key + 1)) {
>   const char *val = notmuch_config_get (db, key);
> - printf("%x: '%s'\n", key, val ? val : "NULL" );
> + printf("%02d: '%s'\n", key, val ? val : "NULL" );
>  }
>  }
>  EOF
>  cat <<'EOF' >EXPECTED
>  == stdout ==
> -0: 'MAIL_DIR'
> -1: 'MAIL_DIR'
> -2: 'MAIL_DIR/.notmuch/hooks'
> -3: 'MAIL_DIR/.notmuch/backups'
> -4: 'foo;bar;fub'
> -5: 'unread;inbox'
> -6: 'sekrit_junk'
> -7: 'true'
> -8: 'test_su...@notmuchmail.org'
> -9: 'test_suite_ot...@notmuchmail.org;test_su...@otherdomain.org'
> -a: 'Notmuch Test Suite'
> +00: 'MAIL_DIR'
> +01: 'MAIL_DIR'
> +02: 'MAIL_DIR/.notmuch/hooks'
> +03: 'MAIL_DIR/.notmuch/backups'
> +04: 'foo;bar;fub'
> +05: 'unread;inbox'
> +06: 'sekrit_junk'
> +07: 'true'
> +08: 'test_su...@notmuchmail.org'
> +09: 'test_suite_ot...@notmuchmail.org;test_su...@otherdomain.org'
> +10: 'Notmuch Test Suite'
>  == stderr ==
>  EOF
>  test_expect_equal_file EXPECTED OUTPUT
> -- 
> 2.30.2
> ___
> notmuch mailing list -- notmuch@notmuchmail.org
> To unsubscribe send an email to notmuch-le...@notmuchmail.org
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: notmuch-emacs notmuch-tag configuration

2021-06-16 Thread Tomi Ollila
On Tue, Jun 15 2021, David Wen Riccardi-Zhu wrote:

> I'm using notmuch 0.32.1, Emacs 27.2, and version 20210605.1839 of
> notmuch-emacs. When I try to mark a message as read using a custom
> keybinding, I'm getting the following error:
>
> notmuch-tag: Symbol’s function definition is void: query

I recall some related/relevant/whatornot lexical-binding talk...

Also, this is mentioned in latest NEWS (for 0.32.1):

  Emacs
  -

  Restore the dynamically bound variables `tag-changes` and `query` in
  in `notmuch-before-tag-hook` and `notmuch-after-tag-hook`.

may or may not help. no time to dig deeper for now :D


Tomi


>
> Here's the backtrace:
>
> Debugger entered--Lisp error: (void-function query)
>   query("(id:pX7JAnfzR_GtdCfx1KGqCA@geopod-ismtpd-4-0)")
>   notmuch-tag("(id:pX7JAnfzR_GtdCfx1KGqCA@geopod-ismtpd-4-0)" ("-new"
> "-unread"))
>   notmuch-search-tag(("-new" "-unread"))
>   (lambda nil "unmark message as new and unread" (interactive)
> (notmuch-search-tag (list "-new" "-unread")) (forward-line))()
>   funcall-interactively((lambda nil "unmark message as new and unread"
> (interactive) (notmuch-search-tag (list "-new" "-unread")) (forward-line)))
>   call-interactively((lambda nil "unmark message as new and unread"
> (interactive) (notmuch-search-tag (list "-new" "-unread")) (forward-line))
> nil nil)
>   command-execute((lambda nil "unmark message as new and unread"
> (interactive) (notmuch-search-tag (list "-new" "-unread")) (forward-line)))
>
> And following is my notmuch-emacs configuration:
>
> (with-eval-after-load 'notmuch
>   (customize-set-variable 'notmuch-search-oldest-first nil)
>   (setq notmuch-address-command 'internal
> notmuch-address-internal-completion '(sent nil)
> notmuch-address-save-filename "~/some/dir/file"
> notmuch-address-use-company t
> notmuch-crypto-process-mime t
> notmuch-fcc-dirs "sent"
> notmuch-hello-hide-tags '("killed"))
>   ;; Search tags
>   (setq notmuch-saved-searches
> '((:name "inbox" :query "tag:inbox" :key "i")
>   (:name "unread" :query "tag:unread" :key "u")
>   (:name "new" :query "tag:new" :key "n")
>   (:name "sent" :query "tag:sent" :key "e")
>   (:name "drafts" :query "tag:draft" :key "d")
>   (:name "all mail" :query "*" :key "a")
>   (:name "todo" :query "tag:todo" :key "t")))
>   ;; Keybindings
>   (define-key notmuch-search-mode-map "S"
> (lambda ()
>   "mark message as spam"
>   (interactive)
>   (notmuch-search-tag (list "-new" "-unread" "-inbox" "+spam"))
>   (forward-line)))
>   (define-key notmuch-show-mode-map "S"
> (lambda ()
>   "mark message as spam"
>   (interactive)
>   (notmuch-show-tag (list "-new" "-unread" "-inbox" "+spam"
>   (define-key notmuch-search-mode-map "N"
> (lambda ()
>   "unmark message as new and unread"
>   (interactive)
>   (notmuch-search-tag (list "-new" "-unread"))
>   (forward-line)))
>   (define-key notmuch-show-mode-map "N"
> (lambda ()
>   "unmark message as new and unread"
>   (interactive)
>   (notmuch-show-tag (list "-new" "-unread"
>   (define-key notmuch-show-mode-map "r" 'notmuch-show-reply)
>   (define-key notmuch-show-mode-map "R" 'notmuch-show-reply-sender)
>   (define-key notmuch-search-mode-map "r" 'notmuch-search-reply-to-thread)
>   (define-key notmuch-search-mode-map "R"
> 'notmuch-search-reply-to-thread-sender))
>
> I'm a little confused as to why this isn't working -- I don't believe that
> my configuration has strayed from what's listed in the online documentation.
>
> Any insights? I don't know Emacs Lisp well enough to understand why query
> is a void function.
>
> Many thanks!
>
> David
> ___
> notmuch mailing list -- notmuch@notmuchmail.org
> To unsubscribe send an email to notmuch-le...@notmuchmail.org
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: show a single message in a huge thread

2021-06-12 Thread Tomi Ollila
On Fri, Jun 11 2021, Jonathan Wilner wrote:

> I definitely also have this problem with large threads - big time hangs
> using Notmuch in Emacs. My simple tests indicate that it happens in Emacs,
> not using Notmuch at the command line, though that can also take quite a
> long time to return.
>
> I'm suspicious that there's something with HTML parsing - does that seem
> possible? It might also make sense if Delta Chat is giving you HTML versus
> plaintext.

one thing you could also try is to press '<' in that notmuch show buffer
adn observe how long it takes to drop indentation of the whole buffer (i
don't remember how it does that) and then repres '<' and see whether
re-indenting takes much more time dropping indentation.

in notmuch show there is
(defvar-local notmuch-show-indent-content t)

I tried just to M-: (setq notmuch-show-indent-content nil) -- that did not
have any effect... 

IIRC the (indent-rigidly ...) executions take quite a lot of time but is
that significant or not here...


Tomi

>
>
>
> On Thu, Jun 3, 2021 at 12:55 AM Alan Schmitt 
> wrote:
>
>> Hello,
>>
>> On 2021-06-02 09:18, David Bremner  writes:
>>
>> > The code I posted worked fine for me for one message from a thread of
>> > 323 messages.
>>
>> The thread that used to crash (before your patch) was from DeltaChat,
>> which is an email-based chat app. The thread it produces are like lists
>> more than trees. So I guess the depth of the tree is what matters.
>>
>> Best,
>>
>> Alan
>> ___
>> notmuch mailing list -- notmuch@notmuchmail.org
>> To unsubscribe send an email to notmuch-le...@notmuchmail.org
>>
> ___
> notmuch mailing list -- notmuch@notmuchmail.org
> To unsubscribe send an email to notmuch-le...@notmuchmail.org
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: [PATCH] emacs: remap send-message and send-message-and-exit

2021-06-07 Thread Tomi Ollila
On Fri, Jun 04 2021, e...@edef.eu wrote:

>> >  (defvar notmuch-message-mode-map
>> >(let ((map (make-sparse-keymap)))
>> > -(define-key map (kbd "C-c C-c") #'notmuch-mua-send-and-exit)
>> > -(define-key map (kbd "C-c C-s") #'notmuch-mua-send)
>> > +(define-key map [remap message-send-and-exit] 
>> > 'notmuch-mua-send-and-exit)
>> > +(define-key map [remap message-send] 'notmuch-mua-send)
>> 
>> where did the # characters disappear here ?
>> 
>> afaic #' is the recommended way here...

> I'm not sure where to find that recommendation — the Emacs manual and
> information I've found in the wild don't use it for define-key.

In this particular case, around the change #' is used, 
and in change ' is used.

(in some other parts in notmuch elisp source there is only ' used
-- consistency -- in one way or another, would be nice...)

emacs sharp quote   can be used in internet searches to find more info,

then, in

http://www.gnu.org/software/emacs/manual/html_node/elisp/Anonymous-Functions.html


  Special Form: function function-object

  This special form returns function-object without evaluating it. In
  this, it is similar to quote (see Quoting). But unlike quote, it also
  serves as a note to the Emacs evaluator and byte-compiler that
  function-object is intended to be used as a function. Assuming
  function-object is a valid lambda expression, this has two effects:

  When the code is byte-compiled, function-object is compiled into a
  byte-code function object (see Byte Compilation).
  When lexical binding is enabled, function-object is converted into
  a closure. See Closures. 

  When function-object is a symbol and the code is byte compiled, the
  byte-compiler will warn if that function is not defined or might not be
  known at run time. 

  The read syntax #' is a short-hand for using function. 

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


Re: [PATCH] emacs: drop setting mail-user-agent, and document how to set it

2021-06-07 Thread Tomi Ollila
On Fri, Jun 04 2021, David Bremner wrote:

> After some discussion [1], I decided it is better to make notmuch users
> who rely on this behaviour customize mail-user-agent. This is
> consistent with the behaviour of other emacs mail packages.

LGTM.

Tomi 

>
> [1]: id:87k0nuhfrk@toryanderson.com
> ---
>  NEWS  |  7 +++
>  doc/notmuch-emacs.rst | 10 ++
>  emacs/notmuch.el  |  2 --
>  3 files changed, 17 insertions(+), 2 deletions(-)
>
> diff --git a/NEWS b/NEWS
> index 35b57cef..538ec168 100644
> --- a/NEWS
> +++ b/NEWS
> @@ -1,6 +1,13 @@
>  Notmuch 0.33 (UNRELEASED)
>  =
>  
> +Emacs
> +-
> +
> +`notmuch` no longer sets `mail-user-agent` on load. To restore the
> +previous behaviour of using notmuch to send mail by default, customize
> +`mail-user-agent` to `notmuch-user-agent`.
> +
>  Vim
>  ---
>  
> diff --git a/doc/notmuch-emacs.rst b/doc/notmuch-emacs.rst
> index d9b497a3..7772871b 100644
> --- a/doc/notmuch-emacs.rst
> +++ b/doc/notmuch-emacs.rst
> @@ -366,6 +366,16 @@ Importing Mail
>  :index:`notmuch-poll-script`
> |docstring::notmuch-poll-script|
>  
> +Sending Mail
> +
> +
> +:index:`mail-user-agent`
> +
> +   Emacs consults the variable :ref:`mail-user-agent` to choose a mail
> +   sending package for commands like :ref:`report-emacs-bug` and
> +   :ref:`compose-mail`.  To use ``notmuch`` for this, customize this
> +   variable to the symbol :ref:`notmuch-user-agent`.
> +
>  Init File
>  -
>  
> diff --git a/emacs/notmuch.el b/emacs/notmuch.el
> index 6d37c623..3e2713e2 100644
> --- a/emacs/notmuch.el
> +++ b/emacs/notmuch.el
> @@ -1162,8 +1162,6 @@ Point should be at the beginning of the line."
>  
>  ;;; _
>  
> -(setq mail-user-agent 'notmuch-user-agent)
> -
>  (provide 'notmuch)
>  
>  ;; After provide to avoid loops if notmuch was require'd via 
> notmuch-init-file.
> -- 
> 2.30.2
> ___
> notmuch mailing list -- notmuch@notmuchmail.org
> To unsubscribe send an email to notmuch-le...@notmuchmail.org
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: [PATCH] test: aggregate-results updates

2021-06-07 Thread Tomi Ollila
On Sat, Jun 05 2021, David Bremner wrote:

> Tomi Ollila  writes:
>>
>> testing all changed branches is somewhat hard; I did by adding
>> sleep 20 and file what effective removed created results files;
>> another change was to change 'total' to 'toxtal' in test_done,
>> then I run (at least) the following command lines:
>
> changing test_done results in pretty nonsensical output. I guess that's
> OK?

Yes.

It is very unlikely that if something is written to file not all data were
written (as the amount of data to be written is low).
A bit less unlikely is the case that output file is created but no data
written.

Should such an extremely rare cases happen it should be enough just to
report it so it get noticed (and not add any extra code to handle such
cases any further). One checking the results would probably guess that
if output is as nonsensical as it is something went badly wrong.

Tomi

>
> $  NOTMUCH_TESTS=T310-emacs.sh ./notmuch-test
>
> ...
>
> '/home/bremner/software/upstream/notmuch/test/test-results/T310-emacs' lacks 
> 'total ...'; results may be inconsistent.
> Notmuch test suite complete.
> 72/0 tests passed.
> 1 test failed.
> -73 tests skipped.
> ___
> notmuch mailing list -- notmuch@notmuchmail.org
> To unsubscribe send an email to notmuch-le...@notmuchmail.org
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: [PATCH] emacs: PATCH [1/2] mail user agent

2021-06-03 Thread Tomi Ollila
On Thu, Jun 03 2021, Tory S. Anderson wrote:

> Nice follow-upabout what other browsers do!
>
> David Bremner  writes:
>
>> Tomi Ollila  writes:
>>
>>> On Mon, May 31 2021, David Bremner wrote:
>>>
>>>> Tomi Ollila  writes:
>>>>>
>>>>> I am for 'ripping the bandage off' and not configure mail-user-agent
>>>>> outside of notmuch use (and just require 'notmuch would not set 
>>>>> anything...)
>>>>>
>>>>> Could we have some 'compose-mail' variant (different name, of course;
>>>>> I had one in mind but then came off-by one problem... >;) which 
>>>>> configures mail-user-agent just for that use (or something).
>>>>>
>>>>
>>>> Are you thinking about notmuch-mua-mail (which exists)?
>>>>
>>>> Tory, did you try the eval-after-load trick I mentioned btw? That seemed
>>>> to work in my testing, and I'm just not sure that customizing a
>>>> notmuch-* variable is much less annoying than adding an eval-after-load to
>>>> reset the variable after notmuch messes with it.
>
> No, I'm guilty here. I used my patch instead and haven't looked back
> since. I think having to add code lines to an init file is much more
> annoying (and less transparent) than simply having something for which I
> can add a =:custom= line in my use-package statements, or new users just
> use the customizer to explore to. Maybe that's just me, but I feel much
> more comfortable about sharing that config or that suggestion with
> others, too. Explorability is what customizer's big benefit to emacs is,
> so it seems to me a real advantage to have this in there.
>

mail-user-agent is defcustom in simple.el, starting:

  (defcustom mail-user-agent 'message-user-agent
"Your preference for a mail composition package.
  Various Emacs Lisp packages (e.g. Reporter) require you to compose an
  outgoing email message.  This variable lets you specify which
  mail-sending package you prefer.

  Valid values include:

`message-user-agent'  -- use the Message package.
 See Info node `(message)'.
`sendmail-user-agent' -- use the Mail package.
 See Info node `(emacs)Sending Mail'.
`mh-e-user-agent' -- use the Emacs interface to the MH mail system.
 See Info node `(mh-e)'.
`gnus-user-agent' -- like `message-user-agent', but with Gnus
 paraphernalia if Gnus is running, particularly
 the Gcc: header for archiving.

  Additional valid symbols may be available; check with the author of
  your package for details.  The function should return non-nil if it
  succeeds.
  ...

Currently if one uses/used customizer to change to something else, which
is saved to .emacs (or somewhere else where custom-file points to), and
then loads notmuch, it suddenly changes to 'notmuch-user-agent.

AFAIU the change your patch did does not change that, one just has to
customize notmuch-mail-user-agent.

IMO that makes things messy.

If there were option to somehow magically add more values to the
mail-user-agent customize menu while loading notmuch.el then one
could just directly choose notmuch-user-agent from that menu.

Otherwise I don't see other options than document how to do that
configuration (and drop that setq and add NEWS entry).

Tomi

>>>>
>>>> Still waiting for feedback from notmuch users that actually use M-x
>>>> compose-mail or other similar generic entry points.
>>>
>>> Does anyone know how compose-mail behaves when one has loaded any other
>>> emacs mua (mh, vm, gnus, mu, ...) ?
>>>
>>
>> As far as I can tell
>>
>>vm: only locally binds mail-user-agent
>>mh-e: used to have a setq mail-user-agent, removed in 2003-ish
>>mu4e: documents how to set mail-user-agent
>>rmail: reads mail-user-agent, but does not set
>>gnus: only locally binds mail-user-agent
>>wanderlust: tells you how how to set mail-user-agent (and oddly, how
>>to define conditionaly define a user agent)
>>
>> So I think notmuch is the odd one out here.
>> ___
>> notmuch mailing list -- notmuch@notmuchmail.org
>> To unsubscribe send an email to notmuch-le...@notmuchmail.org
> ___
> notmuch mailing list -- notmuch@notmuchmail.org
> To unsubscribe send an email to notmuch-le...@notmuchmail.org
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: show a single message in a huge thread

2021-06-02 Thread Tomi Ollila
On Wed, Jun 02 2021, David Bremner wrote:

> David Bremner  writes:
>
>> Alan Schmitt  writes:
>>
>>> Hello,
>>>
>>> On 2021-06-01 15:33, David Bremner  writes:
>>>
> Is this a bug of notmuch-emacs? Is there a way to display a single
> message independently of its context?
>

 I'm not sure what the best UI is, but here is a start:

 (defun notmuch-show-single-message (query)
   (interactive "sQuery: ")
   (message query)
   (let ((notmuch-show-indent-messages-width 0)
 (notmuch-show-only-matching-messages t))
 (notmuch-show query)))
>>>
>>> Thank you for the suggestion, unfortunately I get a very similar error.
>>> I found the id of the message I want, and when I run this function, I
>>> get this backtrace.
>>>
>>
>> The code I posted worked fine for me for one message from a thread of
>> 323 messages. It could be a I need a really giant thread to test, or
>> perhaps the structure of the individual messages matters also. The long
>> threads I have are from Debian mailing lists, so the message structure
>> tests to be be mainly one part of plain text.
>
> I played with this some more, and I think I understand what the issue
> is, although I still cannot duplicate the crash.  By unless given the

max-lisp-eval-depth is a variable defined in ‘C source code’.
Its value is 800

Started second emacs, tried to set max-lisp-eval-depth to 10 
(changed to 100, cannot go lower) then run notmuch 
(ya! you can do that -- no go w/ vm or gnus!) .
I have too short threads to get that crashing :/ but perhaps
someone else(tm) is luckier... ;/

Tomi


> "--part" option the CLI returns the whole thread structure, even if it
> does not populate it. So there is a big tree of empty lists, and
> recursively traversing this tree is what is crashing.  In principle
> passing "--part=0" to the CLI should turn off this behaviour, but I
> don't know how much needs to be changed on the emacs side to display the
> result properly.
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: [PATCH] emacs: PATCH [1/2] mail user agent

2021-06-02 Thread Tomi Ollila
On Mon, May 31 2021, David Bremner wrote:

> Tomi Ollila  writes:
>>
>> I am for 'ripping the bandage off' and not configure mail-user-agent
>> outside of notmuch use (and just require 'notmuch would not set anything...)
>>
>> Could we have some 'compose-mail' variant (different name, of course;
>> I had one in mind but then came off-by one problem... >;) which 
>> configures mail-user-agent just for that use (or something).
>>
>
> Are you thinking about notmuch-mua-mail (which exists)?
>
> Tory, did you try the eval-after-load trick I mentioned btw? That seemed
> to work in my testing, and I'm just not sure that customizing a
> notmuch-* variable is much less annoying than adding an eval-after-load to
> reset the variable after notmuch messes with it.
>
> Still waiting for feedback from notmuch users that actually use M-x
> compose-mail or other similar generic entry points.

Does anyone know how compose-mail behaves when one has loaded any other
emacs mua (mh, vm, gnus, mu, ...) ?

>
> d

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


Re: [PATCH] emacs: remap send-message and send-message-and-exit

2021-06-02 Thread Tomi Ollila
On Tue, Jun 01 2021, e...@edef.eu wrote:

> All three of C-c C-c,   ,
> and   are bound to message-send-and-exit by
> message.el, but notmuch-mua.el only had an explicit override for the
> keyboard binding. This mostly manifests as confusing Fcc behaviour for
> GUI users.
>
> Patching the bindings for specific keys is rather brittle, since it has
> to be aware of every relevant binding. This patch switches to instead

After committed to repo this is no longer 'patch'. Simple change
is to use 'commit', 'change', 'changeset' -- alternative is not
to write 'This ...' but reword...

> using a remap binding, which turns any binding for message-send or
> message-send-and-exit into a binding for the corresponding notmuch-mua
> command.
> ---
> The previous patch managed to *disappear* the menu item, but while
> figuring out how to make that work correctly, I happened upon a much
> simpler and less brittle solution.
>
>  emacs/notmuch-mua.el | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el
> index bbf059a2..8572aa1b 100644
> --- a/emacs/notmuch-mua.el
> +++ b/emacs/notmuch-mua.el
> @@ -341,8 +341,8 @@ Typically this is added to `notmuch-mua-send-hook'."
>  
>  (defvar notmuch-message-mode-map
>(let ((map (make-sparse-keymap)))
> -(define-key map (kbd "C-c C-c") #'notmuch-mua-send-and-exit)
> -(define-key map (kbd "C-c C-s") #'notmuch-mua-send)
> +(define-key map [remap message-send-and-exit] 'notmuch-mua-send-and-exit)
> +(define-key map [remap message-send] 'notmuch-mua-send)

where did the # characters disappear here ?

afaic #' is the recommended way here...

>  (define-key map (kbd "C-c C-p") #'notmuch-draft-postpone)
>  (define-key map (kbd "C-x C-s") #'notmuch-draft-save)
>  map)
> -- 
> 2.31.1

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


Re: [PATCH] NEWS/emacs: document changes in 0.32 that affect keybindings.

2021-05-28 Thread Tomi Ollila
On Thu, May 27 2021, Daniel Kahn Gillmor wrote:

> On Thu 2021-05-27 20:11:13 +0300, Tomi Ollila wrote:
>> On Thu, May 27 2021, Daniel Kahn Gillmor wrote:
>>> +Keymaps are no longer fset, which means they need to be referred to in
>>> +define-key directly (without quotes).  If your ~/.emacs has a
>>
>> In our docs it would be better to refer ~/.emacs.d/notmuch-config.el (?) :D
>
> Interesting, that's not where my notmuch-emacs config is located but i
> certainly have no objection to the proposed revision.

loading of .emacs.d/notmuch-config.el (notmuch-init-file) was added to 
notmuch.el in this commit: 
31fc76b78 emacs/notmuch.el (Tomi Ollila  2014-03-29 10:07:59 +0200)

When it is mentioned in our dox users have better change to know it,
and choose the most appropriate places for their notmuch configurations.

(I personally have (autoload 'notmuch "notmuch" "Notmuch mail" t) in
git repo which contains emacs configuration. There is also
'user-notmuch.el' which has "common" notmuch configurations cloned
everywhere. ~/emacs.d/notmuch-config.el starts with (load "user-notmuch"),
and then continues with site-specific configuration).

>
>   --dkg

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


Re: [PATCH] NEWS/emacs: document changes in 0.32 that affect keybindings.

2021-05-27 Thread Tomi Ollila
On Thu, May 27 2021, Daniel Kahn Gillmor wrote:

> See list discussion in thread starting with
> id:87h7ip2baq@fifthhorseman.net for more details.
>
> Signed-off-by: Daniel Kahn Gillmor 
> ---
>  NEWS | 7 +++
>  1 file changed, 7 insertions(+)
>
> diff --git a/NEWS b/NEWS
> index c0ae6afe..c3ca1085 100644
> --- a/NEWS
> +++ b/NEWS
> @@ -101,6 +101,13 @@ Removed, inlined or renamed functions and variables:
>  `notmuch-sexp-eof`, `notmuch-split-content-type`, and
>  `notmuch-tree-button-activate`.
>  
> +Keymaps are no longer fset, which means they need to be referred to in
> +define-key directly (without quotes).  If your ~/.emacs has a

In our docs it would be better to refer ~/.emacs.d/notmuch-config.el (?) :D

Tomi


> +keybinding like:
> +   (define-key 'notmuch-show-mode-map "7" 'foo)
> +you should change it to:
> +   (define-key notmuch-show-mode-map "7" 'foo)
> +
>  Notmuch 0.31.4 (2021-02-18)
>  ===
>  
> -- 
> 2.30.2
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: [PATCH] emacs: use new face for notmuch-jump and related

2021-05-25 Thread Tomi Ollila
On Fri, May 21 2021, Protesilaos Stavrou wrote:

> The minibuffer-prompt face that was used before made it impossible to
> differentiate between two distinct UI elements: (i) the prompt's text
> which itself cannot be acted upon, (ii) the actionable keys used to
> jump to searches/tags.
>
> The use of a named face, notmuch-jump-key, makes it possible for users
> or theme developers to apply properties that are specific to each of
> those two cases.
>
> In the interest of backward compatibility, the new face inherits from
> minibuffer-prompt.

This looks like a good change. How does one test this
and see the difference?

Tomi

> ---
>  NEWS  | 4 
>  emacs/notmuch-jump.el | 9 +++--
>  2 files changed, 11 insertions(+), 2 deletions(-)
>
> diff --git a/NEWS b/NEWS
> index c0ae6afe..83e42b44 100644
> --- a/NEWS
> +++ b/NEWS
> @@ -29,6 +29,10 @@ Emacs
>  Restore the dynamically bound variables `tag-changes` and `query` in
>  in `notmuch-before-tag-hook` and `notmuch-after-tag-hook`.
>  
> +Add `notmuch-jump-key` face to fontify keys in `notmuch-jump` and
> +related functions.  To ensure backward compatibility, the new face
> +inherits from `minibuffer-prompt`.
> +
>  Notmuch 0.32 (2021-05-02)
>  =
>  
> diff --git a/emacs/notmuch-jump.el b/emacs/notmuch-jump.el
> index 6fab5a79..e228c8a2 100644
> --- a/emacs/notmuch-jump.el
> +++ b/emacs/notmuch-jump.el
> @@ -62,6 +62,11 @@ (defun notmuch-jump-search ()
>(error "To use notmuch-jump, %s"
>"please customize shortcut keys in notmuch-saved-searches."
>  
> +(defface notmuch-jump-key
> +  '((t :inherit minibuffer-prompt))
> +  "Default face used for keys in `notmuch-jump' and related."
> +  :group 'notmuch-faces)
> +
>  (defvar notmuch-jump--action nil)
>  
>  ;;;###autoload
> @@ -88,7 +93,7 @@ (defun notmuch-jump (action-map prompt)
>   (buffer-string)))
>(full-prompt
> (concat table "\n\n"
> -   (propertize prompt 'face 'minibuffer-prompt)))
> +   (propertize prompt 'face 'notmuch-jump-key)))
>;; By default, the minibuffer applies the minibuffer face to
>;; the entire prompt.  However, we want to clearly
>;; distinguish bindings (which we put in the prompt face
> @@ -123,7 +128,7 @@ (defun notmuch-jump--format-actions (action-map)
>  ;; Format each action
>  (mapcar (pcase-lambda (`(,key ,desc))
> (setq key (format-kbd-macro key))
> -   (concat (propertize key 'face 'minibuffer-prompt)
> +   (concat (propertize key 'face 'notmuch-jump-key)
> (make-string (- key-width (length key)) ? )
> " " desc))
>   action-map)))
> -- 
> 2.31.1
>
>
>
> -- 
> Protesilaos Stavrou
> https://protesilaos.com
> ___
> notmuch mailing list -- notmuch@notmuchmail.org
> To unsubscribe send an email to notmuch-le...@notmuchmail.org
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: [PATCH 1/2] make _alloc_notmuch static

2021-05-24 Thread Tomi Ollila
On Sun, May 23 2021, David Bremner wrote:

> It is not used outside this file, so being extern seems like an oversight
> ---
>  lib/open.cc | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/lib/open.cc b/lib/open.cc
> index 1ca69665..bf166e15 100644
> --- a/lib/open.cc
> +++ b/lib/open.cc
> @@ -242,7 +242,7 @@ _choose_database_path (void *ctx,
>  return NOTMUCH_STATUS_SUCCESS;
>  }
>  
> -notmuch_database_t *
> +static notmuch_database_t *
>  _alloc_notmuch ()
>  {
>  notmuch_database_t *notmuch;

could also add static to _maybe_load_config_from_database()
in the same file (open.cc) and to
_notmuch_message_remove_indexed_terms() in message.cc
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: [PATCH] configure: $(CC) -o /dev/null when output not run

2021-05-23 Thread Tomi Ollila
On Sat, May 22 2021, David Bremner wrote:

> Tomi Ollila  writes:
>
>> When C compilation is used just to see whether compilation
>> succeeds, there is no need to write any output file.
>>
>> Some compilations in configure already did this.
>>
>> Now also rm -f lines are used more consistently.
>>
>> While at it reformatted code that prints
>> LIBNOTMUCH_{MAJOR,MINOR,MICRO}_VERSION).
>
> no objection in principle, but has anyone tried a compiler other than
> gcc to make sure it doesn't puke when writing to /dev/null. Not sure
> why it would, but...

I gave it some thought and was sure there would be no such case...

But now that I tested with 'zig cc' -- it apparently tries to remove
the target file before recreating and fails with accessDenied if cannot
(or, hopefully it just checks permissions, as removing /dev/null as
root would be nasty...)

Too bad, I had some plans that this change would have helped but...

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


[PATCH v2] test: source $NOTMUCH_SRCDIR/test/test-lib-emacs.sh

2021-05-23 Thread Tomi Ollila
Sourcing test-lib.sh will cd to TMP_DIRECTORY, so
relative path in $0 will not work in previous version
 . $(dirname "$0")/test-lib-emacs.sh

Now individual test scripts -- e.g. ./test/T310-emacs.sh
will work.
---

s/_BUILDD/_SRCD/ to id:20210522152741.27213-1-tomi.oll...@iki.fi

now works with in-tree and out-of-tree builds.

 test/T160-json.sh  | 2 +-
 test/T170-sexp.sh  | 2 +-
 test/T310-emacs.sh | 2 +-
 test/T320-emacs-large-search-buffer.sh | 2 +-
 test/T330-emacs-subject-to-filename.sh | 2 +-
 test/T350-crypto.sh| 2 +-
 test/T355-smime.sh | 2 +-
 test/T357-index-decryption.sh  | 2 +-
 test/T358-emacs-protected-headers.sh   | 2 +-
 test/T420-emacs-test-functions.sh  | 2 +-
 test/T430-emacs-address-cleaning.sh| 2 +-
 test/T440-emacs-hello.sh   | 2 +-
 test/T450-emacs-show.sh| 2 +-
 test/T455-emacs-charsets.sh| 2 +-
 test/T460-emacs-tree.sh| 2 +-
 test/T510-thread-replies.sh| 2 +-
 test/T630-emacs-draft.sh   | 2 +-
 test/T720-emacs-attachment-warnings.sh | 2 +-
 test/T730-emacs-forwarding.sh  | 2 +-
 19 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/test/T160-json.sh b/test/T160-json.sh
index 638afb4d..9b3bc676 100755
--- a/test/T160-json.sh
+++ b/test/T160-json.sh
@@ -1,7 +1,7 @@
 #!/usr/bin/env bash
 test_description="--format=json output"
 . $(dirname "$0")/test-lib.sh || exit 1
-. $(dirname "$0")/test-lib-emacs.sh || exit 1
+.  $NOTMUCH_SRCDIR/test/test-lib-emacs.sh || exit 1
 
 test_begin_subtest "Show message: json"
 add_message "[subject]=\"json-show-subject\"" "[date]=\"Sat, 01 Jan 2000 
12:00:00 -\"" "[bcc]=\"test_suite+...@notmuchmail.org\"" 
"[reply-to]=\"test_suite+repl...@notmuchmail.org\"" 
"[body]=\"json-show-message\""
diff --git a/test/T170-sexp.sh b/test/T170-sexp.sh
index af8c4b44..94648d49 100755
--- a/test/T170-sexp.sh
+++ b/test/T170-sexp.sh
@@ -1,7 +1,7 @@
 #!/usr/bin/env bash
 test_description="--format=sexp output"
 . $(dirname "$0")/test-lib.sh || exit 1
-. $(dirname "$0")/test-lib-emacs.sh || exit 1
+. $NOTMUCH_SRCDIR/test/test-lib-emacs.sh || exit 1
 
 test_begin_subtest "Show message: sexp"
 add_message "[subject]=\"sexp-show-subject\"" "[date]=\"Sat, 01 Jan 2000 
12:00:00 -\"" "[bcc]=\"test_suite+...@notmuchmail.org\"" 
"[reply-to]=\"test_suite+repl...@notmuchmail.org\"" 
"[body]=\"sexp-show-message\""
diff --git a/test/T310-emacs.sh b/test/T310-emacs.sh
index 1ece6e00..8f114571 100755
--- a/test/T310-emacs.sh
+++ b/test/T310-emacs.sh
@@ -2,7 +2,7 @@
 
 test_description="emacs interface"
 . $(dirname "$0")/test-lib.sh || exit 1
-. $(dirname "$0")/test-lib-emacs.sh || exit 1
+. $NOTMUCH_SRCDIR/test/test-lib-emacs.sh || exit 1
 
 EXPECTED=$NOTMUCH_SRCDIR/test/emacs.expected-output
 
diff --git a/test/T320-emacs-large-search-buffer.sh 
b/test/T320-emacs-large-search-buffer.sh
index d2638c8b..9c42e7f1 100755
--- a/test/T320-emacs-large-search-buffer.sh
+++ b/test/T320-emacs-large-search-buffer.sh
@@ -1,7 +1,7 @@
 #!/usr/bin/env bash
 test_description="Emacs with large search results buffer"
 . $(dirname "$0")/test-lib.sh || exit 1
-. $(dirname "$0")/test-lib-emacs.sh || exit 1
+. $NOTMUCH_SRCDIR/test/test-lib-emacs.sh || exit 1
 
 x=xx # 10
 x=$x$x$x$x$x$x$x$x$x$x # 100
diff --git a/test/T330-emacs-subject-to-filename.sh 
b/test/T330-emacs-subject-to-filename.sh
index 6e09a048..b55566bf 100755
--- a/test/T330-emacs-subject-to-filename.sh
+++ b/test/T330-emacs-subject-to-filename.sh
@@ -2,7 +2,7 @@
 
 test_description="emacs: mail subject to filename"
 . $(dirname "$0")/test-lib.sh || exit 1
-. $(dirname "$0")/test-lib-emacs.sh || exit 1
+. $NOTMUCH_SRCDIR/test/test-lib-emacs.sh || exit 1
 
 test_require_emacs
 
diff --git a/test/T350-crypto.sh b/test/T350-crypto.sh
index 4508c984..3bcf1488 100755
--- a/test/T350-crypto.sh
+++ b/test/T350-crypto.sh
@@ -6,7 +6,7 @@
 
 test_description='PGP/MIME signature verification and decryption'
 . $(dirname "$0")/test-lib.sh || exit 1
-. $(dirname "$0")/test-lib-emacs.sh || exit 1
+. $NOTMUCH_SRCDIR/test/test-lib-emacs.sh || exit 1
 
 ##
 
diff --git a/test/T355-smime.sh b/test/T355-smime.sh
index 69bdcfac..7fa9d337 100755
--- a/test/T355-smime.sh
+++ b/test/T355-smime.sh
@@ -2,7 +2,7 @@
 
 test_description='S/MIME signature verification and decryption'
 . $(dirname "$0")/test-lib.sh || exit 1
-. $(dirname "$0")/test-lib-emacs.sh || exit 1
+. $NOTMUCH_SRCDIR/test/test-lib-emacs.sh || exit 1
 
 test_require_emacs
 test_require_external_prereq openssl
diff --git a/test/T357-index-decryption.sh b/test/T357-index-decryption.sh
index 0d30e566..7b5f13db 100755
--- a/test/T357-index-decryption.sh
+++ b/test/T357-index-decryption.sh
@@ -4,7 +4,7 @@
 
 test_description='indexing decrypted mail'
 . $(dirname "$0")/test-lib.sh || exit 1
-. $(dirname "$0")/test-lib-emacs.sh 

Re: [PATCH] test: say_color() in one write(2)

2021-05-23 Thread Tomi Ollila
On Sat, May 22 2021, David Bremner wrote:

> Tomi Ollila  writes:
>
>> say_color() used to call (builtin) printf (and tput(1) to stdout)
>> several times, which caused attempts to write messages with color
>> to have partial content (e.g. escape sequences) often intermixed
>> with other tests when parallel tests were run.
>
> I still see things like:
>
> T568-lib-thread: Testing API tests for notmuch_thread_*
>  PASS   PASS   count messages on closed db
>  get indexopts from closed database
>
> Is that expected? Both "PASS" are coloured OK.

Yes, that is (unfortunately) possible, say_color only writes that PASS
(with escape sequences coloring and reseting around it) (and subtest
message if $debug is set). The messages following are written in separate
lines, after say_color() returns (echo's if I remember correctly).

Much more overhaul would be required to get the full line written in
one write(1) -- I did think a few options when doing that change but
nothing seems clear enough at this moment...

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


Re: [PATCH] test: source $NOTMUCH_BUILDDIR/test/test-lib-emacs.sh

2021-05-22 Thread Tomi Ollila
On Sat, May 22 2021, Tomi Ollila wrote:

> Sourcing test-lib.sh will cd to TMP_DIRECTORY, so
> relative path in $0 will not work in previous version
>  . $(dirname "$0")/test-lib-emacs.sh
>
> Now individual test scripts -- e.g. ./test/T310-emacs.sh
> will work.
> ---
>  test/T160-json.sh  | 2 +-
>  test/T170-sexp.sh  | 2 +-
>  test/T310-emacs.sh | 2 +-
>  test/T320-emacs-large-search-buffer.sh | 2 +-
>  test/T330-emacs-subject-to-filename.sh | 2 +-
>  test/T350-crypto.sh| 2 +-
>  test/T355-smime.sh | 2 +-
>  test/T357-index-decryption.sh  | 2 +-
>  test/T358-emacs-protected-headers.sh   | 2 +-
>  test/T420-emacs-test-functions.sh  | 2 +-
>  test/T430-emacs-address-cleaning.sh| 2 +-
>  test/T440-emacs-hello.sh   | 2 +-
>  test/T450-emacs-show.sh| 2 +-
>  test/T455-emacs-charsets.sh| 2 +-
>  test/T460-emacs-tree.sh| 2 +-
>  test/T510-thread-replies.sh| 2 +-
>  test/T630-emacs-draft.sh   | 2 +-
>  test/T720-emacs-attachment-warnings.sh | 2 +-
>  test/T730-emacs-forwarding.sh  | 2 +-
>  19 files changed, 19 insertions(+), 19 deletions(-)
>
> diff --git a/test/T160-json.sh b/test/T160-json.sh
> index 638afb4d..9b3bc676 100755
> --- a/test/T160-json.sh
> +++ b/test/T160-json.sh
> @@ -1,7 +1,7 @@
>  #!/usr/bin/env bash
>  test_description="--format=json output"
>  . $(dirname "$0")/test-lib.sh || exit 1
> -. $(dirname "$0")/test-lib-emacs.sh || exit 1
> +.  $NOTMUCH_BUILDDIR/test/test-lib-emacs.sh || exit 1

Too hastily posted; tested that this worked when did in-tree
build, so failed to notice that this should be $NOTMUCH_SRCDIR

-- will test later -- first sed -i s/_BUILDD/_SRCD/ to the
patch file, then apply patch and finally run tests in both
in-tree and out of tree builds...

Tomi


>  
>  test_begin_subtest "Show message: json"
>  add_message "[subject]=\"json-show-subject\"" "[date]=\"Sat, 01 Jan 2000 
> 12:00:00 -\"" "[bcc]=\"test_suite+...@notmuchmail.org\"" 
> "[reply-to]=\"test_suite+repl...@notmuchmail.org\"" 
> "[body]=\"json-show-message\""
> diff --git a/test/T170-sexp.sh b/test/T170-sexp.sh
> index af8c4b44..94648d49 100755
> --- a/test/T170-sexp.sh
> +++ b/test/T170-sexp.sh
> @@ -1,7 +1,7 @@
>  #!/usr/bin/env bash
>  test_description="--format=sexp output"
>  . $(dirname "$0")/test-lib.sh || exit 1
> -. $(dirname "$0")/test-lib-emacs.sh || exit 1
> +. $NOTMUCH_BUILDDIR/test/test-lib-emacs.sh || exit 1
>  
>  test_begin_subtest "Show message: sexp"
>  add_message "[subject]=\"sexp-show-subject\"" "[date]=\"Sat, 01 Jan 2000 
> 12:00:00 -\"" "[bcc]=\"test_suite+...@notmuchmail.org\"" 
> "[reply-to]=\"test_suite+repl...@notmuchmail.org\"" 
> "[body]=\"sexp-show-message\""
> diff --git a/test/T310-emacs.sh b/test/T310-emacs.sh
> index 1ece6e00..8f114571 100755
> --- a/test/T310-emacs.sh
> +++ b/test/T310-emacs.sh
> @@ -2,7 +2,7 @@
>  
>  test_description="emacs interface"
>  . $(dirname "$0")/test-lib.sh || exit 1
> -. $(dirname "$0")/test-lib-emacs.sh || exit 1
> +. $NOTMUCH_BUILDDIR/test/test-lib-emacs.sh || exit 1
>  
>  EXPECTED=$NOTMUCH_SRCDIR/test/emacs.expected-output
>  
> diff --git a/test/T320-emacs-large-search-buffer.sh 
> b/test/T320-emacs-large-search-buffer.sh
> index d2638c8b..9c42e7f1 100755
> --- a/test/T320-emacs-large-search-buffer.sh
> +++ b/test/T320-emacs-large-search-buffer.sh
> @@ -1,7 +1,7 @@
>  #!/usr/bin/env bash
>  test_description="Emacs with large search results buffer"
>  . $(dirname "$0")/test-lib.sh || exit 1
> -. $(dirname "$0")/test-lib-emacs.sh || exit 1
> +. $NOTMUCH_BUILDDIR/test/test-lib-emacs.sh || exit 1
>  
>  x=xx # 10
>  x=$x$x$x$x$x$x$x$x$x$x # 100
> diff --git a/test/T330-emacs-subject-to-filename.sh 
> b/test/T330-emacs-subject-to-filename.sh
> index 6e09a048..b55566bf 100755
> --- a/test/T330-emacs-subject-to-filename.sh
> +++ b/test/T330-emacs-subject-to-filename.sh
> @@ -2,7 +2,7 @@
>  
>  test_description="emacs: mail subject to filename"
>  . $(dirname "$0")/test-lib.sh || exit 1
> -. $(dirname "$0")/test-lib-emacs.sh || exit 1
> +. $NOTMUCH_BUILDDIR/test/test-lib-emacs.sh || exit 1
>  
>  test_require_emacs
>  
> diff --git a/test/T350-crypto.sh b

[PATCH] test: source $NOTMUCH_BUILDDIR/test/test-lib-emacs.sh

2021-05-22 Thread Tomi Ollila
Sourcing test-lib.sh will cd to TMP_DIRECTORY, so
relative path in $0 will not work in previous version
 . $(dirname "$0")/test-lib-emacs.sh

Now individual test scripts -- e.g. ./test/T310-emacs.sh
will work.
---
 test/T160-json.sh  | 2 +-
 test/T170-sexp.sh  | 2 +-
 test/T310-emacs.sh | 2 +-
 test/T320-emacs-large-search-buffer.sh | 2 +-
 test/T330-emacs-subject-to-filename.sh | 2 +-
 test/T350-crypto.sh| 2 +-
 test/T355-smime.sh | 2 +-
 test/T357-index-decryption.sh  | 2 +-
 test/T358-emacs-protected-headers.sh   | 2 +-
 test/T420-emacs-test-functions.sh  | 2 +-
 test/T430-emacs-address-cleaning.sh| 2 +-
 test/T440-emacs-hello.sh   | 2 +-
 test/T450-emacs-show.sh| 2 +-
 test/T455-emacs-charsets.sh| 2 +-
 test/T460-emacs-tree.sh| 2 +-
 test/T510-thread-replies.sh| 2 +-
 test/T630-emacs-draft.sh   | 2 +-
 test/T720-emacs-attachment-warnings.sh | 2 +-
 test/T730-emacs-forwarding.sh  | 2 +-
 19 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/test/T160-json.sh b/test/T160-json.sh
index 638afb4d..9b3bc676 100755
--- a/test/T160-json.sh
+++ b/test/T160-json.sh
@@ -1,7 +1,7 @@
 #!/usr/bin/env bash
 test_description="--format=json output"
 . $(dirname "$0")/test-lib.sh || exit 1
-. $(dirname "$0")/test-lib-emacs.sh || exit 1
+.  $NOTMUCH_BUILDDIR/test/test-lib-emacs.sh || exit 1
 
 test_begin_subtest "Show message: json"
 add_message "[subject]=\"json-show-subject\"" "[date]=\"Sat, 01 Jan 2000 
12:00:00 -\"" "[bcc]=\"test_suite+...@notmuchmail.org\"" 
"[reply-to]=\"test_suite+repl...@notmuchmail.org\"" 
"[body]=\"json-show-message\""
diff --git a/test/T170-sexp.sh b/test/T170-sexp.sh
index af8c4b44..94648d49 100755
--- a/test/T170-sexp.sh
+++ b/test/T170-sexp.sh
@@ -1,7 +1,7 @@
 #!/usr/bin/env bash
 test_description="--format=sexp output"
 . $(dirname "$0")/test-lib.sh || exit 1
-. $(dirname "$0")/test-lib-emacs.sh || exit 1
+. $NOTMUCH_BUILDDIR/test/test-lib-emacs.sh || exit 1
 
 test_begin_subtest "Show message: sexp"
 add_message "[subject]=\"sexp-show-subject\"" "[date]=\"Sat, 01 Jan 2000 
12:00:00 -\"" "[bcc]=\"test_suite+...@notmuchmail.org\"" 
"[reply-to]=\"test_suite+repl...@notmuchmail.org\"" 
"[body]=\"sexp-show-message\""
diff --git a/test/T310-emacs.sh b/test/T310-emacs.sh
index 1ece6e00..8f114571 100755
--- a/test/T310-emacs.sh
+++ b/test/T310-emacs.sh
@@ -2,7 +2,7 @@
 
 test_description="emacs interface"
 . $(dirname "$0")/test-lib.sh || exit 1
-. $(dirname "$0")/test-lib-emacs.sh || exit 1
+. $NOTMUCH_BUILDDIR/test/test-lib-emacs.sh || exit 1
 
 EXPECTED=$NOTMUCH_SRCDIR/test/emacs.expected-output
 
diff --git a/test/T320-emacs-large-search-buffer.sh 
b/test/T320-emacs-large-search-buffer.sh
index d2638c8b..9c42e7f1 100755
--- a/test/T320-emacs-large-search-buffer.sh
+++ b/test/T320-emacs-large-search-buffer.sh
@@ -1,7 +1,7 @@
 #!/usr/bin/env bash
 test_description="Emacs with large search results buffer"
 . $(dirname "$0")/test-lib.sh || exit 1
-. $(dirname "$0")/test-lib-emacs.sh || exit 1
+. $NOTMUCH_BUILDDIR/test/test-lib-emacs.sh || exit 1
 
 x=xx # 10
 x=$x$x$x$x$x$x$x$x$x$x # 100
diff --git a/test/T330-emacs-subject-to-filename.sh 
b/test/T330-emacs-subject-to-filename.sh
index 6e09a048..b55566bf 100755
--- a/test/T330-emacs-subject-to-filename.sh
+++ b/test/T330-emacs-subject-to-filename.sh
@@ -2,7 +2,7 @@
 
 test_description="emacs: mail subject to filename"
 . $(dirname "$0")/test-lib.sh || exit 1
-. $(dirname "$0")/test-lib-emacs.sh || exit 1
+. $NOTMUCH_BUILDDIR/test/test-lib-emacs.sh || exit 1
 
 test_require_emacs
 
diff --git a/test/T350-crypto.sh b/test/T350-crypto.sh
index 4508c984..3bcf1488 100755
--- a/test/T350-crypto.sh
+++ b/test/T350-crypto.sh
@@ -6,7 +6,7 @@
 
 test_description='PGP/MIME signature verification and decryption'
 . $(dirname "$0")/test-lib.sh || exit 1
-. $(dirname "$0")/test-lib-emacs.sh || exit 1
+. $NOTMUCH_BUILDDIR/test/test-lib-emacs.sh || exit 1
 
 ##
 
diff --git a/test/T355-smime.sh b/test/T355-smime.sh
index 69bdcfac..7fa9d337 100755
--- a/test/T355-smime.sh
+++ b/test/T355-smime.sh
@@ -2,7 +2,7 @@
 
 test_description='S/MIME signature verification and decryption'
 . $(dirname "$0")/test-lib.sh || exit 1
-. $(dirname "$0")/test-lib-emacs.sh || exit 1
+. $NOTMUCH_BUILDDIR/test/test-lib-emacs.sh || exit 1
 
 test_require_emacs
 test_require_external_prereq openssl
diff --git a/test/T357-index-decryption.sh b/test/T357-index-decryption.sh
index 0d30e566..7b5f13db 100755
--- a/test/T357-index-decryption.sh
+++ b/test/T357-index-decryption.sh
@@ -4,7 +4,7 @@
 
 test_description='indexing decrypted mail'
 . $(dirname "$0")/test-lib.sh || exit 1
-. $(dirname "$0")/test-lib-emacs.sh || exit 1
+. $NOTMUCH_BUILDDIR/test/test-lib-emacs.sh || exit 1
 
 

[PATCH 1/2] test-lib-emacs: re-define test_emacs() after initialization

2021-05-22 Thread Tomi Ollila
After test_emacs() has started emacs, it re-defines
itself as just calling the started emacs.

First call to test_emacs() will execute to the end of it;
next calls will just execute the 2 lines, first clearing OUTPUT,
second and last executing TEST_EMACSCLIENT...

This simplifies away one if constructs and reduces xtrace
output when doing test debugging with set -x.
---

This has been laying around like 6 years, every now thinking whether
to post or not. Now needed to rebase so finally polished to a
sendable format. re-defining functions just may be too much
to understand (or not)...

 test/test-lib-emacs.sh | 79 +++---
 1 file changed, 43 insertions(+), 36 deletions(-)

diff --git a/test/test-lib-emacs.sh b/test/test-lib-emacs.sh
index dde32177..b2b490be 100644
--- a/test/test-lib-emacs.sh
+++ b/test/test-lib-emacs.sh
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2010-2020 Notmuch Developers
+# Copyright (c) 2010-2021 Notmuch Developers
 #
 # 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
@@ -166,44 +166,51 @@ EOF
 }
 
 test_emacs () {
-   # test dependencies beforehand to avoid the waiting loop below
+   # Note: This test_emacs() is re-defined after emacs started below.
test_require_emacs || return
 
-   if [ -z "$EMACS_SERVER" ]; then
-   emacs_tests="$NOTMUCH_SRCDIR/test/${this_test_bare}.el"
-   if [ -f "$emacs_tests" ]; then
-   load_emacs_tests="--eval '(load \"$emacs_tests\")'"
-   else
-   load_emacs_tests=
-   fi
-   server_name="notmuch-test-suite-$$"
-   # start a detached session with an emacs server
-   # user's TERM (or 'vt100' in case user's TERM is known dumb
-   # or unknown) is given to dtach which assumes a minimally
-   # VT100-compatible terminal -- and emacs inherits that
-   TERM=$SMART_TERM dtach -n "$TEST_TMPDIR/emacs-dtach-socket.$$" \
-   sh -c "stty rows 24 cols 80; exec 
'$TMP_DIRECTORY/run_emacs' \
-   --no-window-system \
-   $load_emacs_tests \
-   --eval '(setq server-name \"$server_name\")' \
-   --eval '(server-start)' \
-   --eval '(orphan-watchdog $$)'" || return
-   EMACS_SERVER="$server_name"
-   # wait until the emacs server is up
-   until test_emacs '()' >/dev/null 2>/dev/null; do
-   sleep 1
-   done
-   fi
+   local emacs_tests load_emacs_tests server_name
 
-   # Clear test-output output file.  Most Emacs tests end with a
-   # call to (test-output).  If the test code fails with an
-   # exception before this call, the output file won't get
-   # updated.  Since we don't want to compare against an output
-   # file from another test, so start out with an empty file.
-   rm -f OUTPUT
-   touch OUTPUT
-
-   ${TEST_EMACSCLIENT} --socket-name="$EMACS_SERVER" --eval 
"(notmuch-test-progn $*)"
+   emacs_tests=$NOTMUCH_SRCDIR/test/${this_test_bare}.el
+   if [ -f "$emacs_tests" ]; then
+   load_emacs_tests="--eval '(load \"$emacs_tests\")'"
+   else
+   load_emacs_tests=
+   fi
+   server_name=notmuch-test-suite-$$
+   # start a detached session with an emacs server
+   # user's TERM (or 'vt100' in case user's TERM is known dumb
+   # or unknown) is given to dtach which assumes a minimally
+   # VT100-compatible terminal -- and emacs inherits that
+   TERM=$SMART_TERM dtach -n "$TEST_TMPDIR/emacs-dtach-socket.$$" \
+   sh -c "stty rows 24 cols 80; exec '$TMP_DIRECTORY/run_emacs' \
+   --no-window-system \
+   $load_emacs_tests \
+   --eval '(setq server-name \"$server_name\")' \
+   --eval '(server-start)' \
+   --eval '(orphan-watchdog $$)'" || return
+
+   EMACS_SERVER=$server_name
+
+   # re-define test_emacs() -- further calls will use this one
+   test_emacs () {
+   # Clear test-output output file.  Most Emacs tests end with a
+   # call to (test-output).  If the test code fails with an
+   # exception before this call, the output file won't get
+   # updated.  Since we don't want to compare against an output
+   # file from another test, so start out with an empty file.
+   : > OUTPUT
+   ${TEST_EMACSCLIENT} --socket-name="$EMACS_SERVER" \
+   --eval "(notmuch-test-progn $*)"
+   }
+
+   # wait until the emacs server is up (now calling "new" test_emacs())
+   until test_emacs '()' >/dev/null 2>/dev/null; do
+ 

[PATCH v5] test: replace notmuch_passwd_sanitize() with _libconfig_sanitize()

2021-05-22 Thread Tomi Ollila
notmuch_passwd_sanitize() in test-lib.sh is too generic, it cannot
work in many cases...

The more specific version _libconfig_sanitize() replaces it in
T590-libconfig.sh and the code that uses it is modified to output
the keys (ascending numbers printed in hex) so the sanitizer knows
what to sanitize in which lines...

"@" + fqdn -> "@FQDN" replacement is used as fqdn could
-- in theory -- be substring of 'USERNAME'.

'user -> 'USER_FULL_NAME replacement to work in cases where user
is empty -- as only first ' is replaced that works as expected.

In addition to ".(none)" now also ".localdomain" is filtered from
USERNAME@FQDN.

/dev/fd/{n} is not defined in posix, but it is portable enough
(if it weren't it is easy to fix -- now code looks clearer).
---

Implemented David's suggestion in id:87sg2ft21p@tethera.net

I did have exactly the same thought, 2 decimal digits, but as
suggested and so easy to implement, did it now instead of
someone(tm) updating when need arises...

v4 in id:20210520134628.11653-1-tomi.oll...@iki.fi

 test/T590-libconfig.sh | 96 +-
 test/test-lib.sh   | 20 -
 2 files changed, 58 insertions(+), 58 deletions(-)

diff --git a/test/T590-libconfig.sh b/test/T590-libconfig.sh
index 745e1bb4..bc7298f8 100755
--- a/test/T590-libconfig.sh
+++ b/test/T590-libconfig.sh
@@ -5,6 +5,25 @@ test_description="library config API"
 
 add_email_corpus
 
+_libconfig_sanitize() {
+${NOTMUCH_PYTHON} /dev/fd/3 3<<'EOF'
+import os, sys, pwd, socket
+
+pw = pwd.getpwuid(os.getuid())
+user = pw.pw_name
+name = pw.pw_gecos.partition(",")[0]
+fqdn = socket.getaddrinfo(socket.gethostname(), 0, 0,
+  socket.SOCK_STREAM, 0, socket.AI_CANONNAME)[0][3]
+for l in sys.stdin:
+if l[:4] == "08: ":
+l = l.replace(user, "USERNAME", 1).replace("@" + fqdn, "@FQDN", 1)
+l = l.replace(".(none)", "", 1).replace(".localdomain", "", 1)
+elif l[:4] == "10: ":
+l = l.replace("'" + name, "'USER_FULL_NAME", 1)
+sys.stdout.write(l)
+EOF
+}
+
 cat < c_head
 #include 
 #include 
@@ -380,26 +399,26 @@ cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR} '' %NULL%
 key < NOTMUCH_CONFIG_LAST;
 key = (notmuch_config_key_t)(key + 1)) {
const char *val = notmuch_config_get (db, key);
-printf("%s\n", val ? val : "NULL" );
+   printf("%02d: '%s'\n", key, val ? val : "NULL" );
 }
 }
 EOF
 
-notmuch_passwd_sanitize < OUTPUT > OUTPUT.clean
+_libconfig_sanitize < OUTPUT > OUTPUT.clean
 
 cat <<'EOF' >EXPECTED
 == stdout ==
-MAIL_DIR
-MAIL_DIR
-MAIL_DIR/.notmuch/hooks
-MAIL_DIR/.notmuch/backups
-
-unread;inbox
-
-true
-USERNAME@FQDN
-NULL
-USER_FULL_NAME
+00: 'MAIL_DIR'
+01: 'MAIL_DIR'
+02: 'MAIL_DIR/.notmuch/hooks'
+03: 'MAIL_DIR/.notmuch/backups'
+04: ''
+05: 'unread;inbox'
+06: ''
+07: 'true'
+08: 'USERNAME@FQDN'
+09: 'NULL'
+10: 'USER_FULL_NAME'
 == stderr ==
 EOF
 unset MAILDIR
@@ -694,23 +713,23 @@ cat c_head2 - c_tail <<'EOF' | test_C ${MAIL_DIR} %NULL% 
%NULL%
 key < NOTMUCH_CONFIG_LAST;
 key = (notmuch_config_key_t)(key + 1)) {
const char *val = notmuch_config_get (db, key);
-printf("%s\n", val ? val : "NULL" );
+   printf("%x: '%s'\n", key, val ? val : "NULL" );
 }
 }
 EOF
 cat <<'EOF' >EXPECTED
 == stdout ==
-MAIL_DIR
-MAIL_DIR
-MAIL_DIR/.notmuch/hooks
-MAIL_DIR/.notmuch/backups
-foo;bar;fub
-unread;inbox
-sekrit_junk
-true
-test_su...@notmuchmail.org
-test_suite_ot...@notmuchmail.org;test_su...@otherdomain.org
-Notmuch Test Suite
+0: 'MAIL_DIR'
+1: 'MAIL_DIR'
+2: 'MAIL_DIR/.notmuch/hooks'
+3: 'MAIL_DIR/.notmuch/backups'
+4: 'foo;bar;fub'
+5: 'unread;inbox'
+6: 'sekrit_junk'
+7: 'true'
+8: 'test_su...@notmuchmail.org'
+9: 'test_suite_ot...@notmuchmail.org;test_su...@otherdomain.org'
+a: 'Notmuch Test Suite'
 == stderr ==
 EOF
 test_expect_equal_file EXPECTED OUTPUT
@@ -723,25 +742,26 @@ cat c_head2 - c_tail <<'EOF' | test_C ${MAIL_DIR} 
/nonexistent %NULL%
 key < NOTMUCH_CONFIG_LAST;
 key = (notmuch_config_key_t)(key + 1)) {
const char *val = notmuch_config_get (db, key);
-   printf("%s\n", val ? val : "NULL" );
+   printf("%02d: '%s'\n", key, val ? val : "NULL" );
 }
 }
 EOF
 
-notmuch_passwd_sanitize < OUTPUT > OUTPUT.clean
+_libconfig_sanitize < OUTPUT > OUTPUT.clean
+
 cat <<'EOF' >EXPECTED
 == stdout ==
-MAIL_DIR
-MAIL_DIR
-MAIL_DIR/.notmuch/hooks
-MAIL_DIR/.notmuch/backups
-
-unread;inbox
-
-true
-USERNAME@FQDN
-NULL
-USER_FULL_NAME
+00: 'MAIL_DIR'
+01: 'MAIL_DIR'
+02: 'MAIL_DIR/.notmuch/hooks'
+03: 'MAIL_DIR/.notmuch/backups'
+04: ''
+05: 'unread;inbox'
+06: ''
+07: 'true'
+08: 'USERNAME@FQDN'
+09: 'NULL'
+10: 'USER_FULL_NAME'
 == stderr ==
 EOF
 test_expect_equal_file EXPECTED OUTPUT.clean
diff --git a/test/test-lib.sh b/test/test-lib.sh
index 6be5d11f..35bea097 100644
--- a/test/test-lib.sh
+++ b/test/test-lib.sh
@@ -561,26 +561,6 @@ notmuch_built_with_sanitize () {
 sed 

Re: [PATCH] emacs: PATCH [1/2] mail user agent

2021-05-22 Thread Tomi Ollila
On Sat, May 22 2021, David Bremner wrote:

> web...@toryanderson.com (Tory S. Anderson) writes:
>
>>  
>> +(defcustom notmuch-mail-user-agent 'notmuch-user-agent
>> +  "The mail user-agent to use when creating mail after using Notmuch. For 
>> historical purposes, the default is 'notmuch-user-agent"
>> +  :group 'notmuch)
>>  ;;; Mime Utilities
>>  
>>  (defun notmuch-foreach-mime-part (function mm-handle)
>> @@ -1162,7 +1165,7 @@ Point should be at the beginning of the line."
>>  
>>  ;;; _
>>  
>> -(setq mail-user-agent 'notmuch-user-agent)
>> +(setq mail-user-agent notmuch-mail-user-agent)
>
> OK, I appreciate idea of a smooth upgrade for existing notmuch users. I
> wonder though if other emacs MUAs do this? I did not see e.g. a
> gnus-mail-user-agent variable. I'm probably biased because I never use
> compose-mail to send mail, but I'm wondering if we're better off to just
> rip the bandage off and let users who want to use notmuch via generic
> emacs mail sending commands configure that.

I am for 'ripping the bandage off' and not configure mail-user-agent
outside of notmuch use (and just require 'notmuch would not set anything...)

Could we have some 'compose-mail' variant (different name, of course;
I had one in mind but then came off-by one problem... >;) which 
configures mail-user-agent just for that use (or something).

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


[PATCH] configure: $(CC) -o /dev/null when output not run

2021-05-21 Thread Tomi Ollila
When C compilation is used just to see whether compilation
succeeds, there is no need to write any output file.

Some compilations in configure already did this.

Now also rm -f lines are used more consistently.

While at it reformatted code that prints
LIBNOTMUCH_{MAJOR,MINOR,MICRO}_VERSION).
---

Hmm, these
printf("libnotmuch_version_major=%d\n", LIBNOTMUCH_MAJOR_VERSION)
lines leaked into this commit. I've always wanted to make
this change (as it fits and looks clearer) but haven't found
good commit for that Now edited commit message to mention 
the change.

 configure | 57 ++-
 1 file changed, 23 insertions(+), 34 deletions(-)

diff --git a/configure b/configure
index cfa9c09b..e907c6fc 100755
--- a/configure
+++ b/configure
@@ -362,7 +362,7 @@ errors=0
 printf "int main(void){return 0;}\n" > minimal.c
 
 printf "Sanity checking C compilation environment... "
-test_cmdline="${CC} ${CFLAGS} ${CPPFLAGS} minimal.c ${LDFLAGS} -o minimal"
+test_cmdline="${CC} ${CFLAGS} ${CPPFLAGS} minimal.c ${LDFLAGS} -o /dev/null"
 if  ${test_cmdline} > /dev/null 2>&1
 then
 printf "OK.\n"
@@ -374,7 +374,7 @@ else
 fi
 
 printf "Sanity checking C++ compilation environment... "
-test_cmdline="${CXX} ${CXXFLAGS_for_sh} ${CPPFLAGS} minimal.c ${LDFLAGS} -o 
minimal"
+test_cmdline="${CXX} ${CXXFLAGS_for_sh} ${CPPFLAGS} minimal.c ${LDFLAGS} -o 
/dev/null"
 if ${test_cmdline} > /dev/null 2>&1
 then
 printf "OK.\n"
@@ -392,7 +392,7 @@ if [ $errors -gt 0 ]; then
 running configure in a clean environment, and if the problem persists,
 report a bug.
 EOF
-rm -f minimal minimal.c
+rm -f minimal.c
 exit 1
 fi
 
@@ -401,12 +401,9 @@ cat > _libversion.c <
 #include "lib/notmuch.h"
 int main(void) {
-printf("libnotmuch_version_major=%d\n",
-   LIBNOTMUCH_MAJOR_VERSION);
-printf("libnotmuch_version_minor=%d\n",
-   LIBNOTMUCH_MINOR_VERSION);
-printf("libnotmuch_version_release=%d\n",
-   LIBNOTMUCH_MICRO_VERSION);
+printf("libnotmuch_version_major=%d\n",LIBNOTMUCH_MAJOR_VERSION);
+printf("libnotmuch_version_minor=%d\n",LIBNOTMUCH_MINOR_VERSION);
+printf("libnotmuch_version_release=%d\n",  LIBNOTMUCH_MICRO_VERSION);
 return 0;
 }
 EOF
@@ -432,7 +429,6 @@ else
 fi
 
 
-
 printf "Checking for Xapian development files (>= 1.4.0)... "
 have_xapian=0
 for xapian_config in ${XAPIAN_CONFIG} xapian-config; do
@@ -1045,7 +1041,7 @@ EOF
 fi
 
 printf "Checking for canonicalize_file_name... "
-if ${CC} -o compat/have_canonicalize_file_name 
"$srcdir"/compat/have_canonicalize_file_name.c > /dev/null 2>&1
+if ${CC} -o /dev/null "$srcdir"/compat/have_canonicalize_file_name.c > 
/dev/null 2>&1
 then
 printf "Yes.\n"
 have_canonicalize_file_name=1
@@ -1053,11 +1049,9 @@ else
 printf "No (will use our own instead).\n"
 have_canonicalize_file_name=0
 fi
-rm -f compat/have_canonicalize_file_name
-
 
 printf "Checking for getline... "
-if ${CC} -o compat/have_getline "$srcdir"/compat/have_getline.c > /dev/null 
2>&1
+if ${CC} -o /dev/null "$srcdir"/compat/have_getline.c > /dev/null 2>&1
 then
 printf "Yes.\n"
 have_getline=1
@@ -1065,10 +1059,9 @@ else
 printf "No (will use our own instead).\n"
 have_getline=0
 fi
-rm -f compat/have_getline
 
 printf "Checking for strcasestr... "
-if ${CC} -o compat/have_strcasestr "$srcdir"/compat/have_strcasestr.c > 
/dev/null 2>&1
+if ${CC} -o /dev/null "$srcdir"/compat/have_strcasestr.c > /dev/null 2>&1
 then
 printf "Yes.\n"
 have_strcasestr=1
@@ -1076,10 +1069,9 @@ else
 printf "No (will use our own instead).\n"
 have_strcasestr=0
 fi
-rm -f compat/have_strcasestr
 
 printf "Checking for strsep... "
-if ${CC} -o compat/have_strsep "$srcdir"/compat/have_strsep.c > /dev/null 2>&1
+if ${CC} -o /dev/null "$srcdir"/compat/have_strsep.c > /dev/null 2>&1
 then
 printf "Yes.\n"
 have_strsep="1"
@@ -1087,10 +1079,9 @@ else
 printf "No (will use our own instead).\n"
 have_strsep="0"
 fi
-rm -f compat/have_strsep
 
 printf "Checking for timegm... "
-if ${CC} -o compat/have_timegm "$srcdir"/compat/have_timegm.c > /dev/null 2>&1
+if ${CC} -o /dev/null "$srcdir"/compat/have_timegm.c > /dev/null 2>&1
 then
 printf "Yes.\n"
 have_timegm="1"
@@ -1098,7 +1089,6 @@ else
 printf "No (will use our own instead).\n"
 have_timegm="0"
 fi
-rm -f compat/have_timegm
 
 cat < _time_t.c
 #include 
@@ -1117,7 +1107,7 @@ else
 fi
 
 printf "Checking for dirent.d_type... "
-if ${CC} -o compat/have_d_type "$srcdir"/compat/have_d_type.c > /dev/null 2>&1
+if ${CC} -o /dev/null "$srcdir"/compat/have_d_type.c > /dev/null 2>&1
 then
 printf "Yes.\n"
 have_d_type="1"
@@ -1125,10 +1115,9 @@ else
 printf "No (will use stat instead).\n"
 have_d_type="0"
 fi
-rm -f compat/have_d_type
 
 printf "Checking for standard version of getpwuid_r... "
-if ${CC} -o compat/check_getpwuid "$srcdir"/compat/check_getpwuid.c > 

Re: [PATCH v3] test: replace notmuch_passwd_sanitize() with _libconfig_sanitize()

2021-05-21 Thread Tomi Ollila
On Fri, May 21 2021, Felipe Contreras wrote:

> On Thu, May 20, 2021 at 2:43 AM Tomi Ollila  wrote:
>>
>> On Wed, May 19 2021, Felipe Contreras wrote:
>>
>> > On Wed, May 19, 2021 at 12:34 PM Tomi Ollila  wrote:
>> >
>> >> Haha, as we do _libconfig_sanitize < OUTPUT > OUTPUT.clean
>> >> reading python script from stdin don't work (perl has __DATA__ ;).
>> >> (bitten again, I did and tested the change... :D).
>> >
>> > That can be fixed with:
>> >
>> >   python /dev/fd/3 3<> >   EOF
>>
>> According to
>>
>> https://unix.stackexchange.com/questions/123602/portability-of-file-descriptor-links
>>
>> that solution could be portable enough.
>
> What the operating system does doesn't really matter, bash emulates /dev/fd/x:

In this case, /dev/fd/3 is given as a parameter to a command, not part of 
redirections -- bash cannot know how the program is going to use the
arguments it gets...

Anyway, the [PATCH v4] in id:20210520134628.11653-1-tomi.oll...@iki.fi
implemented your suggestion ${NOTMUCH_PYTHON} /dev/fd/3 3<<'EOF' ...

> "If the operating system on which Bash is running provides these
> special files, bash will use them; otherwise it will emulate them
> internally with the behavior described below."
>
> https://www.gnu.org/software/bash/manual/html_node/Redirections.html

... "Bash handles several filenames specially when they are used in
redirections, as described in the following table." is just before
your snippet >;D

>
> And as far as I know the testing framework only works correctly on bash... 
> So...
>
>> Another way still using -c ... I've played to look how it actually looks is
>> (diff since patch v3)
>>
>> -sq = chr(39) # single quote
>> -l = l.replace(sq + name, sq + "USER_FULL_NAME", 1)
>> +l = l.replace("'\''" + name, "'\''USER_FULL_NAME", 1)
>
> Yes, that works too. But that's what I said in another mail that is
> weird stuff. I had to read it again three times and then copy to a
> proper text editor with monospace font to see if it was correct.

To me '\'' is /idiomatic/ way to embed ' in the middle of a long argument
string...


>> Tested the above. That python /dev/fd/3 3<> have to be tested to see how it looks like and behaves... :D
>
> Yeap. Took me a while to find the right documentation to figure that
> out, but in my opinion it's better to write a helper for the tests
> once, and then forget about it and just re-use it for all.
>
> -- 
> Felipe Contreras
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: Test failures with notmuch 0.32 and 0.32.1 on openSUSE

2021-05-20 Thread Tomi Ollila
On Thu, May 20 2021, Michael J. Gruber wrote:

> David Bremner venit, vidit, dixit 2021-05-20 11:59:50:
>> Dan Čermák  writes:
>> 
>> >
>> > Right, I mistakenly thought this would grab the test database. Is that
>> > one no longer necessary?
>> >
>> 
>> Ah, that's a different make target, which is indeed no longer necessary
>> (we don't do the relevant tests any more).
>> 
>> >> 1) can you duplicate the problem without running the tests in parallel?
>> >
>> > They don't run in parallel, as gnu parallel is not installed inside the
>> > container. So: yes, I can.
>> 
>> OK, it was a long shot, but gpgsm has some known issues with parallel tests.
>> 
>> >> 2) What are the versions of the dependencies you are building with?
>> >
>> > emacs-el-27.2-1.2.noarch
>> 
>> [snip...]
>> 
>> Thanks. What about python and gnupg versions?
>> 
>
> So, I ran the container using buildah on Fedora 33 (without the make
> corpus_download). Again, I'm not a container guy, so I don't know what
> the influence of the host is. But:
>
> What ist the shell in that container?
>
> I don't see T356 failing, but:
>
> T050-new.36 (Xapian exception: read only files) can read all files, so
> either chmod u-w fails or xapian can write the db anyway.

The read-obly file failures happen due to running containers in
"rootless" mode; even the files are chmod'd read-only the files can
still be written there (IMO that is a bug in podman...)

try:

$ echo foo > bar
$ chmod 400 bar
$ cat bar
foo
$ echo foo >> bar
zsh: permission denied: bar
$ podman unshare
# echo foo >> bar 
# cat bar
foo
foo
# exit
$ cat bar
foo
foo
$ echo foo >> bar
zsh: permission denied: bar

I've been running some tests in various (podman) containers, and
seen that -- cannot recall now If I've seen all the others below...

Tomi

>
> T050-new.37 and the T060-count.14 are gdb related and too much for me to
> wrap my head around :|
>
> T150 "Xapian exception: read only files" is again chmod u-w
>
> Do they fail to fail (fail to throw) because the tests run as root (or
> wheel) inside the container?
>
> T380 clearly fails because the shell does not know arithmetic expansion.
>
> The rest passes as expected, except for ruby tests (skipped), known broken
> tests and the two USERNAME@FQDN issues which were fixed recently.
>
> 1486/1497 tests passed.
> 4 broken tests failed as expected.
> 7 tests failed.
> All tests in 2 files skipped.
>
>
> Maybe someone switched their default shell ;)
>
> Michael
>
> P.S.: I assume this during build is buildah-related:
> dbus-daemon[427]: [session uid=0 pid=427]
> org.freedesktop.DBus.Error.AccessDenied: Failed to set fd limit to
> 65536: Operation not permitted
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH v4] test: replace notmuch_passwd_sanitize() with _libconfig_sanitize()

2021-05-20 Thread Tomi Ollila
notmuch_passwd_sanitize() in test-lib.sh is too generic, it cannot
work in many cases...

The more specific version _libconfig_sanitize() replaces it in
T590-libconfig.sh and the code that uses it is modified to output
the keys (ascending numbers printed in hex) so the sanitizer knows
what to sanitize in which lines...

"@" + fqdn -> "@FQDN" replacement is used as fqdn could
-- in theory -- be substring of 'USERNAME'.

'user -> 'USER_FULL_NAME replacement to work in cases where user
is empty -- as only first ' is replaced that works as expected.

In addition to ".(none)" now also ".localdomain" is filtered from
USERNAME@FQDN.

/dev/fd/{n} is not defined in posix, but it is portable enough
(if it weren't it is easy to fix -- now code looks clearer).
---

v3 in id:20210518055443.21964-1-tomi.oll...@iki.fi

Change: using heredoc and /dev/fd/3 in in _libconfig_sanitize,
so "'" can be clearly used in the embedded python program.

 test/T590-libconfig.sh | 96 +-
 test/test-lib.sh   | 20 -
 2 files changed, 58 insertions(+), 58 deletions(-)

diff --git a/test/T590-libconfig.sh b/test/T590-libconfig.sh
index 745e1bb4..8f775f70 100755
--- a/test/T590-libconfig.sh
+++ b/test/T590-libconfig.sh
@@ -5,6 +5,25 @@ test_description="library config API"
 
 add_email_corpus
 
+_libconfig_sanitize() {
+${NOTMUCH_PYTHON} /dev/fd/3 3<<'EOF'
+import os, sys, pwd, socket
+
+pw = pwd.getpwuid(os.getuid())
+user = pw.pw_name
+name = pw.pw_gecos.partition(",")[0]
+fqdn = socket.getaddrinfo(socket.gethostname(), 0, 0,
+  socket.SOCK_STREAM, 0, socket.AI_CANONNAME)[0][3]
+for l in sys.stdin:
+if l[:3] == "8: ":
+l = l.replace(user, "USERNAME", 1).replace("@" + fqdn, "@FQDN", 1)
+l = l.replace(".(none)", "", 1).replace(".localdomain", "", 1)
+elif l[:3] == "a: ":
+l = l.replace("'" + name, "'USER_FULL_NAME", 1)
+sys.stdout.write(l)
+EOF
+}
+
 cat < c_head
 #include 
 #include 
@@ -380,26 +399,26 @@ cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR} '' %NULL%
 key < NOTMUCH_CONFIG_LAST;
 key = (notmuch_config_key_t)(key + 1)) {
const char *val = notmuch_config_get (db, key);
-printf("%s\n", val ? val : "NULL" );
+   printf("%x: '%s'\n", key, val ? val : "NULL" );
 }
 }
 EOF
 
-notmuch_passwd_sanitize < OUTPUT > OUTPUT.clean
+_libconfig_sanitize < OUTPUT > OUTPUT.clean
 
 cat <<'EOF' >EXPECTED
 == stdout ==
-MAIL_DIR
-MAIL_DIR
-MAIL_DIR/.notmuch/hooks
-MAIL_DIR/.notmuch/backups
-
-unread;inbox
-
-true
-USERNAME@FQDN
-NULL
-USER_FULL_NAME
+0: 'MAIL_DIR'
+1: 'MAIL_DIR'
+2: 'MAIL_DIR/.notmuch/hooks'
+3: 'MAIL_DIR/.notmuch/backups'
+4: ''
+5: 'unread;inbox'
+6: ''
+7: 'true'
+8: 'USERNAME@FQDN'
+9: 'NULL'
+a: 'USER_FULL_NAME'
 == stderr ==
 EOF
 unset MAILDIR
@@ -694,23 +713,23 @@ cat c_head2 - c_tail <<'EOF' | test_C ${MAIL_DIR} %NULL% 
%NULL%
 key < NOTMUCH_CONFIG_LAST;
 key = (notmuch_config_key_t)(key + 1)) {
const char *val = notmuch_config_get (db, key);
-printf("%s\n", val ? val : "NULL" );
+   printf("%x: '%s'\n", key, val ? val : "NULL" );
 }
 }
 EOF
 cat <<'EOF' >EXPECTED
 == stdout ==
-MAIL_DIR
-MAIL_DIR
-MAIL_DIR/.notmuch/hooks
-MAIL_DIR/.notmuch/backups
-foo;bar;fub
-unread;inbox
-sekrit_junk
-true
-test_su...@notmuchmail.org
-test_suite_ot...@notmuchmail.org;test_su...@otherdomain.org
-Notmuch Test Suite
+0: 'MAIL_DIR'
+1: 'MAIL_DIR'
+2: 'MAIL_DIR/.notmuch/hooks'
+3: 'MAIL_DIR/.notmuch/backups'
+4: 'foo;bar;fub'
+5: 'unread;inbox'
+6: 'sekrit_junk'
+7: 'true'
+8: 'test_su...@notmuchmail.org'
+9: 'test_suite_ot...@notmuchmail.org;test_su...@otherdomain.org'
+a: 'Notmuch Test Suite'
 == stderr ==
 EOF
 test_expect_equal_file EXPECTED OUTPUT
@@ -723,25 +742,26 @@ cat c_head2 - c_tail <<'EOF' | test_C ${MAIL_DIR} 
/nonexistent %NULL%
 key < NOTMUCH_CONFIG_LAST;
 key = (notmuch_config_key_t)(key + 1)) {
const char *val = notmuch_config_get (db, key);
-   printf("%s\n", val ? val : "NULL" );
+   printf("%x: '%s'\n", key, val ? val : "NULL" );
 }
 }
 EOF
 
-notmuch_passwd_sanitize < OUTPUT > OUTPUT.clean
+_libconfig_sanitize < OUTPUT > OUTPUT.clean
+
 cat <<'EOF' >EXPECTED
 == stdout ==
-MAIL_DIR
-MAIL_DIR
-MAIL_DIR/.notmuch/hooks
-MAIL_DIR/.notmuch/backups
-
-unread;inbox
-
-true
-USERNAME@FQDN
-NULL
-USER_FULL_NAME
+0: 'MAIL_DIR'
+1: 'MAIL_DIR'
+2: 'MAIL_DIR/.notmuch/hooks'
+3: 'MAIL_DIR/.notmuch/backups'
+4: ''
+5: 'unread;inbox'
+6: ''
+7: 'true'
+8: 'USERNAME@FQDN'
+9: 'NULL'
+a: 'USER_FULL_NAME'
 == stderr ==
 EOF
 test_expect_equal_file EXPECTED OUTPUT.clean
diff --git a/test/test-lib.sh b/test/test-lib.sh
index 6be5d11f..35bea097 100644
--- a/test/test-lib.sh
+++ b/test/test-lib.sh
@@ -561,26 +561,6 @@ notmuch_built_with_sanitize () {
 sed 's/^built_with[.]\(.*\)=.*$/built_with.\1=something/'
 }
 
-notmuch_passwd_sanitize () {
-${NOTMUCH_PYTHON} -c'
-import os, sys, pwd, socket
-
-pw = 

Re: [PATCH v3] test: replace notmuch_passwd_sanitize() with _libconfig_sanitize()

2021-05-20 Thread Tomi Ollila
On Wed, May 19 2021, Felipe Contreras wrote:

> On Wed, May 19, 2021 at 12:34 PM Tomi Ollila  wrote:
>
>> Haha, as we do _libconfig_sanitize < OUTPUT > OUTPUT.clean
>> reading python script from stdin don't work (perl has __DATA__ ;).
>> (bitten again, I did and tested the change... :D).
>
> That can be fixed with:
>
>   python /dev/fd/3 3<   EOF

According to 

https://unix.stackexchange.com/questions/123602/portability-of-file-descriptor-links

that solution could be portable enough.

Another way still using -c ... I've played to look how it actually looks is
(diff since patch v3)

-sq = chr(39) # single quote
-l = l.replace(sq + name, sq + "USER_FULL_NAME", 1)
+l = l.replace("'\''" + name, "'\''USER_FULL_NAME", 1)

Tested the above. That python /dev/fd/3 3<
> -- 
> Felipe Contreras

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


Re: [PATCH v3] test: replace notmuch_passwd_sanitize() with _libconfig_sanitize()

2021-05-19 Thread Tomi Ollila
On Wed, May 19 2021, Tomi Ollila wrote:

> On Wed, May 19 2021, Felipe Contreras wrote:
>
>>
>> Why not use a heredoc?
>>
>>   python <<-EOF
>>   ..
>>   EOF
>
> tldr: I'll post change to use heredoc.

... which did not work ...

> Probably my bias against heredoc's when there are alternatives
> -- although this is much more tolerable than cat < to write stuff to stdout ;)
>
> Also, I did not recall it is this simple to read python code
> from stdin to be executed (right, that loses stdin for user
> input -- I was once bitten by that so that contributes to 
> my bias).

Haha, as we do _libconfig_sanitize < OUTPUT > OUTPUT.clean
reading python script from stdin don't work (perl has __DATA__ ;).
(bitten again, I did and tested the change... :D).

I'd rather keep the same "filter" style here as in everywhere
else in our test scripts, and chr(39) instead of exiting out
from the single quoted string temporarily in order to add
that/those single quote(s) to the argument for python3 -c ...

So [PATCH v3] in id:20210518055443.21964-1-tomi.oll...@iki.fi
is my fix proposal.

Tomi

>
> Here the ability to use "'" (for clarity) is compelling reason
> to use heredoc.
>
> (alternatives would have been:
>
>  * l.replace("'\''" + name ...
>
>  * l.replace("'"'"'" + name ... ;D
>
>  * use other delimiter than ' (but not unicode quotes >;)
> )
>
> While testing this option I looked (once again) how dash and
> bash do heredocs (in linux) (just to update my knowledge):
>
> dash creates pipe and dup2's fd[0] to 0 
>  (that makes stdin not seekable)
>
> bash clones subprocess; in subprocess it creates temporary file,
>  writes data there, closes it, opens it for reading, 
>  unlinks it from fs (could be problematic on windows), 
>  dup2()'s it to stdin, closes the dupped fd and finally
>  execve's python
>
> zsh works like bash (i.e. these 2 provide seekable stdin)
>
> $ (strace -f -ofile zsh heredoc-test.sh)
>
> Tomi
>
>>
>>> +pw = pwd.getpwuid(os.getuid())
>>> +user = pw.pw_name
>>> +name = pw.pw_gecos.partition(",")[0]
>>> +fqdn = socket.getaddrinfo(socket.gethostname(), 0, 0,
>>> +  socket.SOCK_STREAM, 0, socket.AI_CANONNAME)[0][3]
>>> +for l in sys.stdin:
>>> +if l[:3] == "8: ":
>>> +l = l.replace(user, "USERNAME", 1).replace("@" + fqdn, "@FQDN", 1)
>>> +l = l.replace(".(none)", "", 1).replace(".localdomain", "", 1)
>>> +elif l[:3] == "a: ":
>>> +sq = chr(39) # single quote
>>> +l = l.replace(sq + name, sq + "USER_FULL_NAME", 1)
>>
>> Then we can simply do:
>>
>> l.replace("'" + name, "'USER_FULL_NAME", 1)
>>
>> The rest looks fine to me.
>>
>> -- 
>> Felipe Contreras
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: Emacs: prevent notmuch from tampering with message headers & settings

2021-05-19 Thread Tomi Ollila
On Wed, May 19 2021, Tory S. Anderson wrote:

> I've made a branch with a change that should avoid ruining existing
> behavior for anyone not trying to preserve their mail-user-agent. How can
> I submit this thing?

IIRC David already posted something on this mailing list.

but anyway; FYI, and reminder for others:

https://notmuchmail.org/contributing/

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


Re: [PATCH v3] test: replace notmuch_passwd_sanitize() with _libconfig_sanitize()

2021-05-19 Thread Tomi Ollila
On Wed, May 19 2021, Felipe Contreras wrote:

> On Tue, May 18, 2021 at 12:55 AM Tomi Ollila  wrote:
>>
>> notmuch_passwd_sanitize() in test-lib.sh is too generic, it cannot
>> work in many cases...
>>
>> The more specific version _libconfig_sanitize() replaces it in
>> T590-libconfig.sh and the code that uses it is modified to output
>> the keys (ascending numbers printed in hex) so the sanitizer knows
>> what to sanitize in which lines...
>>
>> "@" + fqdn -> "@FQDN" replacement is used as fqdn could --
>> in theory -- be substring of 'USERNAME'.
>>
>> 'user -> 'USER_FULL_NAME replacement to work in cases where user
>> is empty -- as only first ' is replaced that works as expected.
>>
>> In addition to ".(none)" now also ".localdomain" is filtered from
>> USERNAME@FQDN.
>> ---
>>
>> Changes to [v2]:
>>
>> * work in cases of empty user (e.g. in passwd gecos field)
>> * replace only 1st match; e.g. fqdn could contain substring of user
>>
>> v2: id:20210517193315.11343-1-tomi.oll...@iki.fi
>> v1: id:20210502181535.31292-1-tomi.oll...@iki.fi
>>
>> When tried w/ one replacement and w/o sq usage and emptied gecos, got
>>
>> .  @@ -9,5 +9,5 @@
>> .  7: 'true'
>> .  8: 'USERNAME@FQDN'
>> .  9: 'NULL'
>> . -a: 'USER_FULL_NAME'
>> . +USER_FULL_NAMEa: ''
>>
>>  test/T590-libconfig.sh | 97 +-
>>  test/test-lib.sh   | 20 -
>>  2 files changed, 59 insertions(+), 58 deletions(-)
>>
>> diff --git a/test/T590-libconfig.sh b/test/T590-libconfig.sh
>> index 745e1bb4..42cbe6e0 100755
>> --- a/test/T590-libconfig.sh
>> +++ b/test/T590-libconfig.sh
>> @@ -5,6 +5,26 @@ test_description="library config API"
>>
>>  add_email_corpus
>>
>> +_libconfig_sanitize() {
>> +${NOTMUCH_PYTHON} -c '
>> +import os, sys, pwd, socket
>
> Why not use a heredoc?
>
>   python <<-EOF
>   ..
>   EOF

tldr: I'll post change to use heredoc.

Probably my bias against heredoc's when there are alternatives
-- although this is much more tolerable than cat <;)
)

While testing this option I looked (once again) how dash and
bash do heredocs (in linux) (just to update my knowledge):

dash creates pipe and dup2's fd[0] to 0 
 (that makes stdin not seekable)

bash clones subprocess; in subprocess it creates temporary file,
 writes data there, closes it, opens it for reading, 
 unlinks it from fs (could be problematic on windows), 
 dup2()'s it to stdin, closes the dupped fd and finally
 execve's python

zsh works like bash (i.e. these 2 provide seekable stdin)

$ (strace -f -ofile zsh heredoc-test.sh)

Tomi

>
>> +pw = pwd.getpwuid(os.getuid())
>> +user = pw.pw_name
>> +name = pw.pw_gecos.partition(",")[0]
>> +fqdn = socket.getaddrinfo(socket.gethostname(), 0, 0,
>> +  socket.SOCK_STREAM, 0, socket.AI_CANONNAME)[0][3]
>> +for l in sys.stdin:
>> +if l[:3] == "8: ":
>> +l = l.replace(user, "USERNAME", 1).replace("@" + fqdn, "@FQDN", 1)
>> +l = l.replace(".(none)", "", 1).replace(".localdomain", "", 1)
>> +elif l[:3] == "a: ":
>> +sq = chr(39) # single quote
>> +l = l.replace(sq + name, sq + "USER_FULL_NAME", 1)
>
> Then we can simply do:
>
> l.replace("'" + name, "'USER_FULL_NAME", 1)
>
> The rest looks fine to me.
>
> -- 
> Felipe Contreras
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH v3] test: replace notmuch_passwd_sanitize() with _libconfig_sanitize()

2021-05-17 Thread Tomi Ollila
notmuch_passwd_sanitize() in test-lib.sh is too generic, it cannot
work in many cases...

The more specific version _libconfig_sanitize() replaces it in
T590-libconfig.sh and the code that uses it is modified to output
the keys (ascending numbers printed in hex) so the sanitizer knows
what to sanitize in which lines...

"@" + fqdn -> "@FQDN" replacement is used as fqdn could --
in theory -- be substring of 'USERNAME'.

'user -> 'USER_FULL_NAME replacement to work in cases where user
is empty -- as only first ' is replaced that works as expected.

In addition to ".(none)" now also ".localdomain" is filtered from
USERNAME@FQDN.
---

Changes to [v2]:

* work in cases of empty user (e.g. in passwd gecos field)
* replace only 1st match; e.g. fqdn could contain substring of user

v2: id:20210517193315.11343-1-tomi.oll...@iki.fi
v1: id:20210502181535.31292-1-tomi.oll...@iki.fi

When tried w/ one replacement and w/o sq usage and emptied gecos, got

.  @@ -9,5 +9,5 @@
.  7: 'true'
.  8: 'USERNAME@FQDN'
.  9: 'NULL'
. -a: 'USER_FULL_NAME'
. +USER_FULL_NAMEa: ''

 test/T590-libconfig.sh | 97 +-
 test/test-lib.sh   | 20 -
 2 files changed, 59 insertions(+), 58 deletions(-)

diff --git a/test/T590-libconfig.sh b/test/T590-libconfig.sh
index 745e1bb4..42cbe6e0 100755
--- a/test/T590-libconfig.sh
+++ b/test/T590-libconfig.sh
@@ -5,6 +5,26 @@ test_description="library config API"
 
 add_email_corpus
 
+_libconfig_sanitize() {
+${NOTMUCH_PYTHON} -c '
+import os, sys, pwd, socket
+
+pw = pwd.getpwuid(os.getuid())
+user = pw.pw_name
+name = pw.pw_gecos.partition(",")[0]
+fqdn = socket.getaddrinfo(socket.gethostname(), 0, 0,
+  socket.SOCK_STREAM, 0, socket.AI_CANONNAME)[0][3]
+for l in sys.stdin:
+if l[:3] == "8: ":
+l = l.replace(user, "USERNAME", 1).replace("@" + fqdn, "@FQDN", 1)
+l = l.replace(".(none)", "", 1).replace(".localdomain", "", 1)
+elif l[:3] == "a: ":
+sq = chr(39) # single quote
+l = l.replace(sq + name, sq + "USER_FULL_NAME", 1)
+sys.stdout.write(l)
+'
+}
+
 cat < c_head
 #include 
 #include 
@@ -380,26 +400,26 @@ cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR} '' %NULL%
 key < NOTMUCH_CONFIG_LAST;
 key = (notmuch_config_key_t)(key + 1)) {
const char *val = notmuch_config_get (db, key);
-printf("%s\n", val ? val : "NULL" );
+   printf("%x: '%s'\n", key, val ? val : "NULL" );
 }
 }
 EOF
 
-notmuch_passwd_sanitize < OUTPUT > OUTPUT.clean
+_libconfig_sanitize < OUTPUT > OUTPUT.clean
 
 cat <<'EOF' >EXPECTED
 == stdout ==
-MAIL_DIR
-MAIL_DIR
-MAIL_DIR/.notmuch/hooks
-MAIL_DIR/.notmuch/backups
-
-unread;inbox
-
-true
-USERNAME@FQDN
-NULL
-USER_FULL_NAME
+0: 'MAIL_DIR'
+1: 'MAIL_DIR'
+2: 'MAIL_DIR/.notmuch/hooks'
+3: 'MAIL_DIR/.notmuch/backups'
+4: ''
+5: 'unread;inbox'
+6: ''
+7: 'true'
+8: 'USERNAME@FQDN'
+9: 'NULL'
+a: 'USER_FULL_NAME'
 == stderr ==
 EOF
 unset MAILDIR
@@ -694,23 +714,23 @@ cat c_head2 - c_tail <<'EOF' | test_C ${MAIL_DIR} %NULL% 
%NULL%
 key < NOTMUCH_CONFIG_LAST;
 key = (notmuch_config_key_t)(key + 1)) {
const char *val = notmuch_config_get (db, key);
-printf("%s\n", val ? val : "NULL" );
+   printf("%x: '%s'\n", key, val ? val : "NULL" );
 }
 }
 EOF
 cat <<'EOF' >EXPECTED
 == stdout ==
-MAIL_DIR
-MAIL_DIR
-MAIL_DIR/.notmuch/hooks
-MAIL_DIR/.notmuch/backups
-foo;bar;fub
-unread;inbox
-sekrit_junk
-true
-test_su...@notmuchmail.org
-test_suite_ot...@notmuchmail.org;test_su...@otherdomain.org
-Notmuch Test Suite
+0: 'MAIL_DIR'
+1: 'MAIL_DIR'
+2: 'MAIL_DIR/.notmuch/hooks'
+3: 'MAIL_DIR/.notmuch/backups'
+4: 'foo;bar;fub'
+5: 'unread;inbox'
+6: 'sekrit_junk'
+7: 'true'
+8: 'test_su...@notmuchmail.org'
+9: 'test_suite_ot...@notmuchmail.org;test_su...@otherdomain.org'
+a: 'Notmuch Test Suite'
 == stderr ==
 EOF
 test_expect_equal_file EXPECTED OUTPUT
@@ -723,25 +743,26 @@ cat c_head2 - c_tail <<'EOF' | test_C ${MAIL_DIR} 
/nonexistent %NULL%
 key < NOTMUCH_CONFIG_LAST;
 key = (notmuch_config_key_t)(key + 1)) {
const char *val = notmuch_config_get (db, key);
-   printf("%s\n", val ? val : "NULL" );
+   printf("%x: '%s'\n", key, val ? val : "NULL" );
 }
 }
 EOF
 
-notmuch_passwd_sanitize < OUTPUT > OUTPUT.clean
+_libconfig_sanitize < OUTPUT > OUTPUT.clean
+
 cat <<'EOF' >EXPECTED
 == stdout ==
-MAIL_DIR
-MAIL_DIR
-MAIL_DIR/.notmuch/hooks
-MAIL_DIR/.notmuch/backups
-
-unread;inbox
-
-true
-USERNAME@FQDN
-NULL
-USER_FULL_NAME
+0: 'MAIL_DIR'
+1: 'MAIL_DIR'
+2: 'MAIL_DIR/.notmuch/hooks'
+3: 'MAIL_DIR/.notmuch/backups'
+4: ''
+5: 'unread;inbox'
+6: ''
+7: 'true'
+8: 'USERNAME@FQDN'
+9: 'NULL'
+a: 'USER_FULL_NAME'
 == stderr ==
 EOF
 test_expect_equal_file EXPECTED OUTPUT.clean
diff --git a/test/test-lib.sh b/test/test-lib.sh
index 6be5d11f..35bea097 100644
--- a/test/test-lib.sh
+++ b/test/test-lib.sh
@@ -561,26 +561,6 @@ notmuch_built_with_sanitize () {
 sed 

Re: [PATCH v2] test: replace notmuch_passwd_sanitize() with _libconfig_sanitize()

2021-05-17 Thread Tomi Ollila
On Mon, May 17 2021, Felipe Contreras wrote:

> On Mon, May 17, 2021 at 2:33 PM Tomi Ollila  wrote:
>>
>> notmuch_passwd_sanitize() in test-lib.sh is too generic, it cannot
>> work in many cases...
>>
>> The more specific version _libconfig_sanitize() replaces it in
>> T590-libconfig.sh and the code that uses it is modified to output
>> the keys (ascending numbers printed in hex) so the sanitizer knows
>> what to sanitize in which lines...
>>
>> In addition to ".(none)" now also ".localdomain" if filtered from
>> USERNAME@FQDN.
>> ---
>>
>> Rebase of id:20210502181535.31292-1-tomi.oll...@iki.fi
>>
>> * 'fn () {' style change
>> * added @ to fqdn replace, as it could be subset of user
>>
>>  test/T590-libconfig.sh | 97 +-
>>  test/test-lib.sh   | 20 -
>>  2 files changed, 59 insertions(+), 58 deletions(-)
>>
>> diff --git a/test/T590-libconfig.sh b/test/T590-libconfig.sh
>> index 745e1bb4..8e70b7b2 100755
>> --- a/test/T590-libconfig.sh
>> +++ b/test/T590-libconfig.sh
>> @@ -5,6 +5,26 @@ test_description="library config API"
>>
>>  add_email_corpus
>>
>> +_libconfig_sanitize() {
>> +${NOTMUCH_PYTHON} -c '
>> +import os, sys, pwd, socket
>> +
>> +pw = pwd.getpwuid(os.getuid())
>> +user = pw.pw_name
>> +name = pw.pw_gecos.partition(",")[0]
>> +fqdn = socket.getaddrinfo(socket.gethostname(), 0, 0,
>> +  socket.SOCK_STREAM, 0, socket.AI_CANONNAME)[0][3]
>> +for l in sys.stdin:
>> +if l[:3] == "8: ":
>> +# fqdn could be subset of user; therefore @
>> +l = l.replace(user, "USERNAME").replace("@" + fqdn, "@FQDN")
>> +l = l.replace(".(none)", "").replace(".localdomain", "")
>> +elif l[:3] == "a: ":
>> +l = l.replace(name, "USER_FULL_NAME")
>
> This generates garbage when name is null. See ff5f141b (test: fix
> passwd_sanitize(), 2021-05-01).

You're right -- that was the reason I added ''s around,
just forgot that part :/

Anyway, there are other problems, will fix that along...

Thanks,

Tomi

>
> At the very least we need to check for that, even better if we
> generate the proper output:
>
> if name:
> l = l.replace(name, "USER_FULL_NAME")
> else:
> l = "a: \'USER_FULL_NAME\'\\n"

>
> This makes the test pass with no geckos name, but we need to use bash
> strings: $'string'. Otherwise we would need to do something much more
> weird.
>
> Cheers.
>
> -- 
> Felipe Contreras
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH v2] test: replace notmuch_passwd_sanitize() with _libconfig_sanitize()

2021-05-17 Thread Tomi Ollila
notmuch_passwd_sanitize() in test-lib.sh is too generic, it cannot
work in many cases...

The more specific version _libconfig_sanitize() replaces it in
T590-libconfig.sh and the code that uses it is modified to output
the keys (ascending numbers printed in hex) so the sanitizer knows
what to sanitize in which lines...

In addition to ".(none)" now also ".localdomain" if filtered from
USERNAME@FQDN.
---

Rebase of id:20210502181535.31292-1-tomi.oll...@iki.fi

* 'fn () {' style change
* added @ to fqdn replace, as it could be subset of user

 test/T590-libconfig.sh | 97 +-
 test/test-lib.sh   | 20 -
 2 files changed, 59 insertions(+), 58 deletions(-)

diff --git a/test/T590-libconfig.sh b/test/T590-libconfig.sh
index 745e1bb4..8e70b7b2 100755
--- a/test/T590-libconfig.sh
+++ b/test/T590-libconfig.sh
@@ -5,6 +5,26 @@ test_description="library config API"
 
 add_email_corpus
 
+_libconfig_sanitize() {
+${NOTMUCH_PYTHON} -c '
+import os, sys, pwd, socket
+
+pw = pwd.getpwuid(os.getuid())
+user = pw.pw_name
+name = pw.pw_gecos.partition(",")[0]
+fqdn = socket.getaddrinfo(socket.gethostname(), 0, 0,
+  socket.SOCK_STREAM, 0, socket.AI_CANONNAME)[0][3]
+for l in sys.stdin:
+if l[:3] == "8: ":
+# fqdn could be subset of user; therefore @
+l = l.replace(user, "USERNAME").replace("@" + fqdn, "@FQDN")
+l = l.replace(".(none)", "").replace(".localdomain", "")
+elif l[:3] == "a: ":
+l = l.replace(name, "USER_FULL_NAME")
+sys.stdout.write(l)
+'
+}
+
 cat < c_head
 #include 
 #include 
@@ -380,26 +400,26 @@ cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR} '' %NULL%
 key < NOTMUCH_CONFIG_LAST;
 key = (notmuch_config_key_t)(key + 1)) {
const char *val = notmuch_config_get (db, key);
-printf("%s\n", val ? val : "NULL" );
+   printf("%x: '%s'\n", key, val ? val : "NULL" );
 }
 }
 EOF
 
-notmuch_passwd_sanitize < OUTPUT > OUTPUT.clean
+_libconfig_sanitize < OUTPUT > OUTPUT.clean
 
 cat <<'EOF' >EXPECTED
 == stdout ==
-MAIL_DIR
-MAIL_DIR
-MAIL_DIR/.notmuch/hooks
-MAIL_DIR/.notmuch/backups
-
-unread;inbox
-
-true
-USERNAME@FQDN
-NULL
-USER_FULL_NAME
+0: 'MAIL_DIR'
+1: 'MAIL_DIR'
+2: 'MAIL_DIR/.notmuch/hooks'
+3: 'MAIL_DIR/.notmuch/backups'
+4: ''
+5: 'unread;inbox'
+6: ''
+7: 'true'
+8: 'USERNAME@FQDN'
+9: 'NULL'
+a: 'USER_FULL_NAME'
 == stderr ==
 EOF
 unset MAILDIR
@@ -694,23 +714,23 @@ cat c_head2 - c_tail <<'EOF' | test_C ${MAIL_DIR} %NULL% 
%NULL%
 key < NOTMUCH_CONFIG_LAST;
 key = (notmuch_config_key_t)(key + 1)) {
const char *val = notmuch_config_get (db, key);
-printf("%s\n", val ? val : "NULL" );
+   printf("%x: '%s'\n", key, val ? val : "NULL" );
 }
 }
 EOF
 cat <<'EOF' >EXPECTED
 == stdout ==
-MAIL_DIR
-MAIL_DIR
-MAIL_DIR/.notmuch/hooks
-MAIL_DIR/.notmuch/backups
-foo;bar;fub
-unread;inbox
-sekrit_junk
-true
-test_su...@notmuchmail.org
-test_suite_ot...@notmuchmail.org;test_su...@otherdomain.org
-Notmuch Test Suite
+0: 'MAIL_DIR'
+1: 'MAIL_DIR'
+2: 'MAIL_DIR/.notmuch/hooks'
+3: 'MAIL_DIR/.notmuch/backups'
+4: 'foo;bar;fub'
+5: 'unread;inbox'
+6: 'sekrit_junk'
+7: 'true'
+8: 'test_su...@notmuchmail.org'
+9: 'test_suite_ot...@notmuchmail.org;test_su...@otherdomain.org'
+a: 'Notmuch Test Suite'
 == stderr ==
 EOF
 test_expect_equal_file EXPECTED OUTPUT
@@ -723,25 +743,26 @@ cat c_head2 - c_tail <<'EOF' | test_C ${MAIL_DIR} 
/nonexistent %NULL%
 key < NOTMUCH_CONFIG_LAST;
 key = (notmuch_config_key_t)(key + 1)) {
const char *val = notmuch_config_get (db, key);
-   printf("%s\n", val ? val : "NULL" );
+   printf("%x: '%s'\n", key, val ? val : "NULL" );
 }
 }
 EOF
 
-notmuch_passwd_sanitize < OUTPUT > OUTPUT.clean
+_libconfig_sanitize < OUTPUT > OUTPUT.clean
+
 cat <<'EOF' >EXPECTED
 == stdout ==
-MAIL_DIR
-MAIL_DIR
-MAIL_DIR/.notmuch/hooks
-MAIL_DIR/.notmuch/backups
-
-unread;inbox
-
-true
-USERNAME@FQDN
-NULL
-USER_FULL_NAME
+0: 'MAIL_DIR'
+1: 'MAIL_DIR'
+2: 'MAIL_DIR/.notmuch/hooks'
+3: 'MAIL_DIR/.notmuch/backups'
+4: ''
+5: 'unread;inbox'
+6: ''
+7: 'true'
+8: 'USERNAME@FQDN'
+9: 'NULL'
+a: 'USER_FULL_NAME'
 == stderr ==
 EOF
 test_expect_equal_file EXPECTED OUTPUT.clean
diff --git a/test/test-lib.sh b/test/test-lib.sh
index 89eb744d..c379d140 100644
--- a/test/test-lib.sh
+++ b/test/test-lib.sh
@@ -564,26 +564,6 @@ notmuch_built_with_sanitize () {
 sed 's/^built_with[.]\(.*\)=.*$/built_with.\1=something/'
 }
 
-notmuch_passwd_sanitize () {
-${NOTMUCH_PYTHON} -c'
-import os, sys, pwd, socket
-
-pw = pwd.getpwuid(os.getuid())
-user = pw.pw_name
-name = pw.pw_gecos.partition(",")[0]
-fqdn = socket.getaddrinfo(socket.gethostname(), 0, 0, socket.SOCK_STREAM, 0, 
socket.AI_CANONNAME)[0][3]
-
-for l in sys.stdin:
-if user:
-l = l.replace(user, "USERNAME")
-if fqdn:
-l = l.replace(fqdn, "FQDN").replace(".(none)","")
-if name:
-l = l.replace(name, 

[PATCH] test: aggregate-results updates

2021-05-17 Thread Tomi Ollila
notmuch-test will now call aggregate-results.sh with file list
that it compiles based on the test ran, and aggregate-results
will report failure is any of the test files are missing.

With this notmuch-test no longer has to exit in non-parallel
run if some test fail to write its report file -- so it works
as parallel tests in this sense.

Changed test_done() in test-lib.sh write report file in one write(2),
so there is (even) less chance it being partially written. Also,
now it writes 'total' last and aggregate-results.sh expects this
line to exist in all report files for reporting to be successful.

Added 'set -eu' to notmuch-test and modified code to work with
these settings. That makes it harder to get mistakes slipped
into committed code.
---

testing all changed branches is somewhat hard; I did by adding
sleep 20 and file what effective removed created results files;
another change was to change 'total' to 'toxtal' in test_done,
then I run (at least) the following command lines:

make test
NOTMUCH_TESTS='T140-excludes.sh T740-body.sh' make test
NOTMUCH_TESTS='T140-excludes.sh T740-body.sh' NOTMUCH_TEST_SERIALIZE=t make test
NOTMUCH_TESTS=T160-json.sh NOTMUCH_TEST_SERIALIZE=t test/notmuch-test

 test/aggregate-results.sh | 22 --
 test/notmuch-test | 47 ++-
 test/test-lib.sh  | 15 +++--
 3 files changed, 54 insertions(+), 30 deletions(-)

diff --git a/test/aggregate-results.sh b/test/aggregate-results.sh
index 75400e6e..6845fcf0 100755
--- a/test/aggregate-results.sh
+++ b/test/aggregate-results.sh
@@ -8,9 +8,16 @@ failed=0
 broken=0
 total=0
 all_skipped=0
+rep_failed=0
 
 for file
 do
+   if [ ! -f "$file" ]; then
+   echo "'$file' does not exist!"
+   rep_failed=$((rep_failed + 1))
+   continue
+   fi
+   has_total=0
while read type value
do
case $type in
@@ -24,18 +31,23 @@ do
broken=$((broken + value)) ;;
total)
total=$((total + value))
+   has_total=1
if [ "$value" -eq 0 ]; then
all_skipped=$((all_skipped + 1))
fi
esac
done <"$file"
+   if [ "$has_total" -eq 0 ]; then
+   echo "'$file' lacks 'total ...'; results may be inconsistent."
+   failed=$((failed + 1))
+   fi
 done
 
 pluralize_s () { [ "$1" -eq 1 ] && s='' || s='s'; }
 
 echo "Notmuch test suite complete."
 
-if [ "$fixed" -eq 0 ] && [ "$failed" -eq 0 ]; then
+if [ "$fixed" -eq 0 ] && [ "$failed" -eq 0 ] && [ "$rep_failed" -eq 0 ]; then
pluralize_s "$total"
printf "All $total test$s "
if [ "$broken" -eq 0 ]; then
@@ -70,10 +82,16 @@ if [ "$all_skipped" -ne 0 ]; then
echo "All tests in $all_skipped file$s skipped."
 fi
 
+if [ "$rep_failed" -ne 0 ]; then
+   pluralize_s "$rep_failed"
+   echo "$rep_failed test$s failed to report results."
+fi
+
 # Note that we currently do not consider skipped tests as failing the
 # build.
 
-if [ "$success" -gt 0 ] && [ "$fixed" -eq 0 ] && [ "$failed" -eq 0 ]
+if [ "$success" -gt 0 ] && [ "$fixed" -eq 0 ] &&
+   [ "$failed" -eq 0 ] && [ "$rep_failed" -eq 0 ]
 then
exit 0
 else
diff --git a/test/notmuch-test b/test/notmuch-test
index cbd33f93..ce142f7c 100755
--- a/test/notmuch-test
+++ b/test/notmuch-test
@@ -18,12 +18,14 @@ fi
 # Ensure NOTMUCH_SRCDIR and NOTMUCH_BUILDDIR are set.
 . $(dirname "$0")/export-dirs.sh || exit 1
 
+set -eu
+
 TESTS=
-for test in $NOTMUCH_TESTS; do
+for test in ${NOTMUCH_TESTS-}; do
 TESTS="$TESTS $NOTMUCH_SRCDIR/test/$test"
 done
 
-if [[ -z "$TESTS" ]]; then
+if [ -z "$TESTS" ]; then
 TESTS="$NOTMUCH_SRCDIR/test/T[0-9][0-9][0-9]-*.sh"
 fi
 
@@ -44,43 +46,46 @@ else
 TEST_TIMEOUT_CMD=""
 fi
 
-trap 'e=$?; kill $!; exit $e' HUP INT TERM
-
 META_FAILURE=
+RES=0
 # Run the tests
-if test -z "$NOTMUCH_TEST_SERIALIZE" && command -v parallel >/dev/null ; then
+if test -z "${NOTMUCH_TEST_SERIALIZE-}" && command -v parallel >/dev/null ; 
then
 test -t 1 && export COLORS_WITHOUT_TTY=t || :
 if parallel --version 2>&1 | grep -q GNU ; then
 echo "INFO: running tests with GNU parallel"
-printf '%s\n' $TESTS | $TEST_TIMEOUT_CMD parallel
+printf '%s\n' $TESTS | $TEST_TIMEOUT_CMD parallel || RES=$?
 else
 echo "INFO: running tests with moreutils parallel"
-$TEST_TIMEOUT_CMD parallel -- $TESTS
+$TEST_TIMEOUT_CMD parallel -- $TESTS || RES=$?
 fi
-RES=$?
-if [[ $RES != 0 ]]; then
+if [ $RES != 0 ]; then
 META_FAILURE="parallel test suite returned error code $RES"
 fi
 else
+trap 'e=$?; trap - 0; kill ${!-}; exit $e' 0 HUP INT TERM
 for test in $TESTS; do
 $TEST_TIMEOUT_CMD $test "$@" &
-wait $!
-# If the test failed without producing results, 

Re: [PATCH] test: add known broken test for duplicate thread-id terms

2021-05-17 Thread Tomi Ollila
On Sat, May 15 2021, David Bremner wrote:

> According to my bijection, this bug has been present since commit
> 411675a6ce in 2017. It is apparently harmless for regular use, but
> does make notmuch crash when compiled with -DDEBUG_DATABASE_SANITY.
> ---
>  test/T670-duplicate-mid.sh | 17 +
>  1 file changed, 17 insertions(+)
>
> diff --git a/test/T670-duplicate-mid.sh b/test/T670-duplicate-mid.sh
> index 4e5672ab..3fd59ca5 100755
> --- a/test/T670-duplicate-mid.sh
> +++ b/test/T670-duplicate-mid.sh
> @@ -2,10 +2,27 @@
>  test_description="duplicate message ids"
>  . $(dirname "$0")/test-lib.sh || exit 1
>  
> +test_require_external_prereq xapian-delve
> +
>  add_message '[id]="duplicate"' '[subject]="message 1" [filename]=copy1'
>  add_message '[id]="duplicate"' '[subject]="message 2" [filename]=copy2'
>  
>  add_message '[id]="duplicate"' '[subject]="message 0" [filename]=copy0'
> +
> +test_begin_subtest 'at most 1 thread-id per xapian document'
> +test_subtest_known_broken
> +db=${MAIL_DIR}/.notmuch/xapian
> +cp /dev/null OUTPUT.raw
> +for doc in $(xapian-delve -1 -t '' "$db" | grep '^[1-9]'); do
> +xapian-delve -1 -r "$doc"  "$db" | grep '^G' | wc -l >> OUTPUT.raw
> +done

for doc in $(xapian-delve -1 -t '' "$db" | grep '^[1-9]'); do
xapian-delve -1 -r "$doc" "$db" | grep -c '^G'
done > OUTPUT.raw

will do (w/o cp /dev/null OUTPUT.raw) (also NOTE SPACING !!! >;D)


> +sort -u < OUTPUT.raw > OUTPUT
> +cat < EXPECTED
> +0
> +1
> +EOF
> +test_expect_equal_file EXPECTED OUTPUT
> +
>  test_begin_subtest 'search: first indexed subject preserved'
>  cat < EXPECTED
>  thread:XXX   2001-01-05 [1/1(3)] Notmuch Test Suite; message 1 (inbox unread)
> -- 
> 2.30.2
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: ruby: building with CFLAGS="something"

2021-05-16 Thread Tomi Ollila
On Sun, May 16 2021, Felipe Contreras wrote:

> On Sun, May 16, 2021 at 7:28 AM David Bremner  wrote:
>>
>>
>> The rest of the (C and C++) codebase supports
>>
>> make CFLAGS="-g -O0"
>>
>> or
>>
>> CFLAGS="-g -O0" ./configure
>>
>> but the ruby bindings don't build:
>
> That's because -fPIC is needed.
>
> The way Ruby's mkmf generates the Makefile is wrong, because it should do:
>
>   override CFLAGS+=-fPIC
>
> So that the user can specify other CFLAGS.
>
> However, we can fix that by doing that ourselves:
>
> --- a/bindings/Makefile.local
> +++ b/bindings/Makefile.local
> @@ -10,7 +10,7 @@ ifeq ($(HAVE_RUBY_DEV),1)
> LIBNOTMUCH="../../lib/$(LINKER_NAME)" \
> NOTMUCH_SRCDIR='$(NOTMUCH_SRCDIR)' \
> $(RUBY) extconf.rb --vendor
> -   $(MAKE) -C $(dir)/ruby
> +   $(MAKE) -C $(dir)/ruby CFLAGS="$(CFLAGS) -pipe -fno-plt -fPIC"

forget my suggestion -- also in general, usually, make variables have more
"power" than defining such a thing in environment (would not be in those
cases there is intermediate wrapper which does not get the make variable...)

Tomi

>  endif
>
> We lose -march=x86-64 -mtune=generic (at least on my machine), but I
> guess that's not a big deal since libnotmuch itself isn't getting
> compiled with those.
>
> I'll send a patch soonish.
>
> -- 
> Felipe Contreras
> ___
> notmuch mailing list -- notmuch@notmuchmail.org
> To unsubscribe send an email to notmuch-le...@notmuchmail.org
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: [PATCH 1/4] bindings/ruby: unexport CFLAGS when building

2021-05-16 Thread Tomi Ollila
On Sun, May 16 2021, David Bremner wrote:

> This prevents breaking the ruby build when passing CFLAGS to other
> parts of the build.
> ---
>  bindings/Makefile.local | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/bindings/Makefile.local b/bindings/Makefile.local
> index bc960bbc..8e3cd051 100644
> --- a/bindings/Makefile.local
> +++ b/bindings/Makefile.local
> @@ -10,7 +10,7 @@ ifeq ($(HAVE_RUBY_DEV),1)
>   LIBNOTMUCH="../../lib/$(LINKER_NAME)" \
>   NOTMUCH_SRCDIR='$(NOTMUCH_SRCDIR)' \
>   $(RUBY) extconf.rb --vendor
> - $(MAKE) -C $(dir)/ruby
> + env -u CFLAGS $(MAKE) -C $(dir)/ruby

As you mentioned posix env does not have -u (that's shame),
perhaps CFLAGS= $(MAKE) -C $(dir)/ruby works -- that is slightly
different as now CFLAGS is defined in env, just empty.

Tomi

>  endif
>  
>  python-cffi-bindings: lib/$(LINKER_NAME)
> -- 
> 2.30.2
> ___
> notmuch mailing list -- notmuch@notmuchmail.org
> To unsubscribe send an email to notmuch-le...@notmuchmail.org
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: [PATCH 6/7] CLI: make static message strings const

2021-05-14 Thread Tomi Ollila
On Fri, May 14 2021, David Bremner wrote:

> Tomi Ollila  writes:
>
>>
>> In my projects I've been using the following macro:
>> #define WriteCS(fd, str) write((fd), (str), sizeof(str) - 1)
>> but I don't know if that behaved any better (if we cared)...
>
> I'm not sure. The sizeof here is actually slightly treacherous (iiuc,
> making things const char * will blow up the world) so I prefer it out in
> the open.

Right, const char * would make sizeof 8 (or 4).

(I just fixed bug somewhere where first 4 chars of strings were
compared for equality ;/).

The WriteCS meant (Const String), perhaps LS (Literal String) would be 
better. (and write((fd), "" str "", sizeof(str) - 1)).

... have to check if this works, and start using if it works as expected!

Tomi

>
>> But, in addition to these two identical copies of handle_sigint()
>> also notmuch-new.c and notmuch-reindex.c defines anoter 2 identical
>> copies of handle_sigint()...
>>
>> I did not see that those two were also modified in this series...
>
> Good catch! I did the same for those two and pushed the modified series.
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: [PATCH] emacs: do not unconditionally set mail-user-agent

2021-05-14 Thread Tomi Ollila
On Thu, May 13 2021, David Bremner wrote:

> A user that loads notmuch.el does not necessarily want to user
> notmuch-message-mode to send mail.

If this does not break anything, could be point release content,
provided it did not ship yet (then to the next sailing ship...).

> ---
>  emacs/notmuch.el | 2 --
>  1 file changed, 2 deletions(-)
>
> diff --git a/emacs/notmuch.el b/emacs/notmuch.el
> index 6d37c623..3e2713e2 100644
> --- a/emacs/notmuch.el
> +++ b/emacs/notmuch.el
> @@ -1162,8 +1162,6 @@ Point should be at the beginning of the line."
>  
>  ;;; _
>  
> -(setq mail-user-agent 'notmuch-user-agent)
> -
>  (provide 'notmuch)
>  
>  ;; After provide to avoid loops if notmuch was require'd via 
> notmuch-init-file.
> -- 
> 2.30.2
> ___
> notmuch mailing list -- notmuch@notmuchmail.org
> To unsubscribe send an email to notmuch-le...@notmuchmail.org
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: [PATCH v2 00/10] ruby: object cleanups

2021-05-11 Thread Tomi Ollila
On Tue, May 11 2021, Felipe Contreras wrote:

> On Tue, May 4, 2021 at 3:25 AM Felipe Contreras
>  wrote:
>>
>> On Tue, May 4, 2021 at 3:17 AM Felipe Contreras
>>  wrote:
>> >
>> > This superseeds my previous series [1] with much more cleanups.
>> >
>> > An important new change is the move towards RTypedData, which is way 
>> > superior to the old RData
>> > objects.
>> >
>> > Everything should work basically the same though.
>>
>> Please remove Austin Clements from the CC list, his address doesn't
>> work anymore.
>
> What's the status with these? Shall I split this series of 10 patches
> into multiple smaller patch series in order to reduce the reviewing
> burden?

I would not say it is burden to review the current series; just 
to find someone capable with time to test it (I personally only
use notmuch cli and emacs client, no skills w/ anything else
(than "trivial" things))

Tomi

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


Re: [PATCH 5/9] test: test relative paths for database.hook_dir

2021-05-07 Thread Tomi Ollila
On Fri, May 07 2021, David Bremner wrote:

> ---
>  test/T400-hooks.sh | 7 ++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/test/T400-hooks.sh b/test/T400-hooks.sh
> index 3a2df2f4..00c99337 100755
> --- a/test/T400-hooks.sh
> +++ b/test/T400-hooks.sh
> @@ -43,7 +43,7 @@ add_message
>  # create maildir structure for notmuch-insert
>  mkdir -p "$MAIL_DIR"/{cur,new,tmp}
>  
> -for config in traditional profile explicit XDG split; do
> +for config in traditional profile explicit relative XDG split; do
>  unset NOTMUCH_PROFILE
>  notmuch config set database.hook_dir
>  notmuch config set database.path ${MAIL_DIR}
> @@ -63,6 +63,11 @@ for config in traditional profile explicit XDG split; do
>   mkdir -p $HOOK_DIR
>   notmuch config set database.hook_dir $HOOK_DIR
>   ;;
> + relative)
> + HOOK_DIR=${HOME}/.notmuch-hooks
> + mkdir -p $HOOK_DIR

I'd drop the -p, to be sure $HOOK_DIR does not exist before test run
(if it existed, one notices when it fails (or not, we don't fail on error
:/ -- anyway noise to terminal/log (hopefully)


> + notmuch config set database.hook_dir .notmuch-hooks
> + ;;
>   XDG)
>   HOOK_DIR=${HOME}/.config/notmuch/default/hooks
>   ;;
> -- 
> 2.30.2
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH] test: say_color() in one write(2)

2021-05-06 Thread Tomi Ollila
say_color() used to call (builtin) printf (and tput(1) to stdout)
several times, which caused attempts to write messages with color
to have partial content (e.g. escape sequences) often intermixed
with other tests when parallel tests were run.

Now, with all output collected, then written out using one
printf, all strings with color print out correctly
((at least short) write(2)'s appear to write out "atomically").

While at it, used only one tput(1) execution to determine whether
color output works, and made bold/colors/sgr0 to tput(1) their
values once per test.
---
 test/test-lib.sh | 61 +++-
 1 file changed, 29 insertions(+), 32 deletions(-)

diff --git a/test/test-lib.sh b/test/test-lib.sh
index d46bb4c3..d7c96a93 100644
--- a/test/test-lib.sh
+++ b/test/test-lib.sh
@@ -201,56 +201,53 @@ do
 done
 
 if test -n "$debug"; then
-print_subtest () {
-   printf " %-4s" "[$((test_count - 1))]"
-}
+   fmt_subtest () {
+   printf -v $1 " %-4s" "[$((test_count - 1))]"
+   }
 else
-print_subtest () {
-   true
-}
+   fmt_subtest () {
+   printf -v $1 ''
+   }
 fi
 
 test -n "$COLORS_WITHOUT_TTY" || [ -t 1 ] || color=
 
-if [ -n "$color" ] && [ "$ORIGINAL_TERM" != 'dumb' ] && (
-   TERM=$ORIGINAL_TERM &&
-   export TERM &&
-   tput bold
-   tput setaf
-   tput sgr0
-   ) >/dev/null 2>&1
+if [ -n "$color" ] && [ "$ORIGINAL_TERM" != 'dumb' ] &&
+   tput -T "$ORIGINAL_TERM" -S <<<$'bold\nsetaf\nsgr0\n' >/dev/null 2>&1
 then
color=t
 else
color=
 fi
 
-if test -n "$color"; then
+if test -n "$color"
+then
+   # _tput run in subshell (``) only
+   _tput () { exec tput -T "$ORIGINAL_TERM" "$@"; }
+   unset BOLD RED GREEN BROWN SGR0
say_color () {
-   (
-   TERM=$ORIGINAL_TERM
-   export TERM
case "$1" in
-   error) tput bold; tput setaf 1;; # bold red
-   skip)  tput bold; tput setaf 2;; # bold green
-   pass)  tput setaf 2;;# green
-   info)  tput setaf 3;;# brown
-   *) test -n "$quiet" && return;;
+   error)  b=${BOLD=`_tput bold`}
+   c=${RED=`_tput setaf 1`}   ;; # bold red
+   skip)   b=${BOLD=`_tput bold`}
+   c=${GREEN=`_tput setaf 2`} ;; # bold green
+   pass)   b= c=${GREEN=`_tput setaf 2`} ;; # green
+   info)   b= c=${BROWN=`_tput setaf 3`} ;; # brown
+   *) b= c=; test -n "$quiet" && return ;;
esac
-   shift
-   printf " "
-   printf "$@"
-   tput sgr0
-   print_subtest
-   )
+   f=$2
+   shift 2
+   sgr0=${SGR0=`_tput sgr0`}
+   fmt_subtest st
+   printf " ${b}${c}${f}${sgr0}${st}" "$@"
}
 else
say_color() {
test -z "$1" && test -n "$quiet" && return
-   shift
-   printf " "
-   printf "$@"
-   print_subtest
+   f=$2
+   shift 2
+   fmt_subtest st
+   printf " ${f}${st}" "$@"
}
 fi
 
-- 
2.25.1

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


Re: [PATCH 1/9] test: move test_ruby() inside the only client

2021-05-02 Thread Tomi Ollila
On Sun, May 02 2021, David Bremner wrote:

> Felipe Contreras  writes:
>
>> Not much point in polluting the main library, and also will be useful to
>> modify it in tandem with the tests.
>>
>
> I can live with this change.

I'd say strong LGTM :D

Tomi

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


[PATCH] test: replace notmuch_passwd_sanitize() with _libconfig_sanitize()

2021-05-02 Thread Tomi Ollila
notmuch_passwd_sanitize() in test-lib.sh is too generic, it cannot
work in many cases...

The more specific version _libconfig_sanitize() replaces it in
T590-libconfig.sh and the code that uses it is modified to output
the keys (ascending numbers printed in hex) so the sanitizer knows
what to sanitize in which lines...

In addition to ".(none)" now also ".localdomain" if filtered from
USERNAME@FQDN.
---

On fedora 34 I got that ".localdomain" suffix.

 test/T590-libconfig.sh | 97 +-
 test/test-lib.sh   | 21 -
 2 files changed, 59 insertions(+), 59 deletions(-)

diff --git a/test/T590-libconfig.sh b/test/T590-libconfig.sh
index 51dd29c8..3587e607 100755
--- a/test/T590-libconfig.sh
+++ b/test/T590-libconfig.sh
@@ -5,6 +5,26 @@ test_description="library config API"
 
 add_email_corpus
 
+_libconfig_sanitize()
+{
+${NOTMUCH_PYTHON} -c'
+import os, sys, pwd, socket
+
+pw = pwd.getpwuid(os.getuid())
+user = pw.pw_name
+name = pw.pw_gecos.partition(",")[0]
+fqdn = socket.getaddrinfo(socket.gethostname(), 0, 0,
+  socket.SOCK_STREAM, 0, socket.AI_CANONNAME)[0][3]
+for l in sys.stdin:
+if l[:3] == "8: ":
+l = l.replace(user, "USERNAME").replace(fqdn, "FQDN")
+l = l.replace(".(none)","").replace(".localdomain", "")
+elif l[:3] == "a: ":
+l = l.replace(name, "USER_FULL_NAME")
+sys.stdout.write(l)
+'
+}
+
 cat < c_head
 #include 
 #include 
@@ -380,26 +400,26 @@ cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR} '' %NULL%
 key < NOTMUCH_CONFIG_LAST;
 key = (notmuch_config_key_t)(key + 1)) {
const char *val = notmuch_config_get (db, key);
-printf("%s\n", val ? val : "NULL" );
+   printf("%x: '%s'\n", key, val ? val : "NULL" );
 }
 }
 EOF
 
-notmuch_passwd_sanitize < OUTPUT > OUTPUT.clean
+_libconfig_sanitize < OUTPUT > OUTPUT.clean
 
 cat <<'EOF' >EXPECTED
 == stdout ==
-MAIL_DIR
-MAIL_DIR
-MAIL_DIR/.notmuch/hooks
-MAIL_DIR/.notmuch/backups
-
-unread;inbox
-
-true
-USERNAME@FQDN
-NULL
-USER_FULL_NAME
+0: 'MAIL_DIR'
+1: 'MAIL_DIR'
+2: 'MAIL_DIR/.notmuch/hooks'
+3: 'MAIL_DIR/.notmuch/backups'
+4: ''
+5: 'unread;inbox'
+6: ''
+7: 'true'
+8: 'USERNAME@FQDN'
+9: 'NULL'
+a: 'USER_FULL_NAME'
 == stderr ==
 EOF
 unset MAILDIR
@@ -694,23 +714,23 @@ cat c_head2 - c_tail <<'EOF' | test_C ${MAIL_DIR} %NULL% 
%NULL%
 key < NOTMUCH_CONFIG_LAST;
 key = (notmuch_config_key_t)(key + 1)) {
const char *val = notmuch_config_get (db, key);
-printf("%s\n", val ? val : "NULL" );
+   printf("%x: '%s'\n", key, val ? val : "NULL" );
 }
 }
 EOF
 cat <<'EOF' >EXPECTED
 == stdout ==
-MAIL_DIR
-MAIL_DIR
-MAIL_DIR/.notmuch/hooks
-MAIL_DIR/.notmuch/backups
-foo;bar;fub
-unread;inbox
-sekrit_junk
-true
-test_su...@notmuchmail.org
-test_suite_ot...@notmuchmail.org;test_su...@otherdomain.org
-Notmuch Test Suite
+0: 'MAIL_DIR'
+1: 'MAIL_DIR'
+2: 'MAIL_DIR/.notmuch/hooks'
+3: 'MAIL_DIR/.notmuch/backups'
+4: 'foo;bar;fub'
+5: 'unread;inbox'
+6: 'sekrit_junk'
+7: 'true'
+8: 'test_su...@notmuchmail.org'
+9: 'test_suite_ot...@notmuchmail.org;test_su...@otherdomain.org'
+a: 'Notmuch Test Suite'
 == stderr ==
 EOF
 test_expect_equal_file EXPECTED OUTPUT
@@ -723,25 +743,26 @@ cat c_head2 - c_tail <<'EOF' | test_C ${MAIL_DIR} 
/nonexistent %NULL%
 key < NOTMUCH_CONFIG_LAST;
 key = (notmuch_config_key_t)(key + 1)) {
const char *val = notmuch_config_get (db, key);
-   printf("%s\n", val ? val : "NULL" );
+   printf("%x: '%s'\n", key, val ? val : "NULL" );
 }
 }
 EOF
 
-notmuch_passwd_sanitize < OUTPUT > OUTPUT.clean
+_libconfig_sanitize < OUTPUT > OUTPUT.clean
+
 cat <<'EOF' >EXPECTED
 == stdout ==
-MAIL_DIR
-MAIL_DIR
-MAIL_DIR/.notmuch/hooks
-MAIL_DIR/.notmuch/backups
-
-unread;inbox
-
-true
-USERNAME@FQDN
-NULL
-USER_FULL_NAME
+0: 'MAIL_DIR'
+1: 'MAIL_DIR'
+2: 'MAIL_DIR/.notmuch/hooks'
+3: 'MAIL_DIR/.notmuch/backups'
+4: ''
+5: 'unread;inbox'
+6: ''
+7: 'true'
+8: 'USERNAME@FQDN'
+9: 'NULL'
+a: 'USER_FULL_NAME'
 == stderr ==
 EOF
 test_expect_equal_file EXPECTED OUTPUT.clean
diff --git a/test/test-lib.sh b/test/test-lib.sh
index d46bb4c3..777b5dd9 100644
--- a/test/test-lib.sh
+++ b/test/test-lib.sh
@@ -710,27 +710,6 @@ notmuch_built_with_sanitize ()
 sed 's/^built_with[.]\(.*\)=.*$/built_with.\1=something/'
 }
 
-notmuch_passwd_sanitize()
-{
-${NOTMUCH_PYTHON} -c'
-import os, sys, pwd, socket
-
-pw = pwd.getpwuid(os.getuid())
-user = pw.pw_name
-name = pw.pw_gecos.partition(",")[0]
-fqdn = socket.getaddrinfo(socket.gethostname(), 0, 0, socket.SOCK_STREAM, 0, 
socket.AI_CANONNAME)[0][3]
-
-for l in sys.stdin:
-if user:
-l = l.replace(user, "USERNAME")
-if fqdn:
-l = l.replace(fqdn, "FQDN").replace(".(none)","")
-if name:
-l = l.replace(name, "USER_FULL_NAME")
-sys.stdout.write(l)
-'
-}
-
 notmuch_config_sanitize ()
 {
 notmuch_dir_sanitize | notmuch_built_with_sanitize
-- 
2.31.1


Re: [PATCH 00/13] test: several fixes and improvements

2021-05-01 Thread Tomi Ollila
On Sat, May 01 2021, David Bremner wrote:

> Felipe Contreras  writes:
>
>> The current tests fail on my machine due to my configuration, mainly because 
>> I didn't have dtach
>> installed, but also other stuff.
>>
>> The following patches fix all the issues I found, and also do plenty of 
>> cleanups.
>
> I have applied 1,2,4,5,6,7 to master.  10, 11, and 12 are also marked
> ready to apply, but currently don't because of skipped patches.

Good progress !

Now in the morning, after good night's sleep, I think of the following:

The following changes could be done (in 2 or 3 (3 for consistency) places):

--- a/test/T590-libconfig.sh
+++ b/test/T590-libconfig.sh
@@ -375,18 +375,19 @@ test_begin_subtest "load default values"
 export MAILDIR=${MAIL_DIR}
 cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR} '' %NULL%
 {
 notmuch_config_key_t key;
 for (key = NOTMUCH_CONFIG_FIRST;
 key < NOTMUCH_CONFIG_LAST;
 key = (notmuch_config_key_t)(key + 1)) {
 const char *val = notmuch_config_get (db, key);
 printf("%s\n", val ? val : "NULL" );
+printf("%s = %s\n", key, val ? val : "NULL" );
 }
 }
 EOF
 
Then, update the EXPECTED strings.

Finally, move the notmuch_passwd_sanitize () from lib to 
T590-libconfig.sh (perhaps rename to more "specialized"
name) and change it to first match key before replacing
the value in the c program output (and replace to empty
strings, too!).

I am soon going somewhere, I'll look this in the evening
in (+0300 timezone) unless someone(tm) is faster there...

>
> d

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


Re: [PATCH 04/13] test: use correct fqdn in passwd_sanitize()

2021-05-01 Thread Tomi Ollila
On Sat, May 01 2021, Felipe Contreras wrote:

> My fqdn is 'natae.localdomain', however, socket.getfqdn() returns
> 'localhost'.
>
> To fetch the true fqdn we need socket.getaddrinfo().
>
> For more information see: https://stackoverflow.com/a/11580042/10474
>
> Signed-off-by: Felipe Contreras 
> ---
>  test/test-lib.sh | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/test/test-lib.sh b/test/test-lib.sh
> index ae653363..21dda265 100644
> --- a/test/test-lib.sh
> +++ b/test/test-lib.sh
> @@ -709,7 +709,7 @@ import os, sys, pwd, socket
>  pw = pwd.getpwuid(os.getuid())
>  user = pw.pw_name
>  name = pw.pw_gecos.partition(",")[0]
> -fqdn = socket.getfqdn()
> +fqdn = socket.getaddrinfo(socket.gethostname(), 0, 0, socket.SOCK_STREAM, 0, 
> socket.AI_CANONNAME)[0][3]

I trust you this works better. 

LGTM.

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


Re: [PATCH 03/13] test: remove USER_FULL_NAME when not present

2021-05-01 Thread Tomi Ollila
On Sat, May 01 2021, Felipe Contreras wrote:

> If a full name is not configured, the output is empty.

> This is possibly not portable, but it's a start.
>
> Signed-off-by: Felipe Contreras 
> ---
>  test/T590-libconfig.sh | 10 ++
>  1 file changed, 10 insertions(+)
>
> diff --git a/test/T590-libconfig.sh b/test/T590-libconfig.sh
> index 51dd29c8..36d9af1b 100755
> --- a/test/T590-libconfig.sh
> +++ b/test/T590-libconfig.sh
> @@ -5,6 +5,14 @@ test_description="library config API"
>  
>  add_email_corpus
>  
> +get_name () {
> +if hash getent 2>/dev/null; then
> +getent passwd "$USER" | cut -d ':' -f 5
> +else
> +echo "Foo Bar"
> +fi
> +}

I'd do

if test -n "$(getent passwd "$USER" | cut -d ':' -f 5)
then
USER_FULL_NAME=USER_FULL_NAME
else
USER_FULL_NAME=
fi

and then e.g.

cat <<"EOF" >EXPECTED
== stdout ==
MAIL_DIR
...
$USER_FULL_NAME
== stderr ==
EOF

if getent does not exist, then we'd get empty string
and $USER_FULL_NAME empty (as good as "Foo bar")


> +
>  cat < c_head
>  #include 
>  #include 
> @@ -402,6 +410,7 @@ NULL
>  USER_FULL_NAME
>  == stderr ==
>  EOF
> +test "$(get_name)" = "" && sed -e "s/USER_FULL_NAME//" -i EXPECTED
>  unset MAILDIR
>  test_expect_equal_file EXPECTED OUTPUT.clean
>  
> @@ -744,6 +753,7 @@ NULL
>  USER_FULL_NAME
>  == stderr ==
>  EOF
> +test "$(get_name)" = "" && sed -e "s/USER_FULL_NAME//" -i EXPECTED
>  test_expect_equal_file EXPECTED OUTPUT.clean
>  
>  backup_database
> -- 
> 2.31.0
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: [PATCH 02/13] test: unset NAME environment variable

2021-05-01 Thread Tomi Ollila
On Sat, May 01 2021, Felipe Contreras wrote:

> Otherwise the output from the tests would be different.
>
> Signed-off-by: Felipe Contreras 
> ---
>  test/test-lib.sh | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/test/test-lib.sh b/test/test-lib.sh
> index e13797a7..ae653363 100644
> --- a/test/test-lib.sh
> +++ b/test/test-lib.sh
> @@ -112,6 +112,7 @@ unset ALTERNATE_EDITOR
>  
>  # for reproducibility
>  unset EMAIL
> +unset NAME

LGTM. trivial

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


Re: [PATCH 01/13] test: fix passwd_sanitize()

2021-05-01 Thread Tomi Ollila
On Sat, May 01 2021, Felipe Contreras wrote:

> If any of the variables is empty the output is completely messed up,
> because replace("", "FOO") puts "FOO" before every single character.
>
> I don't have my full name configured, and this is what I get:
>
>   USER_FULL_NAME=USER_FULL_NAME=USER_FULL_NAME 
> USER_FULL_NAMEsUSER_FULL_NAMEtUSER_FULL_NAMEdUSER_FULL_NAMEoUSER_FULL_NAMEuUSER_FULL_NAMEtUSER_FULL_NAME
>  USER_FULL_NAME=USER_FULL_NAME=USER_FULL_NAME
>
> Let's check for empty strings before doing any replace.
>
> Signed-off-by: Felipe Contreras 
> ---
>  test/test-lib.sh | 7 ++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/test/test-lib.sh b/test/test-lib.sh
> index 4c9f2a21..e13797a7 100644
> --- a/test/test-lib.sh
> +++ b/test/test-lib.sh
> @@ -711,7 +711,12 @@ name = pw.pw_gecos.partition(",")[0]
>  fqdn = socket.getfqdn()
>  
>  for l in sys.stdin:
> -l = l.replace(user, "USERNAME").replace(fqdn, 
> "FQDN").replace(".(none)","").replace(name, "USER_FULL_NAME")
> +if user:
> +l = l.replace(user, "USERNAME")
> +if fqdn:
> +l = l.replace(fqdn, "FQDN").replace(".(none)","")
> +if name:
> +l = l.replace(name, "USER_FULL_NAME")

This looks like a good change.

This made me think of something. When I quickly deviced the initial code of
this I thinkoed that str.replace() replaces only the first match -- now
that I tested (in python3 repl) it replaces *all* matches...

In my home machines I usually have both "username" and "user_full_name"
(using the terms used in the sanitizer) as 'too'...

Currently all is lost in USER_FULL_NAME replacement -- all 'too's are
replaced with USERNAME and no USER_FULL_NAME replacements happen.
If we had l.replace(user, "USERNAME", 1) then only the first match were
replaced -- and if both matches are expected to happen in same line --
the "full name" replacement later in line, then this change would help
in such a cases. If these replacements are to be done in different lines
then the USERNAME replacement would always be done and nothing helps
there (except more specific replacement code)...

And, now as this chance of having empty username come into our
understanding, instead of empty, but some short (or why not longer) strings 
that just happen to be (sub)strings of the text it gets as input we get
unwanted replacements and test failures... :/

Tomi


>  sys.stdout.write(l)
>  '
>  }
> -- 
> 2.31.0
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: [PATCH] perf-test: add option to run perf

2021-04-25 Thread Tomi Ollila
On Sun, Apr 25 2021, David Bremner wrote:

> Although the generation of perf data is not as slow as valgrind, it
> seems simplest to re-use the machinery already there to save the logs
> in a timestamped subdirectory.
> ---
>
> I'm not sure about the use of --call-graph=lbr here. On the one hand,
> the documentation mentions it depends on recent intel hardware. On the
> other hand, fp does not work for me (just gives 000) and dwarf
> yields giant data files that take painfully long to run "perf report"
> on.
>
>
>  performance-test/perf-test-lib.sh | 27 +++
>  1 file changed, 23 insertions(+), 4 deletions(-)
>
> diff --git a/performance-test/perf-test-lib.sh 
> b/performance-test/perf-test-lib.sh
> index b70288cc..216d1824 100644
> --- a/performance-test/perf-test-lib.sh
> +++ b/performance-test/perf-test-lib.sh
> @@ -2,6 +2,7 @@
>  
>  corpus_size=large
>  
> +use_perf=0
>  while test "$#" -ne 0

In above, newline consistency (perhaps all vars in "block", then
newline). Now that this is added perhaps debug also (or is it
supposed that debug=t from environment has effect ;)

>  do
>   case "$1" in
> @@ -9,6 +10,10 @@ do
>   debug=t;
>   shift
>   ;;
> + -p|--perf)
> + use_perf=1;
> + shift
> + ;;
>   -s|--small)
>   corpus_size=small;
>   shift
> @@ -127,10 +132,20 @@ notmuch_new_with_cache ()
>  fi
>  }
>  
> +make_log_dir () {
> +local timestamp=$(date +%Y%m%dT%H%M%S)
> +log_dir="${TEST_DIRECTORY}/log.$(basename $0)-$corpus_size-${timestamp}"
> +mkdir -p ${log_dir}

This is copy from deleted code -- just that quoting is just as "wrong" as
it can be >;) -- var=val does not need quotes, OTOH "val" in command
argument does need quotes (in order to escape $IFS splitting) -- if that
mattered.

> +}
> +
>  time_start ()
>  {
>  add_email_corpus
>  
> +if [[ "X$use_perf" = "X1" ]]; then

Consistently w/  [[ "$corpus_size" != "large" ]] just if [[ "$use_perf" = 1 ]]

> + make_log_dir
> +fi
> +
>  print_header
>  
>  notmuch_new_with_cache time_run
> @@ -140,9 +155,7 @@ memory_start ()
>  {
>  add_email_corpus
>  
> -local timestamp=$(date +%Y%m%dT%H%M%S)
> -log_dir="${TEST_DIRECTORY}/log.$(basename $0)-$corpus_size-${timestamp}"
> -mkdir -p ${log_dir}
> +make_log_dir
>  
>  notmuch_new_with_cache memory_run
>  }
> @@ -193,7 +206,13 @@ time_run ()
>  printf "  %-22s" "$1"
>  test_count=$(($test_count+1))
>  if test "$verbose" != "t"; then exec 4>test.output 3>&4; fi
> -if ! eval >&3 "/usr/bin/time -f '%e\t%U\t%S\t%M\t%I/%O' $2" ; then
> +if [[ "X$use_perf" = "X1" ]]; then

ditto

> + command_str="perf record --call-graph=lbr -o 
> ${log_dir}/${test_count}.perf $2"
> +else
> + command_str="/usr/bin/time -f '%e\t%U\t%S\t%M\t%I/%O' $2"
> +fi
> +
> +if ! eval >&3 "$command_str" ; then
>   test_failure=$(($test_failure + 1))
>   return 1
>  fi
> -- 
> 2.30.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   >