Re: [PATCH] emacs: notmuch-tree: customizable strings for drawing trees

2021-08-22 Thread Jose Antonio Ortega Ruiz


This one should have been sent with a version 3 mark, sorry.  It's
essentially the previous version (with yet another doc typo corrected),
but rebased against today's master.

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


[PATCH] CLI: make variable n_requested_db_uuid file scope.

2021-08-22 Thread David Bremner
It turns out that now that we pass an open database into the
subcommands, it is easy to check any requested uuid against the
database at the same time as we process the other shared
arguments. This results in overall less boilerplate code, as well as
making a CLI scope function and variable file scope in notmuch.c.
---
 notmuch-client.h |  4 +---
 notmuch-compact.c|  7 +--
 notmuch-config.c |  4 
 notmuch-count.c  |  4 +---
 notmuch-dump.c   |  4 +---
 notmuch-insert.c |  4 +---
 notmuch-new.c|  4 +---
 notmuch-reindex.c|  4 +---
 notmuch-reply.c  |  4 +---
 notmuch-restore.c|  3 +--
 notmuch-search.c |  6 ++
 notmuch-setup.c  |  4 
 notmuch-show.c   |  4 +---
 notmuch-tag.c|  4 +---
 notmuch.c| 24 ++--
 test/random-corpus.c |  3 ++-
 16 files changed, 33 insertions(+), 54 deletions(-)

diff --git a/notmuch-client.h b/notmuch-client.h
index 8643a63f..f820791f 100644
--- a/notmuch-client.h
+++ b/notmuch-client.h
@@ -485,11 +485,9 @@ print_status_gzbytes (const char *loc,
 
 #include "command-line-arguments.h"
 
-extern const char *notmuch_requested_db_uuid;
 extern const notmuch_opt_desc_t notmuch_shared_options [];
-void notmuch_exit_if_unmatched_db_uuid (notmuch_database_t *notmuch);
 
-void notmuch_process_shared_options (const char *subcommand_name);
+void notmuch_process_shared_options (notmuch_database_t *notmuch, const char 
*subcommand_name);
 int notmuch_minimal_options (const char *subcommand_name,
 int argc, char **argv);
 
diff --git a/notmuch-compact.c b/notmuch-compact.c
index 2648434e..40ffb428 100644
--- a/notmuch-compact.c
+++ b/notmuch-compact.c
@@ -45,12 +45,7 @@ notmuch_compact_command (notmuch_database_t *notmuch, int 
argc, char *argv[])
 if (opt_index < 0)
return EXIT_FAILURE;
 
-if (notmuch_requested_db_uuid) {
-   fprintf (stderr, "Error: --uuid not implemented for compact\n");
-   return EXIT_FAILURE;
-}
-
-notmuch_process_shared_options (argv[0]);
+notmuch_process_shared_options (NULL, argv[0]);
 
 if (! quiet)
printf ("Compacting database...\n");
diff --git a/notmuch-config.c b/notmuch-config.c
index 4de55e5f..80a207f6 100644
--- a/notmuch-config.c
+++ b/notmuch-config.c
@@ -708,10 +708,6 @@ notmuch_config_command (notmuch_database_t *notmuch, int 
argc, char *argv[])
 if (opt_index < 0)
return EXIT_FAILURE;
 
-if (notmuch_requested_db_uuid)
-   fprintf (stderr, "Warning: ignoring --uuid=%s\n",
-notmuch_requested_db_uuid);
-
 /* skip at least subcommand argument */
 argc -= opt_index;
 argv += opt_index;
diff --git a/notmuch-count.c b/notmuch-count.c
index 5ac4292b..e8c545e3 100644
--- a/notmuch-count.c
+++ b/notmuch-count.c
@@ -182,7 +182,7 @@ notmuch_count_command (notmuch_database_t *notmuch, int 
argc, char *argv[])
 if (opt_index < 0)
return EXIT_FAILURE;
 
-notmuch_process_shared_options (argv[0]);
+notmuch_process_shared_options (notmuch, argv[0]);
 
 if (input_file_name) {
batch = true;
@@ -201,8 +201,6 @@ notmuch_count_command (notmuch_database_t *notmuch, int 
argc, char *argv[])
return EXIT_FAILURE;
 }
 
-notmuch_exit_if_unmatched_db_uuid (notmuch);
-
 query_str = query_string_from_args (notmuch, argc - opt_index, argv + 
opt_index);
 if (query_str == NULL) {
fprintf (stderr, "Out of memory.\n");
diff --git a/notmuch-dump.c b/notmuch-dump.c
index ae89e4da..5c8213be 100644
--- a/notmuch-dump.c
+++ b/notmuch-dump.c
@@ -366,8 +366,6 @@ notmuch_dump_command (notmuch_database_t *notmuch, int 
argc, char *argv[])
 const char *query_str = NULL;
 int ret;
 
-notmuch_exit_if_unmatched_db_uuid (notmuch);
-
 const char *output_file_name = NULL;
 int opt_index;
 
@@ -394,7 +392,7 @@ notmuch_dump_command (notmuch_database_t *notmuch, int 
argc, char *argv[])
 if (opt_index < 0)
return EXIT_FAILURE;
 
-notmuch_process_shared_options (argv[0]);
+notmuch_process_shared_options (notmuch, argv[0]);
 
 if (include == 0)
include = DUMP_INCLUDE_CONFIG | DUMP_INCLUDE_TAGS | 
DUMP_INCLUDE_PROPERTIES;
diff --git a/notmuch-insert.c b/notmuch-insert.c
index e3d87e4a..72e2e35f 100644
--- a/notmuch-insert.c
+++ b/notmuch-insert.c
@@ -478,7 +478,7 @@ notmuch_insert_command (notmuch_database_t *notmuch, int 
argc, char *argv[])
 if (opt_index < 0)
return EXIT_FAILURE;
 
-notmuch_process_shared_options (argv[0]);
+notmuch_process_shared_options (notmuch, argv[0]);
 
 mail_root = notmuch_config_get (notmuch, NOTMUCH_CONFIG_MAIL_ROOT);
 
@@ -550,8 +550,6 @@ notmuch_insert_command (notmuch_database_t *notmuch, int 
argc, char *argv[])
return EXIT_FAILURE;
 }
 
-notmuch_exit_if_unmatched_db_uuid (notmuch);
-
 status = notmuch_process_shared_indexing_options (notmuch);
 if (status != NOTMUCH_STATUS_SUCCESS) {
  

[PATCH] emacs: notmuch-tree: customizable strings for drawing trees

2021-08-22 Thread jao
New customizable variable, notmuch-tree-thread-symbols, that allows
tweaking of how trees in a forest are represented.  For instance, one
can now choose to use an hyphen rather than a white space as a prefix,
or replace the character(s) used to draw arrows.
---
 emacs/notmuch-tree.el | 36 ++--
 1 file changed, 26 insertions(+), 10 deletions(-)

diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el
index 2f508128..a1dfa7b1 100644
--- a/emacs/notmuch-tree.el
+++ b/emacs/notmuch-tree.el
@@ -74,6 +74,22 @@
   notmuch-unthreaded-show-out
 notmuch-tree-show-out))
 
+(defcustom notmuch-tree-thread-symbols '(" " "─" "┬" "│" "├" "╰" "►")
+  "List of strings used to draw trees in notmuch tree results.
+The first element is used at the top of the tree, followed by the
+second if it has no children or the third if it does.  The fourth
+is a bar connecting with a response down the list skipping the
+current one, while the fifth marks the current message as a reply
+to the previous.  The sixth string is used at the bottom of
+threads.  Finally, the last string in the list is used as a
+pointer to every message.
+
+Common customizations include setting the first element of the
+list to \"-\", to see equal-length prefixes, or the last to an
+empty string or to a different kind of arrow point."
+  :type '(list string)
+  :group 'notmuch-tree)
+
 (defcustom notmuch-tree-result-format
   `(("date" . "%12s  ")
 ("authors" . "%-20s")
@@ -968,20 +984,20 @@ message together with all its descendents."
(replies (cadr tree)))
 (cond
  ((and (< 0 depth) (not last))
-  (push "├" tree-status))
+  (push (elt notmuch-tree-thread-symbols 4) tree-status))
  ((and (< 0 depth) last)
-  (push "╰" tree-status))
+  (push (elt notmuch-tree-thread-symbols 5) tree-status))
  ((and (eq 0 depth) first last)
-  ;; Choice between these two variants is a matter of taste.
-  ;; (push "─" tree-status))
-  (push " " tree-status))
+  (push (elt notmuch-tree-thread-symbols 0) tree-status))
  ((and (eq 0 depth) first (not last))
-  (push "┬" tree-status))
+  (push (elt notmuch-tree-thread-symbols 2) tree-status))
  ((and (eq 0 depth) (not first) last)
-  (push "╰" tree-status))
+  (push (elt notmuch-tree-thread-symbols 5) tree-status))
  ((and (eq 0 depth) (not first) (not last))
-  (push "├" tree-status)))
-(push (concat (if replies "┬" "─") "►") tree-status)
+  (push (elt notmuch-tree-thread-symbols 4) tree-status)))
+(push (concat (elt notmuch-tree-thread-symbols (if replies 2 1))
+ (elt notmuch-tree-thread-symbols 6))
+ tree-status)
 (setq msg (plist-put msg :first (and first (eq 0 depth
 (setq msg (plist-put msg :tree-status tree-status))
 (setq msg (plist-put msg :orig-tags (plist-get msg :tags)))
@@ -990,7 +1006,7 @@ message together with all its descendents."
 (pop tree-status)
 (if last
(push " " tree-status)
-  (push "│" tree-status))
+  (push (elt notmuch-tree-thread-symbols 3) tree-status))
 (notmuch-tree-insert-thread replies (1+ depth) tree-status)))
 
 (defun notmuch-tree-insert-thread (thread depth tree-status)
-- 
2.33.0
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


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

2021-08-22 Thread David Bremner
David Bremner  writes:

> 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

series applied to master.

d
___
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 David Bremner
David Bremner  writes:

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

applied to master
___
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 &optional 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_

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