Re: [PATCH 2/2] cli: notmuch show support for --include-html with --format=text

2018-11-23 Thread Tomi Ollila
On Wed, Oct 31 2018, ma...@kakoune.org wrote:

> From: Maxime Coste 

To me these changes looks simple and trivial enough to be merged
(if these works, but code LGTM)

Tomi


>
> ---
>  NEWS  |  3 ++-
>  doc/man1/notmuch-show.rst | 11 ++-
>  notmuch-show.c|  9 ++---
>  test/T190-multipart.sh|  9 +
>  4 files changed, 23 insertions(+), 9 deletions(-)
>
> diff --git a/NEWS b/NEWS
> index 64de..434f920a 100644
> --- a/NEWS
> +++ b/NEWS
> @@ -4,7 +4,8 @@ Notmuch 0.29 (UNRELEASED)
>  Command Line Interface
>  --
>  
> -`notmuch show` now supports --body=false with --format=text
> +`notmuch show` now supports --body=false and --include-html with
> +--format=text
>  
>  Notmuch 0.28 (2018-10-12)
>  =
> diff --git a/doc/man1/notmuch-show.rst b/doc/man1/notmuch-show.rst
> index f3c32fd2..a2708a04 100644
> --- a/doc/man1/notmuch-show.rst
> +++ b/doc/man1/notmuch-show.rst
> @@ -183,11 +183,12 @@ Supported options for **show** include
>  output is much faster and substantially smaller.
>  
>  ``--include-html``
> -Include "text/html" parts as part of the output (currently only
> -supported with ``--format=json`` and ``--format=sexp``). By default,
> -unless ``--part=N`` is used to select a specific part or
> -``--include-html`` is used to include all "text/html" parts, no
> -part with content type "text/html" is included in the output.
> +Include "text/html" parts as part of the output (currently
> +only supported with ``--format=text``, ``--format=json`` and
> +``--format=sexp``). By default, unless ``--part=N`` is used to
> +select a specific part or ``--include-html`` is used to include all
> +"text/html" parts, no part with content type "text/html" is included
> +in the output.
>  
>  A common use of **notmuch show** is to display a single thread of email
>  messages. For this, use a search term of "thread:" as can be
> diff --git a/notmuch-show.c b/notmuch-show.c
> index 42fe27cc..07e9a5db 100644
> --- a/notmuch-show.c
> +++ b/notmuch-show.c
> @@ -584,7 +584,8 @@ format_part_text (const void *ctx, sprinter_t *sp, 
> mime_node_t *node,
>  
>  if (leaf) {
>   if (g_mime_content_type_is_type (content_type, "text", "*") &&
> - !g_mime_content_type_is_type (content_type, "text", "html"))
> + (params->include_html ||
> +  ! g_mime_content_type_is_type (content_type, "text", "html")))
>   {
>   show_text_part_content (node->part, stream, 0);
>   } else {
> @@ -1218,8 +1219,10 @@ notmuch_show_command (notmuch_config_t *config, int 
> argc, char *argv[])
>  }
>  
>  if (params.include_html &&
> -(format != NOTMUCH_FORMAT_JSON && format != NOTMUCH_FORMAT_SEXP)) {
> - fprintf (stderr, "Warning: --include-html only implemented for 
> format=json and format=sexp\n");
> +(format != NOTMUCH_FORMAT_TEXT &&
> +  format != NOTMUCH_FORMAT_JSON &&
> +  format != NOTMUCH_FORMAT_SEXP)) {
> + fprintf (stderr, "Warning: --include-html only implemented for 
> format=text, format=json and format=sexp\n");
>  }
>  
>  query_string = query_string_from_args (config, argc-opt_index, 
> argv+opt_index);
> diff --git a/test/T190-multipart.sh b/test/T190-multipart.sh
> index 81c4d772..9ad141cb 100755
> --- a/test/T190-multipart.sh
> +++ b/test/T190-multipart.sh
> @@ -325,6 +325,15 @@ Non-text part: text/html
>  EOF
>  test_expect_equal_file EXPECTED OUTPUT
>  
> +test_begin_subtest "--format=text --include-html --part=5, rfc822's html 
> part"
> +notmuch show --format=text --include-html --part=5 
> 'id:87liy5ap00@yoom.home.cworth.org' >OUTPUT
> +cat  +part{ ID: 5, Content-type: text/html
> +This is an embedded message, with a multipart/alternative part.
> +part}
> +EOF
> +test_expect_equal_file EXPECTED OUTPUT
> +
>  test_begin_subtest "--format=text --part=6, rfc822's text part"
>  notmuch show --format=text --part=6 'id:87liy5ap00@yoom.home.cworth.org' 
> >OUTPUT
>  cat  -- 
> 2.14.5
>
> ___
> notmuch mailing list
> notmuch@notmuchmail.org
> https://notmuchmail.org/mailman/listinfo/notmuch
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


Re: [FEATURE] Purge ignored messages from index

2018-11-23 Thread Markus Weimar
Thanks for your reply! I only installed notmuch today, so please take this into 
account when considering my thoughts.

On Thu, 2018-11-22 13:33:06 -0400, David Bremner wrote:
> My first instinct would be to leave new as is, but change reindex to pay
> attention to some ignore parameter.

´new´ already removes messages from the index if the files are gone. Removing 
those but keeping newly ignored messages seems inconsistent to me and it did 
confuse me.

Why would I ever want to keep an ignored email in the index? In regard to 
indexing, I don’t see much of a difference between deleted and ignored. I don’t 
want search results for either.

I’d guess setting up notmuch and creating a ´notmuch new´ cronjob is not that 
uncommon. If a user later adds ignores, they are likely to run into this issue. 
If the indexing followed the config by purging anything ignored, this would 
“just work.”

Best wishes,
Markus
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


Re: [FEATURE] Purge ignored messages from index

2018-11-23 Thread Markus Weimar
On Thu, 2018-11-22 16:49:56 -0400, David Bremner wrote:
> Notmuch new works very hard to not visit files that haven't
> changed. Changing this would have a big negative performance impact, afaik.

I see. I thought it might be possible to purge the entries without looking at 
any files by doing a cheap comparison of indexed file path against ignored 
patterns. If that’s not possible, I agree that ´new´ shouldn’t be slowed down 
for this edge case.

> I care less about the performance of reindex; also it already
> rescans all the relevant messages, so I guess the performance impact
> would not be that bad.

Makes sense to me. Short notes in the docs and config file to run ´reindex 
'folder:'´ after adding new ignore patterns would prevent any such 
confusion.

Take care,
Markus
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


Re: [FEATURE] Purge ignored messages from index

2018-11-23 Thread David Bremner
Markus Weimar  writes:

> On Thu, 2018-11-22 16:49:56 -0400, David Bremner wrote:
>> Notmuch new works very hard to not visit files that haven't
>> changed. Changing this would have a big negative performance impact, afaik.
>
> I see. I thought it might be possible to purge the entries without
> looking at any files by doing a cheap comparison of indexed file path
> against ignored patterns. If that’s not possible, I agree that ´new´
> shouldn’t be slowed down for this edge case.
>

File paths aren't really indexed, only the directory part.

d


___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch