Re: [PATCH 2/2] search --output=files: Output all filenames for each matching message

2011-06-28 Thread Carl Worth
On Tue, 28 Jun 2011 12:12:52 -0700, Carl Worth  wrote:
> I think the only thing I would like to see in addition is an update to
> the documentation to make it explicit that --output=files will emit all
> filenames for a message that has more than one filename.

Actually, I went to go update the documentation itself, and I found that
it doesn't really need anything new here. The current text is:

--output=files

Output the filenames of all messages matching the search terms,
either one per line (--format=text) or as a JSON array
(--format=json).

And that's pretty clearly "the filenames of all messages".

The fact that we share a single "message object" when two files contain
the same message-id seems like an implementation detail that's not worth
bringing up here. (It would add more concepts to the documentation but
not actually change the meaning.)

So I've pushed the test and fix as-is now.

-Carl

-- 
carl.d.wo...@intel.com


pgpiLXQb5RN5d.pgp
Description: PGP signature
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH 2/2] search --output=files: Output all filenames for each matching message

2011-06-28 Thread Carl Worth
On Tue, 28 Jun 2011 12:12:52 -0700, Carl Worth  wrote:
> I think the only thing I would like to see in addition is an update to
> the documentation to make it explicit that --output=files will emit all
> filenames for a message that has more than one filename.

Actually, I went to go update the documentation itself, and I found that
it doesn't really need anything new here. The current text is:

--output=files

Output the filenames of all messages matching the search terms,
either one per line (--format=text) or as a JSON array
(--format=json).

And that's pretty clearly "the filenames of all messages".

The fact that we share a single "message object" when two files contain
the same message-id seems like an implementation detail that's not worth
bringing up here. (It would add more concepts to the documentation but
not actually change the meaning.)

So I've pushed the test and fix as-is now.

-Carl

-- 
carl.d.worth at intel.com
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: 



Re: [PATCH 2/2] search --output=files: Output all filenames for each matching message

2011-06-28 Thread Carl Worth
On Fri, 24 Jun 2011 17:26:55 -0600, Mark Anderson  wrote:
> Messages in the database can have multiple files associated with a
> single message-id, but until now only one filename for each message
> has been reported by "notmuch search --output=files"

Hi Mark,

Thanks for contributing this patch!

I know from a conversation we had in IRC that you needed this feature to
track down a bug you were hitting. Thanks for going the extra mile to
write a new test case and a complete patch for the new feature.

I think the only thing I would like to see in addition is an update to
the documentation to make it explicit that --output=files will emit all
filenames for a message that has more than one filename.

> Perhaps someone can offer a little help making the "separator" code
> tighter, but this works.

It's amazing how painful it is to get the corner cases right here, isn't
it? It's almost enough to make me wish that we allowed trailing
separators as a standard element of style in conventional prose. [*]

-Carl

[*] Though if I had that wish, I'd also want to wish for the abolition
of any distinction for singular and plural nouns. The code to generate
messages like the following is a pain to write:

Processed 1 file in almost no time.
Added 1 new message to the database. Removed 1 message.

(And that's without even adding support for translations which would
further complicate this.) Ah, well, the price we pay to make code with
clean output.

-- 
carl.d.wo...@intel.com


pgp4Ig6NPhPrR.pgp
Description: PGP signature
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH 2/2] search --output=files: Output all filenames for each matching message

2011-06-28 Thread Carl Worth
On Fri, 24 Jun 2011 17:26:55 -0600, Mark Anderson  wrote:
> Messages in the database can have multiple files associated with a
> single message-id, but until now only one filename for each message
> has been reported by "notmuch search --output=files"

Hi Mark,

Thanks for contributing this patch!

I know from a conversation we had in IRC that you needed this feature to
track down a bug you were hitting. Thanks for going the extra mile to
write a new test case and a complete patch for the new feature.

I think the only thing I would like to see in addition is an update to
the documentation to make it explicit that --output=files will emit all
filenames for a message that has more than one filename.

> Perhaps someone can offer a little help making the "separator" code
> tighter, but this works.

It's amazing how painful it is to get the corner cases right here, isn't
it? It's almost enough to make me wish that we allowed trailing
separators as a standard element of style in conventional prose. [*]

-Carl

[*] Though if I had that wish, I'd also want to wish for the abolition
of any distinction for singular and plural nouns. The code to generate
messages like the following is a pain to write:

Processed 1 file in almost no time.
Added 1 new message to the database. Removed 1 message.

(And that's without even adding support for translations which would
further complicate this.) Ah, well, the price we pay to make code with
clean output.

-- 
carl.d.worth at intel.com
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: 



[PATCH 2/2] search --output=files: Output all filenames for each matching message

2011-06-24 Thread Mark Anderson

Messages in the database can have multiple files associated with a
single message-id, but until now only one filename for each message
has been reported by "notmuch search --output=files"

Signed-off-by: Mark Anderson 
---

Perhaps someone can offer a little help making the "separator" code
tighter, but this works.

 notmuch-search.c |   29 ++---
 1 files changed, 22 insertions(+), 7 deletions(-)

diff --git a/notmuch-search.c b/notmuch-search.c
index 616fe68..faccaf7 100644
--- a/notmuch-search.c
+++ b/notmuch-search.c
@@ -275,6 +275,7 @@ do_search_messages (const search_format_t *format,
 {
 notmuch_message_t *message;
 notmuch_messages_t *messages;
+notmuch_filenames_t *filenames;
 int first_message = 1;

 messages = notmuch_query_search_messages (query);
@@ -289,19 +290,33 @@ do_search_messages (const search_format_t *format,
 {
message = notmuch_messages_get (messages);

-   if (! first_message)
-   fputs (format->item_sep, stdout);
-
if (output == OUTPUT_FILES) {
-   format->item_id (message, "",
-notmuch_message_get_filename (message));
+   filenames = notmuch_message_get_filenames (message);
+
+   for (;
+notmuch_filenames_valid (filenames);
+notmuch_filenames_move_to_next (filenames))
+   {
+   if (! first_message)
+   fputs (format->item_sep, stdout);
+
+   format->item_id (message, "",
+notmuch_filenames_get (filenames));
+
+   first_message = 0;
+   }
+   
+   notmuch_filenames_destroy( filenames );
+
} else { /* output == OUTPUT_MESSAGES */
+   if (! first_message)
+   fputs (format->item_sep, stdout);
+
format->item_id (message, "id:",
 notmuch_message_get_message_id (message));
+   first_message = 0;
}

-   first_message = 0;
-
notmuch_message_destroy (message);
 }

-- 
1.7.4.1



[PATCH 2/2] search --output=files: Output all filenames for each matching message

2011-06-24 Thread Mark Anderson

Messages in the database can have multiple files associated with a
single message-id, but until now only one filename for each message
has been reported by "notmuch search --output=files"

Signed-off-by: Mark Anderson 
---

Perhaps someone can offer a little help making the "separator" code
tighter, but this works.

 notmuch-search.c |   29 ++---
 1 files changed, 22 insertions(+), 7 deletions(-)

diff --git a/notmuch-search.c b/notmuch-search.c
index 616fe68..faccaf7 100644
--- a/notmuch-search.c
+++ b/notmuch-search.c
@@ -275,6 +275,7 @@ do_search_messages (const search_format_t *format,
 {
 notmuch_message_t *message;
 notmuch_messages_t *messages;
+notmuch_filenames_t *filenames;
 int first_message = 1;
 
 messages = notmuch_query_search_messages (query);
@@ -289,19 +290,33 @@ do_search_messages (const search_format_t *format,
 {
message = notmuch_messages_get (messages);
 
-   if (! first_message)
-   fputs (format->item_sep, stdout);
-
if (output == OUTPUT_FILES) {
-   format->item_id (message, "",
-notmuch_message_get_filename (message));
+   filenames = notmuch_message_get_filenames (message);
+
+   for (;
+notmuch_filenames_valid (filenames);
+notmuch_filenames_move_to_next (filenames))
+   {
+   if (! first_message)
+   fputs (format->item_sep, stdout);
+
+   format->item_id (message, "",
+notmuch_filenames_get (filenames));
+
+   first_message = 0;
+   }
+   
+   notmuch_filenames_destroy( filenames );
+
} else { /* output == OUTPUT_MESSAGES */
+   if (! first_message)
+   fputs (format->item_sep, stdout);
+
format->item_id (message, "id:",
 notmuch_message_get_message_id (message));
+   first_message = 0;
}
 
-   first_message = 0;
-
notmuch_message_destroy (message);
 }
 
-- 
1.7.4.1

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