unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* wish: syncable/immutable threads
@ 2009-12-15 21:23 David Bremner
  2009-12-16  0:36 ` Carl Worth
  0 siblings, 1 reply; 4+ messages in thread
From: David Bremner @ 2009-12-15 21:23 UTC (permalink / raw
  To: notmuch


I write links to notmuch threads into my todo list in org-mode.

I then try to visit these threads on a different machine, but of course
that thread id doesn't exist there, since the database was reindexed and
tags reimported.

I don't know if it is in any way practical, but it would be nice from my
point of view if thread id's were a property of the mail collection, or
at least it was possible to dump and restore them.

If this is too much of a corner case, then I suspect I can work around
it in the emacs client by calling search twice, first with an id in the
thread.

David

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: wish: syncable/immutable threads
  2009-12-15 21:23 wish: syncable/immutable threads David Bremner
@ 2009-12-16  0:36 ` Carl Worth
  2009-12-18  0:20   ` David Bremner
  0 siblings, 1 reply; 4+ messages in thread
From: Carl Worth @ 2009-12-16  0:36 UTC (permalink / raw
  To: David Bremner, notmuch

[-- Attachment #1: Type: text/plain, Size: 2121 bytes --]

On Tue, 15 Dec 2009 17:23:59 -0400, David Bremner <bremner@unb.ca> wrote:
> I then try to visit these threads on a different machine, but of course
> that thread id doesn't exist there, since the database was reindexed and
> tags reimported.

Ah, good point.

I've wanted reproducible thread IDs also for a similar reason. I
anticipate writing a tool to create HTML versions of the archives of
mailing lists. In this case I want to have thread IDs in URLs and I want
those URLs to be persistent even if I re-build the index from scratch.
(For this case, I'd also like to have small thread IDs, such as
consecutive integers.)

> I don't know if it is in any way practical, but it would be nice from my
> point of view if thread id's were a property of the mail collection, or
> at least it was possible to dump and restore them.

I think it's quite practical. The easiest answer is probably to simply
include the thread ID in each line of the dump output. And then we
should ensure that thread IDs as well as tags are accounted for in the
design of any synchronization mechanism to support multiple notmuch
databases. One thing to consider is whether we want to continue to have
any amount of compatibility with the sup dump format

> If this is too much of a corner case, then I suspect I can work around
> it in the emacs client by calling search twice, first with an id in the
> thread.

That's almost similar to what sup does, which is to use a message ID of
a the first message encoutered in a thread as the thread ID. Doing that
alone doesn't help with the case of rebuilding the index on separate
machines since it makes the thread ID dependent on the order in which
messages are processed.

But yes, if you can make your links depend only on message IDs then you
can get reliable results even before we start including thread IDs in
the dump output. The result of "notmuch show --entire-thread id:foo" is
quite similar to the result of "notmuch show thread:bar" (for the
corresponding thread ID of course). It differs only in the "match"
field, which is used to determine which messages to open by default.

-Carl

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: wish: syncable/immutable threads
  2009-12-16  0:36 ` Carl Worth
@ 2009-12-18  0:20   ` David Bremner
  2009-12-18  2:44     ` [PATCH] notmuch-show.c: provide an option --format=message-ids which outputs only ids david
  0 siblings, 1 reply; 4+ messages in thread
From: David Bremner @ 2009-12-18  0:20 UTC (permalink / raw
  To: Carl Worth, notmuch

On Tue, 15 Dec 2009 16:36:04 -0800, Carl Worth <cworth@cworth.org> wrote:

> But yes, if you can make your links depend only on message IDs then you
> can get reliable results even before we start including thread IDs in
> the dump output. The result of "notmuch show --entire-thread id:foo" is
> quite similar to the result of "notmuch show thread:bar" (for the
> corresponding thread ID of course). It differs only in the "match"
> field, which is used to determine which messages to open by default.

I'm thinking of making links in the style "threadof:msg-id".  At the
moment I just substitute id: for threadof: and call notmuch-show. This
relies on (notmuch-show "id:foo") using "notmuch show --entire-thread"
or something equivalent.  I could also put another layer of function
there if relying on the behaviour of notmuch-show is an obviously bad
idea.

David

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH] notmuch-show.c: provide an option --format=message-ids which outputs only ids.
  2009-12-18  0:20   ` David Bremner
@ 2009-12-18  2:44     ` david
  0 siblings, 0 replies; 4+ messages in thread
From: david @ 2009-12-18  2:44 UTC (permalink / raw
  To: notmuch; +Cc: David Bremner

From: David Bremner <bremner@unb.ca>

If the option --format=message-ids is passed on the command line, only message
IDs are output.  A new structure show_options_t is defined to keep track of
all (currently 2) command line options.
---

It seems a shame to parse the entire output of notmuch show to get a
message id (or all of the message ids) contained in a thread.  One
might like a shorter command line option, but this seems to leave room
for --format=json, and so on.  Similarly, defining an option structure is 
arguably overengineering; I'm happy to rework to just pass a second boolean 
parameter to notmuch_show_messages.  

 notmuch-show.c |   30 ++++++++++++++++++++++--------
 1 files changed, 22 insertions(+), 8 deletions(-)

diff --git a/notmuch-show.c b/notmuch-show.c
index 376aacd..4ed8cec 100644
--- a/notmuch-show.c
+++ b/notmuch-show.c
@@ -20,6 +20,11 @@
 
 #include "notmuch-client.h"
 
+typedef struct {
+  enum { FORMAT_DEFAULT, FORMAT_MESSAGE_ID } format;
+  int entire_thread;
+} show_options_t;
+    
 static const char *
 _get_tags_as_string (void *ctx, notmuch_message_t *message)
 {
@@ -185,7 +190,7 @@ show_message (void *ctx, notmuch_message_t *message, int indent)
 
 static void
 show_messages (void *ctx, notmuch_messages_t *messages, int indent,
-	       notmuch_bool_t entire_thread)
+	       show_options_t *options)
 {
     notmuch_message_t *message;
     notmuch_bool_t match;
@@ -201,13 +206,17 @@ show_messages (void *ctx, notmuch_messages_t *messages, int indent,
 
 	next_indent = indent;
 
-	if (match || entire_thread) {
-	    show_message (ctx, message, indent);
-	    next_indent = indent + 1;
+	if (match || options->entire_thread) {
+	    if (options->format == FORMAT_DEFAULT) {
+		show_message (ctx, message, indent);
+		next_indent = indent + 1;
+	    } else {
+ 		puts (notmuch_message_get_message_id (message));
+	    } 
 	}
 
 	show_messages (ctx, notmuch_message_get_replies (message),
-		       next_indent, entire_thread);
+		       next_indent, options);
 
 	notmuch_message_destroy (message);
     }
@@ -222,17 +231,22 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))
     notmuch_threads_t *threads;
     notmuch_thread_t *thread;
     notmuch_messages_t *messages;
+    show_options_t options;
     char *query_string;
-    int entire_thread = 0;
     int i;
 
+    options.entire_thread = 0;
+    options.format = FORMAT_DEFAULT;
+        
     for (i = 0; i < argc && argv[i][0] == '-'; i++) {
 	if (strcmp (argv[i], "--") == 0) {
 	    i++;
 	    break;
 	}
         if (strcmp(argv[i], "--entire-thread") == 0) {
-	    entire_thread = 1;
+	    options.entire_thread = 1;
+	} else if (strcmp (argv[i], "--format=message-ids") == 0) {
+	    options.format = FORMAT_MESSAGE_ID;
 	} else {
 	    fprintf (stderr, "Unrecognized option: %s\n", argv[i]);
 	    return 1;
@@ -280,7 +294,7 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))
 	    INTERNAL_ERROR ("Thread %s has no toplevel messages.\n",
 			    notmuch_thread_get_thread_id (thread));
 
-	show_messages (ctx, messages, 0, entire_thread);
+	show_messages (ctx, messages, 0, &options);
 
 	notmuch_thread_destroy (thread);
     }
-- 
1.6.5.3

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-12-18  2:45 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-12-15 21:23 wish: syncable/immutable threads David Bremner
2009-12-16  0:36 ` Carl Worth
2009-12-18  0:20   ` David Bremner
2009-12-18  2:44     ` [PATCH] notmuch-show.c: provide an option --format=message-ids which outputs only ids david

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).