Re: [PATCH] cli/show: list all filenames of a message in the formatted output

2017-01-28 Thread Jani Nikula
On Wed, 25 Jan 2017, Tomi Ollila  wrote:
> On Tue, Jan 10 2017, Jani Nikula  wrote:
>
>> Instead of just having the first filename for the message, list all
>> duplicate filenames of the message as a list in the formatted
>> outputs. This bumps the format version to 3.
>
> Great stuff -- just now quite a few (~33) tests fail ;)

I'll fix that up iff we decide this is the way to go.

BR,
Jani.


>
>>
>> ---
>>
>> I presume the UI could do fancy things with this to highlight messages
>> with dupes better. I haven't quite figured out yet what that could be,
>> but this seems like the right thing to do regardless.
>> ---
>>  devel/schemata   |  5 -
>>  notmuch-client.h |  2 +-
>>  notmuch-show.c   | 16 +++-
>>  3 files changed, 20 insertions(+), 3 deletions(-)
>>
>> diff --git a/devel/schemata b/devel/schemata
>> index 41dc4a60fff3..6dede7a453d7 100644
>> --- a/devel/schemata
>> +++ b/devel/schemata
>> @@ -26,6 +26,9 @@ v1
>>  v2
>>  - Added the thread_summary.query field.
>>  
>> +v3
>> +- Replaced message.filename string with a list of filenames.
>> +
>>  Common non-terminals
>>  
>>  
>> @@ -59,7 +62,7 @@ message = {
>>  # (format_message_sprinter)
>>  id: messageid,
>>  match:  bool,
>> -filename:   string,
>> +filename:   [string*],
>>  timestamp:  unix_time, # date header as unix time
>>  date_relative:  string,   # user-friendly timestamp
>>  tags:   [string*],
>> diff --git a/notmuch-client.h b/notmuch-client.h
>> index d026e6004239..21b087980a17 100644
>> --- a/notmuch-client.h
>> +++ b/notmuch-client.h
>> @@ -145,7 +145,7 @@ chomp_newline (char *str)
>>   * this.  New (required) map fields can be added without increasing
>>   * this.
>>   */
>> -#define NOTMUCH_FORMAT_CUR 2
>> +#define NOTMUCH_FORMAT_CUR 3
>>  /* The minimum supported structured output format version.  Requests
>>   * for format versions below this will return an error. */
>>  #define NOTMUCH_FORMAT_MIN 1
>> diff --git a/notmuch-show.c b/notmuch-show.c
>> index 22fa655ad20d..3b9e31247f2c 100644
>> --- a/notmuch-show.c
>> +++ b/notmuch-show.c
>> @@ -133,7 +133,21 @@ format_message_sprinter (sprinter_t *sp, 
>> notmuch_message_t *message)
>>  sp->boolean (sp, notmuch_message_get_flag (message, 
>> NOTMUCH_MESSAGE_FLAG_EXCLUDED));
>>  
>>  sp->map_key (sp, "filename");
>> -sp->string (sp, notmuch_message_get_filename (message));
>> +if (notmuch_format_version >= 3) {
>> +notmuch_filenames_t *filenames;
>> +
>> +sp->begin_list (sp);
>> +for (filenames = notmuch_message_get_filenames (message);
>> + notmuch_filenames_valid (filenames);
>> + notmuch_filenames_move_to_next (filenames)) {
>> +sp->string (sp, notmuch_message_get_filename (message));
>> +sp->separator (sp);
>> +}
>> +notmuch_filenames_destroy (filenames);
>> +sp->end (sp);
>> +} else {
>> +sp->string (sp, notmuch_message_get_filename (message));
>> +}
>>  
>>  sp->map_key (sp, "timestamp");
>>  date = notmuch_message_get_date (message);
>> -- 
>> 2.11.0
>>
>> ___
>> notmuch mailing list
>> notmuch@notmuchmail.org
>> https://notmuchmail.org/mailman/listinfo/notmuch
> ___
> 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: [PATCH] cli/show: list all filenames of a message in the formatted output

2017-01-25 Thread Tomi Ollila
On Tue, Jan 10 2017, Jani Nikula  wrote:

> Instead of just having the first filename for the message, list all
> duplicate filenames of the message as a list in the formatted
> outputs. This bumps the format version to 3.

Great stuff -- just now quite a few (~33) tests fail ;)

>
> ---
>
> I presume the UI could do fancy things with this to highlight messages
> with dupes better. I haven't quite figured out yet what that could be,
> but this seems like the right thing to do regardless.
> ---
>  devel/schemata   |  5 -
>  notmuch-client.h |  2 +-
>  notmuch-show.c   | 16 +++-
>  3 files changed, 20 insertions(+), 3 deletions(-)
>
> diff --git a/devel/schemata b/devel/schemata
> index 41dc4a60fff3..6dede7a453d7 100644
> --- a/devel/schemata
> +++ b/devel/schemata
> @@ -26,6 +26,9 @@ v1
>  v2
>  - Added the thread_summary.query field.
>  
> +v3
> +- Replaced message.filename string with a list of filenames.
> +
>  Common non-terminals
>  
>  
> @@ -59,7 +62,7 @@ message = {
>  # (format_message_sprinter)
>  id: messageid,
>  match:  bool,
> -filename:string,
> +filename:[string*],
>  timestamp:  unix_time, # date header as unix time
>  date_relative:  string,   # user-friendly timestamp
>  tags:   [string*],
> diff --git a/notmuch-client.h b/notmuch-client.h
> index d026e6004239..21b087980a17 100644
> --- a/notmuch-client.h
> +++ b/notmuch-client.h
> @@ -145,7 +145,7 @@ chomp_newline (char *str)
>   * this.  New (required) map fields can be added without increasing
>   * this.
>   */
> -#define NOTMUCH_FORMAT_CUR 2
> +#define NOTMUCH_FORMAT_CUR 3
>  /* The minimum supported structured output format version.  Requests
>   * for format versions below this will return an error. */
>  #define NOTMUCH_FORMAT_MIN 1
> diff --git a/notmuch-show.c b/notmuch-show.c
> index 22fa655ad20d..3b9e31247f2c 100644
> --- a/notmuch-show.c
> +++ b/notmuch-show.c
> @@ -133,7 +133,21 @@ format_message_sprinter (sprinter_t *sp, 
> notmuch_message_t *message)
>  sp->boolean (sp, notmuch_message_get_flag (message, 
> NOTMUCH_MESSAGE_FLAG_EXCLUDED));
>  
>  sp->map_key (sp, "filename");
> -sp->string (sp, notmuch_message_get_filename (message));
> +if (notmuch_format_version >= 3) {
> + notmuch_filenames_t *filenames;
> +
> + sp->begin_list (sp);
> + for (filenames = notmuch_message_get_filenames (message);
> +  notmuch_filenames_valid (filenames);
> +  notmuch_filenames_move_to_next (filenames)) {
> + sp->string (sp, notmuch_message_get_filename (message));
> + sp->separator (sp);
> + }
> + notmuch_filenames_destroy (filenames);
> + sp->end (sp);
> +} else {
> + sp->string (sp, notmuch_message_get_filename (message));
> +}
>  
>  sp->map_key (sp, "timestamp");
>  date = notmuch_message_get_date (message);
> -- 
> 2.11.0
>
> ___
> notmuch mailing list
> notmuch@notmuchmail.org
> https://notmuchmail.org/mailman/listinfo/notmuch
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


[PATCH] cli/show: list all filenames of a message in the formatted output

2017-01-10 Thread Jani Nikula
Instead of just having the first filename for the message, list all
duplicate filenames of the message as a list in the formatted
outputs. This bumps the format version to 3.

---

I presume the UI could do fancy things with this to highlight messages
with dupes better. I haven't quite figured out yet what that could be,
but this seems like the right thing to do regardless.
---
 devel/schemata   |  5 -
 notmuch-client.h |  2 +-
 notmuch-show.c   | 16 +++-
 3 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/devel/schemata b/devel/schemata
index 41dc4a60fff3..6dede7a453d7 100644
--- a/devel/schemata
+++ b/devel/schemata
@@ -26,6 +26,9 @@ v1
 v2
 - Added the thread_summary.query field.
 
+v3
+- Replaced message.filename string with a list of filenames.
+
 Common non-terminals
 
 
@@ -59,7 +62,7 @@ message = {
 # (format_message_sprinter)
 id: messageid,
 match:  bool,
-filename:  string,
+filename:  [string*],
 timestamp:  unix_time, # date header as unix time
 date_relative:  string,   # user-friendly timestamp
 tags:   [string*],
diff --git a/notmuch-client.h b/notmuch-client.h
index d026e6004239..21b087980a17 100644
--- a/notmuch-client.h
+++ b/notmuch-client.h
@@ -145,7 +145,7 @@ chomp_newline (char *str)
  * this.  New (required) map fields can be added without increasing
  * this.
  */
-#define NOTMUCH_FORMAT_CUR 2
+#define NOTMUCH_FORMAT_CUR 3
 /* The minimum supported structured output format version.  Requests
  * for format versions below this will return an error. */
 #define NOTMUCH_FORMAT_MIN 1
diff --git a/notmuch-show.c b/notmuch-show.c
index 22fa655ad20d..3b9e31247f2c 100644
--- a/notmuch-show.c
+++ b/notmuch-show.c
@@ -133,7 +133,21 @@ format_message_sprinter (sprinter_t *sp, notmuch_message_t 
*message)
 sp->boolean (sp, notmuch_message_get_flag (message, 
NOTMUCH_MESSAGE_FLAG_EXCLUDED));
 
 sp->map_key (sp, "filename");
-sp->string (sp, notmuch_message_get_filename (message));
+if (notmuch_format_version >= 3) {
+   notmuch_filenames_t *filenames;
+
+   sp->begin_list (sp);
+   for (filenames = notmuch_message_get_filenames (message);
+notmuch_filenames_valid (filenames);
+notmuch_filenames_move_to_next (filenames)) {
+   sp->string (sp, notmuch_message_get_filename (message));
+   sp->separator (sp);
+   }
+   notmuch_filenames_destroy (filenames);
+   sp->end (sp);
+} else {
+   sp->string (sp, notmuch_message_get_filename (message));
+}
 
 sp->map_key (sp, "timestamp");
 date = notmuch_message_get_date (message);
-- 
2.11.0

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