[notmuch] Emacs: Problem viewing a thread after reading it once interface

2009-12-04 Thread Bart Trojanowski
* Carl Worth  [091204 13:55]:
> So maybe we need "notmuch show" to accept a second query string
> to do something like:
> 
>   notmuch show tag:foo --matching tag:inbox
> 
> which will display all threads with messages matching "tag:foo" but then
> mark only the messages matching "tag:inbox" with the "match:1" marker
> for the UI to use.

Right.  That would make sense.
thread ID, like say:

> What do you think, Bart? Did you run into a similar issue with the vim
> interface?

While I have not noticed before, yes... it's there.

-Bart



-- 
WebSig: http://www.jukie.net/~bart/sig/


Re: [notmuch] Emacs: Problem viewing a thread after reading it once interface

2009-12-04 Thread Bart Trojanowski
* Carl Worth  [091204 13:55]:
> So maybe we need "notmuch show" to accept a second query string
> to do something like:
> 
>   notmuch show tag:foo --matching tag:inbox
> 
> which will display all threads with messages matching "tag:foo" but then
> mark only the messages matching "tag:inbox" with the "match:1" marker
> for the UI to use.

Right.  That would make sense.
thread ID, like say:

> What do you think, Bart? Did you run into a similar issue with the vim
> interface?

While I have not noticed before, yes... it's there.

-Bart



-- 
WebSig: http://www.jukie.net/~bart/sig/
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[notmuch] [PATCH] vim: preserve the 'show everything' flag when finding next/prev buffer

2009-12-03 Thread Bart Trojanowski
* Carl Worth  [091203 16:31]:
> Sorry I missed this with your earlier, related changes. But I've pushed
> this now.

Thanks.

-Bart

-- 
WebSig: http://www.jukie.net/~bart/sig/


Re: [notmuch] [PATCH] vim: preserve the 'show everything' flag when finding next/prev buffer

2009-12-03 Thread Bart Trojanowski
* Carl Worth  [091203 16:31]:
> Sorry I missed this with your earlier, related changes. But I've pushed
> this now.

Thanks.

-Bart

-- 
WebSig: http://www.jukie.net/~bart/sig/
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[notmuch] semi-usable notmuch-gtk client

2009-11-27 Thread Bart Trojanowski
* Baruch Even  [091127 12:58]:
> I added a quick hack to show a message thread in notmuch-gtk and this  
> makes it semi-usable. I don't actually parse the reply of notmuch-show  
> but it's already passably usable to read mail.

got screenshots?

Cheers,
-Bart

-- 
WebSig: http://www.jukie.net/~bart/sig/


[notmuch] [PATCH RFC] debugger: detect presence of ptrace type debuggers

2009-11-27 Thread Bart Trojanowski
According to the internet [1], this is a more reliable way of detecting if
one is under the spell of a debugger.  Should work for ptrace, strace,
gdb, etc.  Basically anything that uses the ptrace() syscall.

[1] http://vx.netlux.org/lib/vsc04.html
---
 debugger.c |5 +
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/debugger.c b/debugger.c
index e8b9378..f486032 100644
--- a/debugger.c
+++ b/debugger.c
@@ -22,6 +22,8 @@

 #include 

+#include 
+
 #if HAVE_VALGRIND
 #include 
 #else
@@ -36,6 +38,9 @@ debugger_is_active (void)
 if (RUNNING_ON_VALGRIND)
return TRUE;

+if (ptrace(PTRACE_TRACEME, 0, 1, 0) < 0)
+   return TRUE;
+
 sprintf (buf, "/proc/%d/exe", getppid ());
 if (readlink (buf, buf, sizeof (buf)) != -1 &&
strncmp (basename (buf), "gdb", 3) == 0)
-- 
1.6.4.4.2.gc2f148



[notmuch] [PATCH 2/2] vim: use notmuch show --entire-thread

2009-11-27 Thread Bart Trojanowski
---
 vim/plugin/notmuch.vim |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/vim/plugin/notmuch.vim b/vim/plugin/notmuch.vim
index 34d70d9..a226f20 100644
--- a/vim/plugin/notmuch.vim
+++ b/vim/plugin/notmuch.vim
@@ -409,7 +409,7 @@ endfunction

 function! s:NM_cmd_show(words)
 let prev_bufnr = bufnr('%')
-let data = s:NM_run(['show'] + a:words)
+let data = s:NM_run(['show', '--entire-thread'] + a:words)
 let lines = split(data, "\n")

 let info = s:NM_cmd_show_parse(lines)
-- 
1.6.4.4.2.gc2f148



[notmuch] [PATCH 1/2] notmuch-show: limit display to only matching messages

2009-11-27 Thread Bart Trojanowski
This patch changes the default behaviour of notmuch show to display only
messages that match the search expression.  However, --entire-thread
option is provided to display all messages in threads that matched the
search expression.

It is deemed that will be more useful for human users on the command line.
Scripts can be modified to include the --entire-thread option so that they
can display all messages once more.

Example:

$ notmuch search subject:git AND thread:23d99d0f364f93e90e15df8b42eddb5b
thread:23d99d0f364f93e90e15df8b42eddb5b  July 31 [4/12] Johan Herland; 
[RFCv2 00/12] Foreign VCS helper program for CVS repositories (inbox unread)

Note that in this thread 4 out of 12 messages matched.  The default show
behaviour is to show only those messages that match:

$ notmuch show subject:git AND thread:23d99d0f364f93e90e15df8b42eddb5b | grep 
'message{' | wc -l
4

With the --only-matching-messages option the output will contain all dozen
messages:

$ notmuch show --entire-thread subject:git AND 
thread:23d99d0f364f93e90e15df8b42eddb5b | grep 'message{' | wc -l
12

Signed-off-by: Bart Trojanowski 
---
 notmuch-show.c |   48 +---
 notmuch.c  |8 
 2 files changed, 45 insertions(+), 11 deletions(-)

diff --git a/notmuch-show.c b/notmuch-show.c
index 13c91e4..60339d0 100644
--- a/notmuch-show.c
+++ b/notmuch-show.c
@@ -212,6 +212,24 @@ notmuch_show_command (void *ctx, unused (int argc), unused 
(char *argv[]))
 notmuch_thread_t *thread;
 notmuch_messages_t *messages;
 char *query_string;
+int entire_thread = 0;
+int i;
+
+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;
+   } else {
+   fprintf (stderr, "Unrecognized option: %s\n", argv[i]);
+   return 1;
+   }
+}
+
+argc -= i;
+argv += i;

 config = notmuch_config_open (ctx, NULL, NULL);
 if (config == NULL)
@@ -239,21 +257,29 @@ notmuch_show_command (void *ctx, unused (int argc), 
unused (char *argv[]))
return 1;
 }

-for (threads = notmuch_query_search_threads (query);
-notmuch_threads_has_more (threads);
-notmuch_threads_advance (threads))
-{
-   thread = notmuch_threads_get (threads);
+if (!entire_thread) {
+   messages = notmuch_query_search_messages (query);
+   if (messages == NULL)
+   INTERNAL_ERROR ("No messages.\n");
+   show_messages (ctx, messages, 0);

-   messages = notmuch_thread_get_toplevel_messages (thread);
+} else {
+   for (threads = notmuch_query_search_threads (query);
+   notmuch_threads_has_more (threads);
+   notmuch_threads_advance (threads))
+   {
+   thread = notmuch_threads_get (threads);

-   if (messages == NULL)
-   INTERNAL_ERROR ("Thread %s has no toplevel messages.\n",
-   notmuch_thread_get_thread_id (thread));
+   messages = notmuch_thread_get_toplevel_messages (thread);

-   show_messages (ctx, messages, 0);
+   if (messages == NULL)
+   INTERNAL_ERROR ("Thread %s has no toplevel messages.\n",
+   notmuch_thread_get_thread_id (thread));
+
+   show_messages (ctx, messages, 0);

-   notmuch_thread_destroy (thread);
+   notmuch_thread_destroy (thread);
+   }
 }

 notmuch_query_destroy (query);
diff --git a/notmuch.c b/notmuch.c
index 5b0284c..ea67b4f 100644
--- a/notmuch.c
+++ b/notmuch.c
@@ -177,6 +177,14 @@ command_t commands[] = {
   "\t\t(all replies to a particular message appear immediately\n"
   "\t\tafter that message in date order).\n"
   "\n"
+  "\t\tSupported options for show include:\n"
+  "\n"
+  "\t\t--entire-thread\n"
+  "\n"
+  "\t\t\tBy default only messages strictly matching the\n"
+  "\t\t\tsearch expression will be displayed.  With this\n"
+  "\t\t\toption all messages in matching threads are shown.\n"
+  "\n"
   "\t\tThe output format is plain-text, with all text-content\n"
   "\t\tMIME parts decoded. Various components in the output,\n"
   "\t\t('message', 'header', 'body', 'attachment', and MIME 'part')\n"
-- 
1.6.4.4.2.gc2f148



[notmuch] [PATCH] vim: preserve the 'show everything' flag when finding next/prev buffer

2009-11-27 Thread Bart Trojanowski
When show mode is invoked it could be displaying just the matched messages
or everything.  This flag is passed to NM_search_show_thread().  It is then
stored in a buffer variable, b:nm_show_everything, and used for subsequent
calls to NM_search_show_thread() triggered by ,  and .

Signed-off-by: Bart Trojanowski 
---
 vim/plugin/notmuch.vim |7 +--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/vim/plugin/notmuch.vim b/vim/plugin/notmuch.vim
index b415f50..34d70d9 100644
--- a/vim/plugin/notmuch.vim
+++ b/vim/plugin/notmuch.vim
@@ -275,6 +275,7 @@ function! s:NM_search_show_thread(everything)
 call add(words, ')')
 endif
 call NM_cmd_show(words)
+let b:nm_show_everything = a:everything
 endfunction

 function! s:NM_search_prompt()
@@ -430,6 +431,7 @@ function! s:NM_cmd_show(words)
 endfunction

 function! s:NM_show_previous(can_change_thread, find_matching)
+let everything = exists('b:nm_show_everything') ? b:nm_show_everything 
: 0
 let info = b:nm_raw_info
 let lnum = line('.')
 for msg in reverse(copy(info['msgs']))
@@ -450,7 +452,7 @@ function! s:NM_show_previous(can_change_thread, 
find_matching)
 call NM_kill_this_buffer()
 if line('.') > 1
 norm k
-call NM_search_show_thread()
+call NM_search_show_thread(everything)
 norm G
 call NM_show_previous(0, a:find_matching)
 else
@@ -479,10 +481,11 @@ function! s:NM_show_next(can_change_thread, find_matching)
 endfunction

 function! s:NM_show_next_thread()
+let everything = exists('b:nm_show_everything') ? b:nm_show_everything 
: 0
 call NM_kill_this_buffer()
 if line('.') != line('$')
 norm j
-call NM_search_show_thread()
+call NM_search_show_thread(everything)
 else
 echo 'No more messages.'
 endif
-- 
1.6.4.4.2.gc2f148



[notmuch] [PATCH 2/3] have _notmuch_thread_create mark which messages matched the query

2009-11-27 Thread Bart Trojanowski
On Fri, 27 Nov 2009 17:15:35 -0800, Carl Worth  wrote:
> This is a very useful feature, Bart. Thanks for coding it up. And it's a
> nicely-implemented patch series as well.

Thanks.  I've found it very handy.

> By the way, do you think that this support obviates the
> --only-matching-messages option for "notmuch search" or does anyone
> still want that?

I personally don't have much use for it (in the notmuch.vim UI).  However, I
can see it being useful if someone reads the messages on the terminal, maybe
using some less verbose output format.

> Or maybe the right fix is to make "notmuch show" display only matching
> messages by default, (which will likely be more friendly to a user
> manually typing "notmuch show" at the command line). And then make the
> user-interfaces pass an "--entire-thread" option (or so) to get the
> current results.

Sure, I'll fix up the patch and submit it in a bit.

> If we're going to make the command-line user-interface usable on its
> own, then I definitely want to make it be the user interfaces that have
> to pass extra-long command-line options to get what they want.

Agreed.  I still think we could use some templating for the different output
modes.  Maybe it will be important enough for soemone to implement :)

> One quick point on naming:
> 
> >  /* Message flags */
> >  typedef enum _notmuch_message_flag {
> > +NOTMUCH_MSG_FLAG_MATCHING_SEARCH,
> >  } notmuch_message_flag_t;
> 
> I like my enum values to match their type name without abbreviation. I
> also like internals (like this enum value) to match the way they are
> exposed in the interface, (which in this case is "match"). So I'd like
> the above value to instead be:
> 
>   NOTMUCH_MESSAGE_FLAG_MATCH

OK.  Patch is in flight.

Cheers,
-Bart

-- 
email sent from notmuch.vim plugin


[notmuch] [PATCH] correct message flag enum value so that it matches the type

2009-11-27 Thread Bart Trojanowski
As per Carl's request, this patch corrects the only value defined under
the notmuch_message_flag_t enum typedef to match the name of the type.

Signed-off-by: Bart Trojanowski 
---
 lib/notmuch.h  |2 +-
 lib/thread.cc  |2 +-
 notmuch-show.c |2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/notmuch.h b/lib/notmuch.h
index e4f3992..60834fb 100644
--- a/lib/notmuch.h
+++ b/lib/notmuch.h
@@ -711,7 +711,7 @@ notmuch_message_get_filename (notmuch_message_t *message);

 /* Message flags */
 typedef enum _notmuch_message_flag {
-NOTMUCH_MSG_FLAG_MATCHING_SEARCH,
+NOTMUCH_MESSAGE_FLAG_MATCH,
 } notmuch_message_flag_t;

 /* Get a value of a flag for the email corresponding to 'message'. */
diff --git a/lib/thread.cc b/lib/thread.cc
index 9e4cb5c..321937b 100644
--- a/lib/thread.cc
+++ b/lib/thread.cc
@@ -148,7 +148,7 @@ _thread_add_matched_message (notmuch_thread_t *thread,
notmuch_message_get_message_id (message), NULL,
(void **) &hashed_message)) {
notmuch_message_set_flag (hashed_message,
-   NOTMUCH_MSG_FLAG_MATCHING_SEARCH, 1);
+ NOTMUCH_MESSAGE_FLAG_MATCH, 1);
 }
 }

diff --git a/notmuch-show.c b/notmuch-show.c
index f189e94..13c91e4 100644
--- a/notmuch-show.c
+++ b/notmuch-show.c
@@ -158,7 +158,7 @@ show_message (void *ctx, notmuch_message_t *message, int 
indent)
 printf ("\fmessage{ id:%s depth:%d match:%d filename:%s\n",
notmuch_message_get_message_id (message),
indent,
-   notmuch_message_get_flag (message, 
NOTMUCH_MSG_FLAG_MATCHING_SEARCH),
+   notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_MATCH),
notmuch_message_get_filename (message));

 printf ("\fheader{\n");
-- 
1.6.4.4.2.gc2f148



Re: [notmuch] semi-usable notmuch-gtk client

2009-11-27 Thread Bart Trojanowski
* Baruch Even  [091127 12:58]:
> I added a quick hack to show a message thread in notmuch-gtk and this  
> makes it semi-usable. I don't actually parse the reply of notmuch-show  
> but it's already passably usable to read mail.

got screenshots?

Cheers,
-Bart

-- 
WebSig: http://www.jukie.net/~bart/sig/
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[notmuch] [PATCH RFC] debugger: detect presence of ptrace type debuggers

2009-11-27 Thread Bart Trojanowski
According to the internet [1], this is a more reliable way of detecting if
one is under the spell of a debugger.  Should work for ptrace, strace,
gdb, etc.  Basically anything that uses the ptrace() syscall.

[1] http://vx.netlux.org/lib/vsc04.html
---
 debugger.c |5 +
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/debugger.c b/debugger.c
index e8b9378..f486032 100644
--- a/debugger.c
+++ b/debugger.c
@@ -22,6 +22,8 @@
 
 #include 
 
+#include 
+
 #if HAVE_VALGRIND
 #include 
 #else
@@ -36,6 +38,9 @@ debugger_is_active (void)
 if (RUNNING_ON_VALGRIND)
return TRUE;
 
+if (ptrace(PTRACE_TRACEME, 0, 1, 0) < 0)
+   return TRUE;
+
 sprintf (buf, "/proc/%d/exe", getppid ());
 if (readlink (buf, buf, sizeof (buf)) != -1 &&
strncmp (basename (buf), "gdb", 3) == 0)
-- 
1.6.4.4.2.gc2f148

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


[notmuch] [PATCH 2/2] vim: use notmuch show --entire-thread

2009-11-27 Thread Bart Trojanowski
---
 vim/plugin/notmuch.vim |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/vim/plugin/notmuch.vim b/vim/plugin/notmuch.vim
index 34d70d9..a226f20 100644
--- a/vim/plugin/notmuch.vim
+++ b/vim/plugin/notmuch.vim
@@ -409,7 +409,7 @@ endfunction
 
 function! s:NM_cmd_show(words)
 let prev_bufnr = bufnr('%')
-let data = s:NM_run(['show'] + a:words)
+let data = s:NM_run(['show', '--entire-thread'] + a:words)
 let lines = split(data, "\n")
 
 let info = s:NM_cmd_show_parse(lines)
-- 
1.6.4.4.2.gc2f148

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


[notmuch] [PATCH 1/2] notmuch-show: limit display to only matching messages

2009-11-27 Thread Bart Trojanowski
This patch changes the default behaviour of notmuch show to display only
messages that match the search expression.  However, --entire-thread
option is provided to display all messages in threads that matched the
search expression.

It is deemed that will be more useful for human users on the command line.
Scripts can be modified to include the --entire-thread option so that they
can display all messages once more.

Example:

$ notmuch search subject:git AND thread:23d99d0f364f93e90e15df8b42eddb5b
thread:23d99d0f364f93e90e15df8b42eddb5b  July 31 [4/12] Johan Herland; 
[RFCv2 00/12] Foreign VCS helper program for CVS repositories (inbox unread)

Note that in this thread 4 out of 12 messages matched.  The default show
behaviour is to show only those messages that match:

$ notmuch show subject:git AND thread:23d99d0f364f93e90e15df8b42eddb5b | grep 
'message{' | wc -l
4

With the --only-matching-messages option the output will contain all dozen
messages:

$ notmuch show --entire-thread subject:git AND 
thread:23d99d0f364f93e90e15df8b42eddb5b | grep 'message{' | wc -l
12

Signed-off-by: Bart Trojanowski 
---
 notmuch-show.c |   48 +---
 notmuch.c  |8 
 2 files changed, 45 insertions(+), 11 deletions(-)

diff --git a/notmuch-show.c b/notmuch-show.c
index 13c91e4..60339d0 100644
--- a/notmuch-show.c
+++ b/notmuch-show.c
@@ -212,6 +212,24 @@ notmuch_show_command (void *ctx, unused (int argc), unused 
(char *argv[]))
 notmuch_thread_t *thread;
 notmuch_messages_t *messages;
 char *query_string;
+int entire_thread = 0;
+int i;
+
+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;
+   } else {
+   fprintf (stderr, "Unrecognized option: %s\n", argv[i]);
+   return 1;
+   }
+}
+
+argc -= i;
+argv += i;
 
 config = notmuch_config_open (ctx, NULL, NULL);
 if (config == NULL)
@@ -239,21 +257,29 @@ notmuch_show_command (void *ctx, unused (int argc), 
unused (char *argv[]))
return 1;
 }
 
-for (threads = notmuch_query_search_threads (query);
-notmuch_threads_has_more (threads);
-notmuch_threads_advance (threads))
-{
-   thread = notmuch_threads_get (threads);
+if (!entire_thread) {
+   messages = notmuch_query_search_messages (query);
+   if (messages == NULL)
+   INTERNAL_ERROR ("No messages.\n");
+   show_messages (ctx, messages, 0);
 
-   messages = notmuch_thread_get_toplevel_messages (thread);
+} else {
+   for (threads = notmuch_query_search_threads (query);
+   notmuch_threads_has_more (threads);
+   notmuch_threads_advance (threads))
+   {
+   thread = notmuch_threads_get (threads);
 
-   if (messages == NULL)
-   INTERNAL_ERROR ("Thread %s has no toplevel messages.\n",
-   notmuch_thread_get_thread_id (thread));
+   messages = notmuch_thread_get_toplevel_messages (thread);
 
-   show_messages (ctx, messages, 0);
+   if (messages == NULL)
+   INTERNAL_ERROR ("Thread %s has no toplevel messages.\n",
+   notmuch_thread_get_thread_id (thread));
+
+   show_messages (ctx, messages, 0);
 
-   notmuch_thread_destroy (thread);
+   notmuch_thread_destroy (thread);
+   }
 }
 
 notmuch_query_destroy (query);
diff --git a/notmuch.c b/notmuch.c
index 5b0284c..ea67b4f 100644
--- a/notmuch.c
+++ b/notmuch.c
@@ -177,6 +177,14 @@ command_t commands[] = {
   "\t\t(all replies to a particular message appear immediately\n"
   "\t\tafter that message in date order).\n"
   "\n"
+  "\t\tSupported options for show include:\n"
+  "\n"
+  "\t\t--entire-thread\n"
+  "\n"
+  "\t\t\tBy default only messages strictly matching the\n"
+  "\t\t\tsearch expression will be displayed.  With this\n"
+  "\t\t\toption all messages in matching threads are shown.\n"
+  "\n"
   "\t\tThe output format is plain-text, with all text-content\n"
   "\t\tMIME parts decoded. Various components in the output,\n"
   "\t\t('message', 'header', 'body', 'attachment', and MIME 'part')\n"
-- 
1.6.4.4.2.gc2f148

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


[notmuch] [PATCH] Return unpropertized strings for filename and message-id

2009-11-27 Thread Bart Trojanowski
* Bart Trojanowski  [091127 18:32]:
> You can actually put arbitrary text between the diffstat output and the first
> diff --git line.  For example:

Oops, and that's exactly what you said...

> >  So to satisfy "git am", introductory and explanatory portions of
> >  the email, ("Hi!" and "Here's my first patch"), have to be
> >  relegated to past the "---" divider).

Sorry.

-- 
WebSig: http://www.jukie.net/~bart/sig/


[notmuch] [PATCH] vim: preserve the 'show everything' flag when finding next/prev buffer

2009-11-27 Thread Bart Trojanowski
When show mode is invoked it could be displaying just the matched messages
or everything.  This flag is passed to NM_search_show_thread().  It is then
stored in a buffer variable, b:nm_show_everything, and used for subsequent
calls to NM_search_show_thread() triggered by ,  and .

Signed-off-by: Bart Trojanowski 
---
 vim/plugin/notmuch.vim |7 +--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/vim/plugin/notmuch.vim b/vim/plugin/notmuch.vim
index b415f50..34d70d9 100644
--- a/vim/plugin/notmuch.vim
+++ b/vim/plugin/notmuch.vim
@@ -275,6 +275,7 @@ function! s:NM_search_show_thread(everything)
 call add(words, ')')
 endif
 call NM_cmd_show(words)
+let b:nm_show_everything = a:everything
 endfunction
 
 function! s:NM_search_prompt()
@@ -430,6 +431,7 @@ function! s:NM_cmd_show(words)
 endfunction
 
 function! s:NM_show_previous(can_change_thread, find_matching)
+let everything = exists('b:nm_show_everything') ? b:nm_show_everything 
: 0
 let info = b:nm_raw_info
 let lnum = line('.')
 for msg in reverse(copy(info['msgs']))
@@ -450,7 +452,7 @@ function! s:NM_show_previous(can_change_thread, 
find_matching)
 call NM_kill_this_buffer()
 if line('.') > 1
 norm k
-call NM_search_show_thread()
+call NM_search_show_thread(everything)
 norm G
 call NM_show_previous(0, a:find_matching)
 else
@@ -479,10 +481,11 @@ function! s:NM_show_next(can_change_thread, find_matching)
 endfunction
 
 function! s:NM_show_next_thread()
+let everything = exists('b:nm_show_everything') ? b:nm_show_everything 
: 0
 call NM_kill_this_buffer()
 if line('.') != line('$')
 norm j
-call NM_search_show_thread()
+call NM_search_show_thread(everything)
 else
 echo 'No more messages.'
 endif
-- 
1.6.4.4.2.gc2f148

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


[notmuch] [PATCH] Return unpropertized strings for filename and message-id

2009-11-27 Thread Bart Trojanowski
[[ First of all I am jazzed because this is the first email I am sending to
anyone other than myself from the vim interface to notmuch ]]

Getting on wit the show...

>  So to satisfy "git am", introductory and explanatory portions of
>  the email, ("Hi!" and "Here's my first patch"), have to be
>  relegated to past the "---" divider).
> 
>  I actually don't love this about "git am", since I think those
>  introductory parts are essential to having cordial and friendly
>  exchanges on the mailing list, (rather than just dryly shooting
>  code back and forth). And it feels natural to have them first. One
>  thing that might be interesting is to teach "git am" about an
>  additional divider so that other text can came *before* the commit
>  message.
> 
>  Alternately, one can put introductory text in one message, and the
>  dry commit-only stuff as a reply.

You can actually put arbitrary text between the diffstat output and the first
diff --git line.  For example:

--- 8< ---
>From e6628e78d9ce3f9383a4699df9063a648617b428 Mon Sep 17 00:00:00 2001
From: Bart Trojanowski 
Date: Fri, 27 Nov 2009 18:02:05 -0500
Subject: [PATCH] this is the patch description

Text that goes here will end up in the git commit.
---
 vim/README |3 ++-
 1 files changed, 11 insertions(+), 12 deletions(-)

Anything that goes here will be ignored, so you can typ

diff --git a/vim/README b/vim/README
index 299c7f8..8cd3b1a 100644
--- a/vim/README
+++ b/vim/README
@@ -42,7 +42,8 @@ Buffer types:
 You are presented with the search results when you run :NotMuch.

 Keybindings:
- - show the selected message
+ - show the selected thread colapsing unmatched items
+ - show the entire selected thread
 a   - archive message (remove inbox tag)
 f   - filter the current search terms
 o   - toggle search screen order
-- 
1.6.4.4.2.gc2f148

--- 8< ---



-- 
email sent from notmuch.vim plugin


[notmuch] [PATCH] correct message flag enum value so that it matches the type

2009-11-27 Thread Bart Trojanowski
As per Carl's request, this patch corrects the only value defined under
the notmuch_message_flag_t enum typedef to match the name of the type.

Signed-off-by: Bart Trojanowski 
---
 lib/notmuch.h  |2 +-
 lib/thread.cc  |2 +-
 notmuch-show.c |2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/notmuch.h b/lib/notmuch.h
index e4f3992..60834fb 100644
--- a/lib/notmuch.h
+++ b/lib/notmuch.h
@@ -711,7 +711,7 @@ notmuch_message_get_filename (notmuch_message_t *message);
 
 /* Message flags */
 typedef enum _notmuch_message_flag {
-NOTMUCH_MSG_FLAG_MATCHING_SEARCH,
+NOTMUCH_MESSAGE_FLAG_MATCH,
 } notmuch_message_flag_t;
 
 /* Get a value of a flag for the email corresponding to 'message'. */
diff --git a/lib/thread.cc b/lib/thread.cc
index 9e4cb5c..321937b 100644
--- a/lib/thread.cc
+++ b/lib/thread.cc
@@ -148,7 +148,7 @@ _thread_add_matched_message (notmuch_thread_t *thread,
notmuch_message_get_message_id (message), NULL,
(void **) &hashed_message)) {
notmuch_message_set_flag (hashed_message,
-   NOTMUCH_MSG_FLAG_MATCHING_SEARCH, 1);
+ NOTMUCH_MESSAGE_FLAG_MATCH, 1);
 }
 }
 
diff --git a/notmuch-show.c b/notmuch-show.c
index f189e94..13c91e4 100644
--- a/notmuch-show.c
+++ b/notmuch-show.c
@@ -158,7 +158,7 @@ show_message (void *ctx, notmuch_message_t *message, int 
indent)
 printf ("\fmessage{ id:%s depth:%d match:%d filename:%s\n",
notmuch_message_get_message_id (message),
indent,
-   notmuch_message_get_flag (message, 
NOTMUCH_MSG_FLAG_MATCHING_SEARCH),
+   notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_MATCH),
notmuch_message_get_filename (message));
 
 printf ("\fheader{\n");
-- 
1.6.4.4.2.gc2f148

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


Re: [notmuch] [PATCH 2/3] have _notmuch_thread_create mark which messages matched the query

2009-11-27 Thread Bart Trojanowski
On Fri, 27 Nov 2009 17:15:35 -0800, Carl Worth  wrote:
> This is a very useful feature, Bart. Thanks for coding it up. And it's a
> nicely-implemented patch series as well.

Thanks.  I've found it very handy.

> By the way, do you think that this support obviates the
> --only-matching-messages option for "notmuch search" or does anyone
> still want that?

I personally don't have much use for it (in the notmuch.vim UI).  However, I
can see it being useful if someone reads the messages on the terminal, maybe
using some less verbose output format.

> Or maybe the right fix is to make "notmuch show" display only matching
> messages by default, (which will likely be more friendly to a user
> manually typing "notmuch show" at the command line). And then make the
> user-interfaces pass an "--entire-thread" option (or so) to get the
> current results.

Sure, I'll fix up the patch and submit it in a bit.

> If we're going to make the command-line user-interface usable on its
> own, then I definitely want to make it be the user interfaces that have
> to pass extra-long command-line options to get what they want.

Agreed.  I still think we could use some templating for the different output
modes.  Maybe it will be important enough for soemone to implement :)

> One quick point on naming:
> 
> >  /* Message flags */
> >  typedef enum _notmuch_message_flag {
> > +NOTMUCH_MSG_FLAG_MATCHING_SEARCH,
> >  } notmuch_message_flag_t;
> 
> I like my enum values to match their type name without abbreviation. I
> also like internals (like this enum value) to match the way they are
> exposed in the interface, (which in this case is "match"). So I'd like
> the above value to instead be:
> 
>   NOTMUCH_MESSAGE_FLAG_MATCH

OK.  Patch is in flight.

Cheers,
-Bart

-- 
email sent from notmuch.vim plugin
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [notmuch] [PATCH] Return unpropertized strings for filename and message-id

2009-11-27 Thread Bart Trojanowski
* Bart Trojanowski  [091127 18:32]:
> You can actually put arbitrary text between the diffstat output and the first
> diff --git line.  For example:

Oops, and that's exactly what you said...

> >  So to satisfy "git am", introductory and explanatory portions of
> >  the email, ("Hi!" and "Here's my first patch"), have to be
> >  relegated to past the "---" divider).

Sorry.

-- 
WebSig: http://www.jukie.net/~bart/sig/
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [notmuch] [PATCH] Return unpropertized strings for filename and message-id

2009-11-27 Thread Bart Trojanowski
[[ First of all I am jazzed because this is the first email I am sending to
anyone other than myself from the vim interface to notmuch ]]

Getting on wit the show...

>  So to satisfy "git am", introductory and explanatory portions of
>  the email, ("Hi!" and "Here's my first patch"), have to be
>  relegated to past the "---" divider).
> 
>  I actually don't love this about "git am", since I think those
>  introductory parts are essential to having cordial and friendly
>  exchanges on the mailing list, (rather than just dryly shooting
>  code back and forth). And it feels natural to have them first. One
>  thing that might be interesting is to teach "git am" about an
>  additional divider so that other text can came *before* the commit
>  message.
> 
>  Alternately, one can put introductory text in one message, and the
>  dry commit-only stuff as a reply.

You can actually put arbitrary text between the diffstat output and the first
diff --git line.  For example:

--- 8< ---
>From e6628e78d9ce3f9383a4699df9063a648617b428 Mon Sep 17 00:00:00 2001
From: Bart Trojanowski 
Date: Fri, 27 Nov 2009 18:02:05 -0500
Subject: [PATCH] this is the patch description

Text that goes here will end up in the git commit.
---
 vim/README |3 ++-
 1 files changed, 11 insertions(+), 12 deletions(-)

Anything that goes here will be ignored, so you can typ

diff --git a/vim/README b/vim/README
index 299c7f8..8cd3b1a 100644
--- a/vim/README
+++ b/vim/README
@@ -42,7 +42,8 @@ Buffer types:
 You are presented with the search results when you run :NotMuch.
 
 Keybindings:
- - show the selected message
+ - show the selected thread colapsing unmatched items
+ - show the entire selected thread
 a   - archive message (remove inbox tag)
 f   - filter the current search terms
 o   - toggle search screen order
-- 
1.6.4.4.2.gc2f148

--- 8< ---



-- 
email sent from notmuch.vim plugin
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[notmuch] [PATCH 2/4] notmuch: Config option to specify tags to be applied by 'notmuch new'.

2009-11-25 Thread Bart Trojanowski
Jan,

I really want this feature to get in, so I am going to do my best to
review your code :)

Here are some more sticking points...

> +char **
> +notmuch_config_get_new_tags (notmuch_config_t *config, size_t *length);

If you are not giving over control of the pointer to the caller please
return const char * const *.

Similarly...

> +char **new_tags;

... this should probably be const char **.

Next...

> +char **
> +notmuch_config_get_new_tags (notmuch_config_t *config, size_t *length)

... but ...

> +unsigned int count, i;
> +
> +if ((tags = notmuch_config_get_new_tags (config, &count)) == NULL)
> + return;

size_t != unsigned int on all platforms.  Please stick with one or the
other.  Note there are a few calls to fix here.

-Bart

-- 
WebSig: http://www.jukie.net/~bart/sig/


[notmuch] [PATCH] notmuch-new: Option to disable tags from the configuration file.

2009-11-25 Thread Bart Trojanowski
Jan,

I think your use of STRNCMP_LITERAL here is wrong...

> + } else if (STRNCMP_LITERAL (argv[i], "--no-config-tags") == 0) {
> + add_config_tags = 0;

it will happily match "--no-config-tags-xxx".

Can I also suggest including --no-config-tags in the 'notmuch help'
output?

Besides that I am very happy with this patch series.

-pBart

-- 
WebSig: http://www.jukie.net/~bart/sig/


[notmuch] [PATCH -v4] notmuch.el: Add face support to search and show mode

2009-11-25 Thread Bart Trojanowski
* Jeffrey Ollie  [091125 09:33]:
> On Tue, Nov 24, 2009 at 11:24 PM, Alexander Botero-Lowry
>  wrote:
> >
> > This way of detecting the tags seems ok, but I think it would be nicer
> > if it could be done even more deterministically. :) One idea that be
> > neat is to have a --format=sexp for notmuch search, which exports sexps
> > (probably alists, but could be some other format) for the search results
> > that can just be eval'd and processed in a cleaner way (and would also
> > make for nicer APIs in emacs for querying notmuch itself). Actually I
> > really like the idea of a sexp output mode for show too, instead of the
> > markers *plots*
> 
> Along the same lines, I was thinking that it would be nice to be able
> to get output formatted in JSON as well for possible use in a web
> front-end.  Actually, it looks like Emacs has support for JSON as
> well[1].  Not sure what release it was introduced in, but I see that
> it's in 23.1.
> 
> http://edward.oconnor.cx/2006/03/json.el

Would it be possible to make templates for output?

notmuch show --format=json would have notmuch follow rules from
.notmuch/json.template (or somesuch)

-Bart

-- 
WebSig: http://www.jukie.net/~bart/sig/


[notmuch] vim interface pull request

2009-11-25 Thread Bart Trojanowski
Carl,

as you already know, I've spent some time working on a vim-based
interface to notmuch.  I currently only depend on the 'march:[01]'
patches that we talked about briefly on irc.  Everything else is
isolated to the 'vim' directory and should not effect anyone else.

My efforts are cataloged here:

git://git.jukie.net/notmuch.git (vim branch)
http://git.jukie.net/notmuch.git?a=shortlog;h=refs/heads/vim

Please consider pulling in the vim branch.

-Bart

-- 
WebSig: http://www.jukie.net/~bart/sig/


[notmuch] [PATCH 3/3] notmuch-show: identify which messages printed matched the query string

2009-11-24 Thread Bart Trojanowski
The show command outputs all messages in the threads that match the
search-terms.  This patch introduces a 'match:[01]' entry to the 'message{'
line output by the show command.  Value of 1 indicates that the message is
matching the search expression.

Signed-off-by: Bart Trojanowski 
---
 notmuch-show.c |3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/notmuch-show.c b/notmuch-show.c
index 8599c6c..e9f0883 100644
--- a/notmuch-show.c
+++ b/notmuch-show.c
@@ -155,9 +155,10 @@ show_message (void *ctx, notmuch_message_t *message, int 
indent)
 const char *name, *value;
 unsigned int i;

-printf ("\fmessage{ id:%s depth:%d filename:%s\n",
+printf ("\fmessage{ id:%s depth:%d match:%d filename:%s\n",
notmuch_message_get_message_id (message),
indent,
+   notmuch_message_get_flag (message, 
NOTMUCH_MSG_FLAG_MATCHING_SEARCH),
notmuch_message_get_filename (message));

 printf ("\fheader{\n");
-- 
1.6.4.4.2.gc2f148



[notmuch] [PATCH 2/3] have _notmuch_thread_create mark which messages matched the query

2009-11-24 Thread Bart Trojanowski
When _notmuch_thread_create() is given a query string, it can return more
messages than just those matching the query.  To distinguish those that
matched the query expression, the MATCHING_SEARCH flag is set
appropriately.

Signed-off-by: Bart Trojanowski 
---
 lib/notmuch.h |1 +
 lib/thread.cc |8 
 2 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/lib/notmuch.h b/lib/notmuch.h
index c232c58..3974820 100644
--- a/lib/notmuch.h
+++ b/lib/notmuch.h
@@ -686,6 +686,7 @@ notmuch_message_get_filename (notmuch_message_t *message);

 /* Message flags */
 typedef enum _notmuch_message_flag {
+NOTMUCH_MSG_FLAG_MATCHING_SEARCH,
 } notmuch_message_flag_t;

 /* Get a value of a flag for the email corresponding to 'message'. */
diff --git a/lib/thread.cc b/lib/thread.cc
index 58d88c2..9e4cb5c 100644
--- a/lib/thread.cc
+++ b/lib/thread.cc
@@ -132,6 +132,7 @@ _thread_add_matched_message (notmuch_thread_t *thread,
 notmuch_message_t *message)
 {
 time_t date;
+notmuch_message_t *hashed_message;

 date = notmuch_message_get_date (message);

@@ -142,6 +143,13 @@ _thread_add_matched_message (notmuch_thread_t *thread,
thread->newest = date;

 thread->matched_messages++;
+
+if (g_hash_table_lookup_extended (thread->message_hash,
+   notmuch_message_get_message_id (message), NULL,
+   (void **) &hashed_message)) {
+   notmuch_message_set_flag (hashed_message,
+   NOTMUCH_MSG_FLAG_MATCHING_SEARCH, 1);
+}
 }

 static void
-- 
1.6.4.4.2.gc2f148



[notmuch] [PATCH 1/3] message: add flags to notmuch_message_t

2009-11-24 Thread Bart Trojanowski
This patch allows for different flags, internal to notmuch, to be set on a
message object.  The patch does not define any such flags, just the
facilities to manage these flags.

Signed-off-by: Bart Trojanowski 
---
 lib/message.cc |   19 +++
 lib/notmuch.h  |   14 ++
 2 files changed, 33 insertions(+), 0 deletions(-)

diff --git a/lib/message.cc b/lib/message.cc
index 1e325e2..e0834f1 100644
--- a/lib/message.cc
+++ b/lib/message.cc
@@ -37,6 +37,7 @@ struct _notmuch_message {
 char *filename;
 notmuch_message_file_t *message_file;
 notmuch_message_list_t *replies;
+unsigned long flags;

 Xapian::Document doc;
 };
@@ -108,6 +109,7 @@ _notmuch_message_create (const void *talloc_owner,
 message->doc_id = doc_id;

 message->frozen = 0;
+message->flags = 0;

 /* Each of these will be lazily created as needed. */
 message->message_id = NULL;
@@ -445,6 +447,23 @@ notmuch_message_get_filename (notmuch_message_t *message)
 return message->filename;
 }

+notmuch_bool_t
+notmuch_message_get_flag (notmuch_message_t *message,
+ notmuch_message_flag_t flag)
+{
+return message->flags & (1 << flag);
+}
+
+void
+notmuch_message_set_flag (notmuch_message_t *message,
+ notmuch_message_flag_t flag, notmuch_bool_t enable)
+{
+if (enable)
+   message->flags |= (1 << flag);
+else
+   message->flags &= ~(1 << flag);
+}
+
 time_t
 notmuch_message_get_date (notmuch_message_t *message)
 {
diff --git a/lib/notmuch.h b/lib/notmuch.h
index 8bba442..c232c58 100644
--- a/lib/notmuch.h
+++ b/lib/notmuch.h
@@ -684,6 +684,20 @@ notmuch_message_get_replies (notmuch_message_t *message);
 const char *
 notmuch_message_get_filename (notmuch_message_t *message);

+/* Message flags */
+typedef enum _notmuch_message_flag {
+} notmuch_message_flag_t;
+
+/* Get a value of a flag for the email corresponding to 'message'. */
+notmuch_bool_t
+notmuch_message_get_flag (notmuch_message_t *message,
+ notmuch_message_flag_t flag);
+
+/* Set a value of a flag for the email corresponding to 'message'. */
+void
+notmuch_message_set_flag (notmuch_message_t *message,
+ notmuch_message_flag_t flag, notmuch_bool_t value);
+
 /* Get the date of 'message' as a time_t value.
  *
  * For the original textual representation of the Date header from the
-- 
1.6.4.4.2.gc2f148



[notmuch] notmuch show should tell us what messages matched the search expression

2009-11-24 Thread Bart Trojanowski
The following 3 patches implement this feature.

Internally the message object learns about flags.  Only a single flag is
defined to denote that a message matched the search expression.

That flag is then rendered on the "message{" line in the output of
notmuch show like this:

message{ id:... depth:4 match:0 filename:...
message{ id:... depth:4 match:1 filename:...

This can now be used by UI interfaces to hide or collapse less
interesting messages.

-Bart


[notmuch] [PATCH 0/4] Make tags applied by 'notmuch new' configurable.

2009-11-24 Thread Bart Trojanowski
* Jan Janak  [091124 17:11]:
> I would like to propose that we make the list of tags applied by 'notmuch new'
> configurable. Right now notmuch applies two tags to all new messages added to
> the database, 'inbox' and 'unread'. The two tags are added by the C code in
> notmuch-new.c and they cannot be changed without editing the source file and
> recompiling notmuch.

I like it.

-Bart

-- 
WebSig: http://www.jukie.net/~bart/sig/


[notmuch] [PATCH] notmuch-show: add option to limit display to only matching messages

2009-11-24 Thread Bart Trojanowski
This patch adds support for notmuch show --only-matching-messages
which limits the output to only the top level messages matching
the search terms provides.

Example:

$ notmuch search subject:git AND thread:23d99d0f364f93e90e15df8b42eddb5b
thread:23d99d0f364f93e90e15df8b42eddb5b  July 31 [4/12] Johan Herland; 
[RFCv2 00/12] Foreign VCS helper program for CVS repositories (inbox unread)

Note that in this thread 4 out of 12 messages matched.  The default show
behaviour is to show all messages in the thread:

$ notmuch show subject:git AND thread:23d99d0f364f93e90e15df8b42eddb5b | grep 
'message{' | wc -l
12

With the --only-matching-messages option the output is limited to the
matching messages only:

$ notmuch show --only-matching-messages subject:git AND 
thread:23d99d0f364f93e90e15df8b42eddb5b | grep 'message{' | wc -l
4

Signed-off-by: Bart Trojanowski 
---
 notmuch-show.c |   48 +---
 notmuch.c  |7 +++
 2 files changed, 44 insertions(+), 11 deletions(-)

diff --git a/notmuch-show.c b/notmuch-show.c
index edebaca..8599c6c 100644
--- a/notmuch-show.c
+++ b/notmuch-show.c
@@ -211,6 +211,24 @@ notmuch_show_command (void *ctx, unused (int argc), unused 
(char *argv[]))
 notmuch_thread_t *thread;
 notmuch_messages_t *messages;
 char *query_string;
+int only_matching = 0;
+int i;
+
+for (i = 0; i < argc && argv[i][0] == '-'; i++) {
+   if (strcmp (argv[i], "--") == 0) {
+   i++;
+   break;
+   }
+if (strcmp(argv[i], "--only-matching-messages") == 0) {
+   only_matching = 1;
+   } else {
+   fprintf (stderr, "Unrecognized option: %s\n", argv[i]);
+   return 1;
+   }
+}
+
+argc -= i;
+argv += i;

 config = notmuch_config_open (ctx, NULL, NULL);
 if (config == NULL)
@@ -238,21 +256,29 @@ notmuch_show_command (void *ctx, unused (int argc), 
unused (char *argv[]))
return 1;
 }

-for (threads = notmuch_query_search_threads (query);
-notmuch_threads_has_more (threads);
-notmuch_threads_advance (threads))
-{
-   thread = notmuch_threads_get (threads);
+if (only_matching) {
+   messages = notmuch_query_search_messages (query);
+   if (messages == NULL)
+   INTERNAL_ERROR ("No messages.\n");
+   show_messages (ctx, messages, 0);

-   messages = notmuch_thread_get_toplevel_messages (thread);
+} else {
+   for (threads = notmuch_query_search_threads (query);
+   notmuch_threads_has_more (threads);
+   notmuch_threads_advance (threads))
+   {
+   thread = notmuch_threads_get (threads);

-   if (messages == NULL)
-   INTERNAL_ERROR ("Thread %s has no toplevel messages.\n",
-   notmuch_thread_get_thread_id (thread));
+   messages = notmuch_thread_get_toplevel_messages (thread);

-   show_messages (ctx, messages, 0);
+   if (messages == NULL)
+   INTERNAL_ERROR ("Thread %s has no toplevel messages.\n",
+   notmuch_thread_get_thread_id (thread));
+
+   show_messages (ctx, messages, 0);

-   notmuch_thread_destroy (thread);
+   notmuch_thread_destroy (thread);
+   }
 }

 notmuch_query_destroy (query);
diff --git a/notmuch.c b/notmuch.c
index f45b692..a817ae3 100644
--- a/notmuch.c
+++ b/notmuch.c
@@ -177,6 +177,13 @@ command_t commands[] = {
   "\t\t(all replies to a particular message appear immediately\n"
   "\t\tafter that message in date order).\n"
   "\n"
+  "\t\tSupported options for show include:\n"
+  "\n"
+  "\t\t--only-matching-messages\n"
+  "\n"
+  "\t\t\tUsing this option will prevent output of any messages\n"
+  "\t\t\tthat do not match the search terms.\n"
+  "\n"
   "\t\tThe output format is plain-text, with all text-content\n"
   "\t\tMIME parts decoded. Various components in the output,\n"
   "\t\t('message', 'header', 'body', 'attachment', and MIME 'part')\n"
-- 
1.6.4.4.2.gc2f148



[notmuch] (no subject)

2009-11-24 Thread Bart Trojanowski
Hi,

I find this patch useful for searching my mail.  I realize that the
option is horrendously long, and I would take any suggestions to shorten
it or to use a short op, like -m.

-Bart



[notmuch] notmuch 'index' mode.

2009-11-24 Thread Bart Trojanowski
* Keith Packard  [091124 11:38]:
> A disadvantage I see is that you would not see this 'virtual tags' in
> the list of tags on each message. And, we'd have to put the virtual tags
> in the .config file or the command line would become a lot less
> useful. Speaking of which, we should put the folders in the .config file
> in any case, and provide command line syntax to use them.

I too would vote for this approach.  I'd like to keep as much smarts in
the notmuch executable as it would mean less to port to other (non
emacs) interfaces.

-Bart

-- 
WebSig: http://www.jukie.net/~bart/sig/


[notmuch] [PATCH 3/3] change config file location to be ~/.notmuch/config

2009-11-22 Thread Bart Trojanowski
I totally agree with Jamie about the config rename.  I don't know if I
agree with the database location change... but I might just need some
convincing.

Would it be enough to just read .notmuch/config and fall back to
.notmuch-config otherwise?

-Bart

* Jameson Graef Rollins  [091122 17:15]:
> Hi, folks.  I wanted to comment on this patch request.
> 
> I personally think it makes a lot of sense to use config directories.
> This makes things much neater, since all config files can be kept in
> one place without clutter the config name space.  I can imagine down
> the line that there may be more notmuch config files, and it would be
> nicer to have a config directory rather than a bunch of ~/.notmuch-*
> files in the user dot file config space.
> 
> I also imagine this config directory as a place to store the notmuch
> database files.  I would rather keep all the notmuch data and config
> files together in one place, and keep my mail directories completely
> untouched (only read) by notmuch, if possible.
> 
> I realize, however, there is a transition problem associated with
> moving the config file, which is why I propose it be moved sooner
> rather than later.  If folks are interested in this change, and are
> worried about transition even at this early stage, we can try to come
> up with some smoother transition code.
> 
> Finally, I am (maybe clearly) *not* particularly adept at c
> programming.  I'm still learning.  I think I already have better ways
> to improve this patch.  I will try to make some improvements and send
> those along as well.
> 
> jamie.
> 
> PS. I'm sure this has already been discussed on the list, but if this
> is not the best way to send patches, please let me know.  I would be
> happy to send a pointer to my notmuch git repo if it would be
> preferable to just pull from it directly.
> 
> 
> On Sun, Nov 22, 2009 at 04:58:36PM -0500, Jameson Graef Rollins wrote:
> > This change creates a ~/.notmuch config directory where the config
> > file is stored when created with the "setup" command.  The use of a
> > ~/.notmuch config directory creates one place where all notmuch config
> > files and data can be stored, which will greatly simplify managing
> > notmuch, and reduce cluter of user dot files.
> > ---
> >  notmuch-config.c |   21 ++---
> >  notmuch-setup.c  |2 +-
> >  notmuch.1|4 ++--
> >  notmuch.c|2 +-
> >  4 files changed, 22 insertions(+), 7 deletions(-)
> > 
> > diff --git a/notmuch-config.c b/notmuch-config.c
> > index 7252a19..321c880 100644
> > --- a/notmuch-config.c
> > +++ b/notmuch-config.c
> > @@ -22,9 +22,11 @@
> >  
> >  #include 
> >  #include 
> > +#include 
> > +#include 
> >  
> >  static const char toplevel_config_comment[] =
> > -" .notmuch-config - Configuration file for the notmuch mail system\n"
> > +" .notmuch/config - Configuration file for the notmuch mail system\n"
> >  "\n"
> >  " For more information about notmuch, see http://notmuchmail.org";;
> >  
> > @@ -134,7 +136,7 @@ get_username_from_passwd_file (void *ctx)
> >  
> >  /* Open the named notmuch configuration file. A filename of NULL will
> >   * be interpreted as the default configuration file
> > - * ($HOME/.notmuch-config).
> > + * ($HOME/.notmuch/config).
> >   *
> >   * If any error occurs, (out of memory, or a permission-denied error,
> >   * etc.), this function will print a message to stderr and return
> > @@ -183,7 +185,7 @@ notmuch_config_open (void *ctx,
> >  if (filename)
> > config->filename = talloc_strdup (config, filename);
> >  else
> > -   config->filename = talloc_asprintf (config, "%s/.notmuch-config",
> > +   config->filename = talloc_asprintf (config, "%s/.notmuch/config",
> > getenv ("HOME"));
> >  
> >  config->key_file = g_key_file_new ();
> > @@ -297,14 +299,27 @@ notmuch_config_save (notmuch_config_t *config)
> >  {
> >  size_t length;
> >  char *data;
> > +char buf[256];
> >  GError *error = NULL;
> >  
> > +struct stat statbuf;
> > +
> >  data = g_key_file_to_data (config->key_file, &length, NULL);
> >  if (data == NULL) {
> > fprintf (stderr, "Out of memory.\n");
> > return 1;
> >  }
> >  
> > +/* Create config directory if it doesn't already exist */
> > +snprintf(buf, sizeof buf, "%s", config->filename);
> > +dirname(buf);
> > +if (stat(buf, &statbuf) < 0) {
> > +  if (mkdir(buf, 0755) < 0) {
> > +   fprintf (stderr, "Could not create directory '%s'\n.", buf);
> > +   return 1;
> > +  }
> > +}
> > +
> >  if (! g_file_set_contents (config->filename, data, length, &error)) {
> > fprintf (stderr, "Error saving configuration to %s: %s\n",
> >  config->filename, error->message);
> > diff --git a/notmuch-setup.c b/notmuch-setup.c
> > index 68788e1..76e104c 100644
> > --- a/notmuch-setup.c
> > +++ b/notmuch-setup.c
> > @@ -74,7 +74,7 @@ welcome_message_post_setup (void)
> 

[notmuch] Catching up unread messages

2009-11-22 Thread Bart Trojanowski
* Tassilo Horn  [091122 16:49]:
> Ok, so new the question: I indexed all my 63.000 mails, and because it
> was a first-time indexing, all my mail now has the tags inbox and
> unread.  Of course, I don't want to SPC through all threads (using the
> great emacs interface) to remove the unread status.  So is there some
> catchup command, which marks all messages in the buffer as read?

notmuch tag -unread -- tag:unread

-Bart

-- 
WebSig: http://www.jukie.net/~bart/sig/


[notmuch] [RFC] Precedence of OR and AND

2009-11-22 Thread Bart Trojanowski
* Jed Brown  [091122 16:43]:
> Absolutely, and I have this applied locally to notmuch.el, but I didn't
> fix notmuch-search-filter-by-tag because that would really need to parse
> the expression.  I'm just asking if anyone else thinks binding OR
> tighter than AND would be desirable.

Maybe some of the ambiguity would go away if we used && and || instead
of AND and OR.  Then no matter the default, we could distinguish if
someone meant 2 or 3 tags when they typed in 'foo and bar'.

-Bart

-- 
WebSig: http://www.jukie.net/~bart/sig/


[notmuch] [RFC] Precedence of OR and AND

2009-11-22 Thread Bart Trojanowski
Wouldn't this problem be solved by each filter appending a bracketed
version of your filter?

You start with tag:inbox and you filter on "term1 or term2" you'd get:

tag:inbox and (term1 or term2)

Doing it again would result in...

tag:inbox and (term1 or term2) and (term3 or term4)

To me, it would seem the most intuitive solution.

Actually, I think I'll add that to notmuch.vim right now. :)

-Bart

* Jed Brown  [091122 16:26]:
> Currently OR binds more weakly than AND, which is natural in most
> contexts, but I think it is rarely desirably for this sort of search.
> Suppose I am in looking at my inbox and decide to filter by
> 
>   term1 OR term2
> 
> Notmuch makes the query
> 
>   tag:inbox AND term1 OR term2
> 
> which is actually
> 
>   (tag:inbox AND term1) OR term2
> 
> and not at all what I wanted.  Adding the necessary parentheses to
> notmuch-search-filter is trivial but it requires more parentheses for
> the overwhelming majority of searches that I think are more common.
> 
> Are most searches indeed closer to conjunctive form?
> 
> Should OR bind tighter than AND?
> 
> 
> Jed
> ___
> notmuch mailing list
> notmuch at notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch

-- 
WebSig: http://www.jukie.net/~bart/sig/


[notmuch] [PATCH] Add SCons build files.

2009-11-22 Thread Bart Trojanowski
My bad.  I totally misread your introduction.

* Jeffrey Ollie  [091122 11:46]:
> The SCons build files are not meant to require emacs.  If I've messed
> something up and emacs is somehow required I would consider that a bug
> and would try to fix it.
> 
> As far as availability, I'm sure that SCons is one yum or apt-get or
>  away.   The only
> people that would face more than a minor inconvenience are people that
> prefer to download tarballs and compile and install things themselves.
> 
> Yes, I'm sure that make is widely available, but as notmuch gets used
> on a wider variety of systems some sort of configuration system will
> become necessary.  If I can prevent another project from going down
> the autoconf/automake path I'll be happy.  I started creating CMake
> build files but I don't know CMake well enough to come up with a
> working build.
> 
> On 11/22/09, Bart Trojanowski  wrote:
> > * Jeffrey C. Ollie  [091122 08:47]:
> >> The SCons build files included here *should* do everything that the
> >> current Makefiles do, plus a little bit of configuration checking.  To
> >> build/install:
> >
> > Wouldn't that have the unfortunate side effect of making notmuch
> > unusable w/o emacs and scons installed?
> >
> > GNU make has a much wider install base, and notmuch is still very useful
> > without emacs.
> >
> > -Bart
> >
> > --
> > WebSig: http://www.jukie.net/~bart/sig/
> >
> 
> -- 
> Sent from my mobile device
> 
> Jeff Ollie

-- 
WebSig: http://www.jukie.net/~bart/sig/


[notmuch] [PATCH] fix notmuch-new bug when database path ends with a trailing /

2009-11-22 Thread Bart Trojanowski
I configured my database.path with a trailing /, and after running notmuch
new every notmuch search would fail with error messages like this:

  Error opening /inbox/cur/1258565257.000211.mbox:2,S: No such file or directory

The actual bug was in the filename normalization for storage in the
database.  The database.path was removed from the full filename, but if
the database.path from the config file contained a trailing /, the
relative file name would retain an extra leading /... which made it look
like an absolute path after it was read out from the DB.

Signed-off-by: Bart Trojanowski 
---
 lib/message.cc |   10 +++---
 1 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/lib/message.cc b/lib/message.cc
index 017c47b..1e325e2 100644
--- a/lib/message.cc
+++ b/lib/message.cc
@@ -411,10 +411,14 @@ _notmuch_message_set_filename (notmuch_message_t *message,
 db_path = notmuch_database_get_path (message->notmuch);
 db_path_len = strlen (db_path);

-if (*s == '/' && strncmp (s, db_path, db_path_len) == 0
-   && strlen (s) > db_path_len)
+if (*s == '/' && strlen (s) > db_path_len
+   && strncmp (s, db_path, db_path_len) == 0)
 {
-   s += db_path_len + 1;
+   s += db_path_len;
+   while (*s == '/') s++;
+
+   if (!*s)
+   INTERNAL_ERROR ("Message filename was same as db prefix.");
 }

 message->doc.set_data (s);
-- 
1.6.4.4.2.gc2f148



[notmuch] [PATCH] Add SCons build files.

2009-11-22 Thread Bart Trojanowski
* Jeffrey C. Ollie  [091122 08:47]:
> The SCons build files included here *should* do everything that the
> current Makefiles do, plus a little bit of configuration checking.  To
> build/install:

Wouldn't that have the unfortunate side effect of making notmuch
unusable w/o emacs and scons installed?

GNU make has a much wider install base, and notmuch is still very useful
without emacs.

-Bart

-- 
WebSig: http://www.jukie.net/~bart/sig/


[notmuch] notmuch vim support

2009-11-21 Thread Bart Trojanowski
* Carl Worth  [091121 15:20]:
> On Sat, 21 Nov 2009 14:14:02 -0500, Bart Trojanowski  
> wrote:
> > Perfect.  How would you like to proceed with the initial integration?
> > Pulling my tree, or me squashing all the changes into a single patch?
> > Also, are you OK with where the files live (ie under a vim directory).
> 
> I'm glad to pull (it will be nice for you to have the accurate
> history). And a vim directory sounds perfect.

Indeed.

> Or should we do interfaces/emacs and interfaces/vim ? I don't know.

I don't really have a preference.  As long as 'make install' at the top
doesn't install both/either blindly.

> Email or pull requests are fine. You're clearly the "owner" of the vim
> stuff, so don't expect any refusals to pull from me. (And feel free to
> ping me out of band if you don't want to clutter the list with pull
> requests---but it's more likely that you'll want to let people on the
> list know about changes anyway.)

Great.  Thanks.  I'll keep the list informed.

-Bart

-- 
WebSig: http://www.jukie.net/~bart/sig/


[notmuch] notmuch vim support

2009-11-21 Thread Bart Trojanowski
* Carl Worth  [091121 15:14]:
> So, well done!

Thank you.

> I think the only thing we noticed is that "filter" doesn't add the "and"
> between the old and new search terms. But Chris may have more to comment
> soon.

I think I fixed that along the way.  I'll verify.

> I don't know how realistic it will be to keep both interfaces totally
> synchronized in terms of look-and-feel, colors, keybindings, etc. But it
> might be nice to do that as much as possible. I think it would be
> helpful if we could have interface discussions as an entire community
> and not split based on choice of editor.

Perfect.

-Bart

-- 
WebSig: http://www.jukie.net/~bart/sig/


[notmuch] [PATCH 2/2] notmuch list: A new command to produce various lists.

2009-11-21 Thread Bart Trojanowski
* Carl Worth  [091121 18:08]:
> Another option would be to just call this "notmuch search" and have an
> option to control what is output:
> 
>notmuch search # for threads, as currently
>notmuch search --output=tags
>notmuch search --output=messages
> 
> Actually, I kind of like that. For one thing, it makes it easy to
> eliminate the redundancy I made with the option-parsing in both
> notmuch-search.c and notmuch-search-message.c.

I too prefer this option.  It keeps the interface and code simpler.

Moreover, it might also eliminate the need for 'notmuch count'. Simply
pass --count-only to the search command.

-Bart

-- 
WebSig: http://www.jukie.net/~bart/sig/


[notmuch] hijacked threads can be confusing in notmuch

2009-11-21 Thread Bart Trojanowski
I'd like to see how other people feel about a problem I just ran into.

I wanted to look at the 'notmuch count' patch that Keith Packard posted
a couple of days ago (as I am porting his folder mode to notmuch.vim).

I was unable to find it using notmuch because he happened to post 3
patches in one go.  It's pretty common git practice, and by no means to
I hold Keith responsible :)

In mutt it looked like this:

  [notmuch] [PATCH 1/3] Make mouse-1 click in search view show thread
  ??>[notmuch] [PATCH 2/3] Add 'notmuch count' command to show the count of 
matching messages
??>[notmuch] [PATCH 3/3] Add notmuch-index mode to display message 
counts

... and in the mutt threaded display the relationship between the three
messages is pretty clear.

Now consider what happens when I run notmuch search 'notmuch count'.  I
get this:

  Today 02:15 [2/3] Keith Packard; [notmuch] [PATCH 1/3] Make mouse-1 click in 
search view show thread (inbox unread)

This thread happens to look completely unrelated to my search at first
glance.  So naturally, I dismissed it.  I finally clued in what was
happening and came back to it after.

On a related note, one mail related pet peeve I have is when people
reply to a random email in their mailbox when they actually intend to
start a new thread.  Doing that would totally mess up someone using
notmuch.  They could get search results with threads which have no
relevance to their actual search... at least at first glance.

So is there something better that we could do when detecting hijacked
threads like this?  Is it safe to cut threads when you notice a topic
change?  Or maybe it would be better to just mark such threads in the
output of notmuch-search (either a boolean flag, or a count of topic
changes).

Anyone know how Gmail deals with this?

Cheers,
-Bart

-- 
WebSig: http://www.jukie.net/~bart/sig/


[notmuch] [PATCH] notmuch: Add Maildir directory name as tag name for messages

2009-11-21 Thread Bart Trojanowski
* Carl Worth  [091121 15:28]:
> And sadly, I just pulled it out again.
> 
> I realized that I actually don't want my mail tagged based on the
> maildir directories I'm using, (they are arbitrarily-named directories
> used only to keep the per-directory number of files below about 10
> thousand).
> 
> So we'll probably need to make this an opt-in feature from the
> configuration file.

I think notmuch needs something that will add tags based on the
attributes of a message (headers or body), as it imports data from a
maildir.

I am currently considering having procmail deliver to date based
(-MM) folders and have notmuch determine what tags they should get.

-Bart

-- 
WebSig: http://www.jukie.net/~bart/sig/


[notmuch] notmuch vim support

2009-11-21 Thread Bart Trojanowski
* Stefan Schmidt  [091121 14:06]:
> IMHO it would be best to do the development inside the main tree. You could 
> use
> branches there too and it would be easier to find and test. And as notmuch is
> still under heavy development its not a problem that the vim interface is as
> well.

Perfect.  How would you like to proceed with the initial integration?
Pulling my tree, or me squashing all the changes into a single patch?
Also, are you OK with where the files live (ie under a vim directory).

After that, do you want me to submit patches by email, via pull
requests, or giving me push access to a branch at your repo?

BTW, have you considered using github or gitorious so branch management
becomes a distributed problem?

Cheers,
-Bart

-- 
WebSig: http://www.jukie.net/~bart/sig/


[notmuch] notmuch vim support

2009-11-21 Thread Bart Trojanowski
Hi list,

I've spent a few days on porting notmuch.el to vim.  It's not as feature
rich as notmuch.el yet, but it's coming along nicely.  The results of my
work are here:

git://git.jukie.net/notmuch.git (on the vim branch)
http://git.jukie.net/notmuch.git?a=shortlog;h=refs/heads/vim

There are some screenshots in my blog:

http://www.jukie.net/~bart/blog/notmuch.vim

List of supported features are in the README:

http://git.jukie.net/notmuch.git?a=blob;f=vim/README;hb=refs/heads/vim

I'd love for this to be included in the official project, but I am not
sure if you'd prefer to merge at this point or wait will I am done.
Naturally, if anyone is interested I'd love some help.

Cheers,

-Bart

-- 
WebSig: http://www.jukie.net/~bart/sig/