how to make postfix running with notmuch-deliver

2012-04-10 Thread Jani Nikula
David Belohrad  writes:
> is there any 'standard' setup procedure how to make notmuch-deliver
> (from contrib/notmuch-deliver repo) working correctly with postfix? I
> was thinking to make a record in master.cf, but I'm not sure how this
> would have to be setup. As well what is not clear to me is, whether
> notmuch-deliver calls notmuch post-new hook (where I store additional
> tagging instructions)...

Only "notmuch new" runs pre-new and post-new hooks.

BR,
Jani.


[PATCH 1/2] cli: make --entire-thread=false work for format=json.

2012-04-10 Thread Mark Walters
On Tue, 10 Apr 2012, Adam Wolfe Gordon  wrote:
> Hi Mark,
>
> This looks good to me, but I haven't tested it. It's probably worth
> adding a test for the new functionality.

Yes I agree. I could add a test to the json tests, or I could update the
pair of test patches at
id:"1332171061-27983-1-git-send-email-markwalters1009 at gmail.com" as
there do not seem to be any tests for --entire-thread or not for the
other formats either. What do you think?

> One style issue below, which is a matter of taste and I'll defer to
> others if they disagree:
>
> On Tue, Apr 10, 2012 at 11:04, Mark Walters  
> wrote:
>> @@ -895,10 +905,11 @@ show_messages (void *ctx,
>> ? ? ? ? ? ?if (status && !res)
>> ? ? ? ? ? ? ? ?res = status;
>> ? ? ? ? ? ?next_indent = indent + 1;
>> + ? ? ? } else
>> + ? ? ? ? ? status = show_null_message (format);
>
> I accept, but don't particularly like, the notmuch style of omitting
> braces where they aren't required. However, an else with a brace on
> only one side just looks weird. If they're like this everywhere else
> then I guess it's best to be consistent, but to me it's a lot more
> readable as } else {.
>
> As I said above, I'll defer to others' judgement here, just thought it
> was worth pointing out.

Yes I will fix this in the next version (I recall Jani agreed with you
so I will take that as preferred unless someone says otherwise.)

thanks

Mark


[PATCH 1/4] Make configure use /bin/bash instead of /bin/sh

2012-04-10 Thread Tomi Ollila
On Mon, Apr 09 2012, Vladimir Marek wrote:

>> > Posix /bin/sh is not capable of running this configure and fails.
>> 
>> What fails? What would it take to make this work on posix sh instead?
>> 
>> The tests do require bash, but generally I think it would be preferable to
>> not depend on bash to build.
>
> Well I gave it a quick stab. This is not posix:
>
> BLAH=$( ... )
> BLAH=$(( ... ))
> ${option%=*}
> ${option%%=*}
> ${option#=*}
> ${option##=*}

According to 

http://pubs.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html

all of those are part of Shell Command Language...

Does the configure script work if you replace /bin/sh with /bin/ksh
in your Solaris box

If yes, something like the following could be added to the beginning
of 'configure'

option=option=value
if test ! x"${option$*=}" = x"value" 2>/dev/null; then
if test x"${PREVENT_LOOPING-}" = x; then
PREVENT_LOOPING=true; export PREVENT_LOOPING
test ! -x /bin/ksh || exec /bin/ksh "$0" "$@"
test ! -x /bin/bash || exec /bin/bash "$0" "$@"
fi
echo "Cannot find compatible shell for '$0'" >&2
exit 1
fi



>
> First two cases are easy to replace by `...` resp `expr ...`. The rest
> leads to external utility like sed. The dirtiest part of configure is
> parsing the commandline arguments, but that could be replaced by
> /usr/bin/getopts.
>
> If it is appealing way of doing that, I can rework my patch and submit
> it for consideration.
>
> Thank you
> -- 
>   Vlad
> ___
> notmuch mailing list
> notmuch at notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH] replace gnu xargs usage in notmuch-mutt with perl

2012-04-10 Thread Tomi Ollila
On Tue, Apr 10 2012, Taylor Carpenter wrote:

> ---

what if instead of

> +my @filelist = `notmuch search --output=files $query`;
> +foreach(@filelist) {

there is:

  open my $fh, '-|', qw/notmuch search --output=files/, $query;
  while (<$fh>) { 
   ...
  }
  unless (close $fh) {
 # handle error case
  }

Tomi

(in addition to more verbose commit message & unrelated change moved to
another commit)


>  contrib/notmuch-mutt/notmuch-mutt |   12 
>  1 files changed, 8 insertions(+), 4 deletions(-)
>
> diff --git a/contrib/notmuch-mutt/notmuch-mutt 
> b/contrib/notmuch-mutt/notmuch-mutt
> index 71206c3..dbe7f2d 100755
> --- a/contrib/notmuch-mutt/notmuch-mutt
> +++ b/contrib/notmuch-mutt/notmuch-mutt
> @@ -1,4 +1,4 @@
> -#!/usr/bin/perl -w
> +#!/usr/bin/env perl -w
>  #
>  # notmuch-mutt - notmuch (of a) helper for Mutt
>  #
> @@ -12,6 +12,7 @@ use strict;
>  use warnings;
>  
>  use File::Path;
> +use File::Basename;
>  use Getopt::Long qw(:config no_getopt_compat);
>  use Mail::Internet;
>  use Mail::Box::Maildir;
> @@ -41,9 +42,12 @@ sub search($$) {
>  $query = shell_quote($query);
>  
>  empty_maildir($maildir);
> -system("notmuch search --output=files $query"
> -. " | sed -e 's: : :g'"
> -. " | xargs --no-run-if-empty ln -s -t $maildir/cur/");
> +my @filelist = `notmuch search --output=files $query`;
> +foreach(@filelist) {
> +chomp;
> +my $target = sprintf("$maildir/cur/%s", basename($_));
> +symlink($_, $target);
> +}
>  }
>  
>  sub prompt($$) {
> -- 
> 1.7.7.4
>
> ___
> notmuch mailing list
> notmuch at notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH] emacs: get rid of trailing spaces in notmuch-hello view

2012-04-10 Thread Tomi Ollila
On Sat, Mar 10 2012, Dmitry Kurochkin  wrote:

> This patch removes trailing spaces in notmuch-hello view.
>
> A side effect of this change is that tag/query buttons no longer
> include a space at the end.  This means that pressing RET when the
> point is at the first character after the tag/query button no longer
> works (note that this is the standard behavior for buttons).  We may
> change this behavior in the future (without adding trailing spaces
> back) if people would find this change inconvenient.
> ---

LGTM.

Tomi


[PATCH v3 4/5] config: Add 'config list' command

2012-04-10 Thread Peter Wang
On Tue, 10 Apr 2012 00:22:01 -0700, Jameson Graef Rollins  wrote:
> On Thu, Apr 05 2012, Peter Wang  wrote:
> 
> > -if (strcmp (argv[0], "get") == 0)
> > +if (strcmp (argv[0], "get") == 0) {
> > +   if (argc < 2) {
> > +   fprintf (stderr, "Error: notmuch config get requires at least "
> > +"two arguments.\n");
> > +   return 1;
> > +   }
> > return notmuch_config_command_get (ctx, argv[1]);
> > -else if (strcmp (argv[0], "set") == 0)
> > +} else if (strcmp (argv[0], "set") == 0) {
> > +   if (argc < 2) {
> > +   fprintf (stderr, "Error: notmuch config set requires at least "
> > +"two arguments.\n");
> > +   return 1;
> > +   }
> > return notmuch_config_command_set (ctx, argv[1], argc - 2, argv + 2);
> 
> But then these changes look unrelated to me.  They do look good
> intentioned, though.  It's probably best to submit these changes in a
> separate unrelated patch.

Well, the only reason to duplicate the arity check is due to the
introduction of the 'list' subcommand.  But I see that the error
messages are wrong anyway, so I will separate out the changes in another
patch series.

Peter


[PATCH 2/2] emacs: make elide messages use notmuch-show for omitting messages.

2012-04-10 Thread Mark Walters
Previously the elide messages code got the entire-thread from
notmuch-show.c and then threw away all non-matching messages. This
version calls notmuch-show.c without the --entire-thread flag so
it never receives the non-matching messages in the first place.

This makes it substantially faster.
---
 emacs/notmuch-show.el |   17 +
 1 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 30b26d1..31e6937 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -976,9 +976,9 @@ current buffer, if possible."
   "Insert the message tree TREE at depth DEPTH in the current thread."
   (let ((msg (car tree))
(replies (cadr tree)))
-(if (or (not notmuch-show-elide-non-matching-messages)
-   (plist-get msg :match))
-   (notmuch-show-insert-msg msg depth))
+;; We test whether there is a message or just some replies.
+(when msg
+  (notmuch-show-insert-msg msg depth))
 (notmuch-show-insert-thread replies (1+ depth

 (defun notmuch-show-insert-thread (thread depth)
@@ -1059,16 +1059,17 @@ function is used."
 (args (if notmuch-show-query-context
   (append (list "\'") basic-args
   (list "and (" notmuch-show-query-context ")\'"))
-(append (list "\'") basic-args (list "\'")
-   (notmuch-show-insert-forest (notmuch-query-get-threads
-(cons "--exclude=false" args)))
+(append (list "\'") basic-args (list "\'"
+(cli-args (when notmuch-show-elide-non-matching-messages
+(list "--entire-thread=false" "--exclude=false"
+
+   (notmuch-show-insert-forest (notmuch-query-get-threads (append cli-args 
args)))
;; If the query context reduced the results to nothing, run
;; the basic query.
(when (and (eq (buffer-size) 0)
   notmuch-show-query-context)
  (notmuch-show-insert-forest
-  (notmuch-query-get-threads
-   (cons "--exclude=false" basic-args)
+  (notmuch-query-get-threads (append cli-args basic-args)

   (jit-lock-register #'notmuch-show-buttonise-links)

-- 
1.7.9.1



[PATCH 1/2] cli: make --entire-thread=false work for format=json.

2012-04-10 Thread Mark Walters
The --entire-thread option in notmuch-show.c defaults to true when
format=json. Previously there was no way to turn this off. This patch
makes it respect --entire-thread=false.

The one subtlety is that we initialise a notmuch_bool_t to -1 to
indicate that the option parsing has not set it. This allows the code
to distinguish between the option being omitted from the command line,
and the option being set to false on the command line.

Finally, all formats except Json can output empty messages for non
entire-thread, but in Json format we need to output {} to keep the
other elements (e.g. the replies to this message) in the correct
place.
---
 notmuch-show.c |   33 -
 1 files changed, 28 insertions(+), 5 deletions(-)

diff --git a/notmuch-show.c b/notmuch-show.c
index 7af8e64..5d58bfd 100644
--- a/notmuch-show.c
+++ b/notmuch-show.c
@@ -809,6 +809,16 @@ format_part_raw (unused (const void *ctx), mime_node_t 
*node,
 }

 static notmuch_status_t
+show_null_message (const notmuch_show_format_t *format)
+{
+/* For all formats except json an empty message output is valid;
+ * for json we need the braces.*/
+if (format == _json)
+   printf ("{}");
+return NOTMUCH_STATUS_SUCCESS;
+}
+
+static notmuch_status_t
 show_message (void *ctx,
  const notmuch_show_format_t *format,
  notmuch_message_t *message,
@@ -895,10 +905,11 @@ show_messages (void *ctx,
if (status && !res)
res = status;
next_indent = indent + 1;
+   } else
+   status = show_null_message (format);

-   if (!status)
-   fputs (format->message_set_sep, stdout);
-   }
+   if (!status)
+   fputs (format->message_set_sep, stdout);

status = show_messages (ctx,
format,
@@ -1013,7 +1024,13 @@ notmuch_show_command (void *ctx, unused (int argc), 
unused (char *argv[]))
 char *query_string;
 int opt_index, ret;
 const notmuch_show_format_t *format = _text;
-notmuch_show_params_t params = { .part = -1, .omit_excluded = TRUE };
+
+/* We abuse the notmuch_bool_t variable params.entire-thread by
+ * setting it to -1 to denote that the command line parsing has
+ * not set it. We ensure it is set to TRUE or FALSE before passing
+ * it to any other function.*/
+notmuch_show_params_t params = { .part = -1, .entire_thread = -1 };
+
 int format_sel = NOTMUCH_FORMAT_NOT_SPECIFIED;
 notmuch_bool_t verify = FALSE;
 int exclude = EXCLUDE_TRUE;
@@ -1053,7 +1070,9 @@ notmuch_show_command (void *ctx, unused (int argc), 
unused (char *argv[]))
 switch (format_sel) {
 case NOTMUCH_FORMAT_JSON:
format = _json;
-   params.entire_thread = TRUE;
+   /* JSON defaults to entire-thread TRUE */
+   if (params.entire_thread == -1)
+   params.entire_thread = TRUE;
break;
 case NOTMUCH_FORMAT_TEXT:
format = _text;
@@ -1075,6 +1094,10 @@ notmuch_show_command (void *ctx, unused (int argc), 
unused (char *argv[]))
params.raw = TRUE;
break;
 }
+/* Default is entire-thread = FALSE except for format=json which
+ * is dealt with above. */
+if (params.entire_thread == -1)
+   params.entire_thread = FALSE;

 if (params.decrypt || verify) {
 #ifdef GMIME_ATLEAST_26
-- 
1.7.9.1



[PATCH 0/2] Allow JSON to use non-entire thread, and use for elide

2012-04-10 Thread Mark Walters
These two patches supersede the series [1] and the first patch
replaces [2].

The first patch allows --entire-thread=false for notmuch-show.c when
the output format is JSON. In the previous version [2] Austin
suggested that we should output an empty message (i.e., {}) for
non-matching messages rather than just omitting them. This version
does that.

Note the first patch is entirely functional without the second.

The second patch uses the first to implement the "elide" functionality
in the emacs interface on the cli-side rather than on the emacs
side. This is substantially faster in some cases. In current emacs
show view it is a relatively small speed-up which is only noticable
with large threads. However, it will be used by notmuch-pick [3] and
there the speed up will be important. (I have a current version of
notmuch-pick which I will submit in the near future.)

Best wishes

Mark


[1] id:"1330033294-21980-1-git-send-email-markwalters1009 at gmail.com"
[2] id:"1331377533-30262-3-git-send-email-markwalters1009 at gmail.com"
[3] id:"1329072579-27340-1-git-send-email-markwalters1009 at gmail.com"

Mark Walters (2):
  cli: make --entire-thread=false work for format=json.
  emacs: make elide messages use notmuch-show for omitting messages.

 emacs/notmuch-show.el |   17 +
 notmuch-show.c|   33 -
 2 files changed, 37 insertions(+), 13 deletions(-)

-- 
1.7.9.1



how to make postfix running with notmuch-deliver

2012-04-10 Thread David Belohrad
Dear All,
is there any 'standard' setup procedure how to make notmuch-deliver
(from contrib/notmuch-deliver repo) working correctly with postfix? I
was thinking to make a record in master.cf, but I'm not sure how this
would have to be setup. As well what is not clear to me is, whether
notmuch-deliver calls notmuch post-new hook (where I store additional
tagging instructions)...

any help appreciated

david



[PATCH 1/2] cli: make --entire-thread=false work for format=json.

2012-04-10 Thread Adam Wolfe Gordon
Hi Mark,

This looks good to me, but I haven't tested it. It's probably worth
adding a test for the new functionality.

One style issue below, which is a matter of taste and I'll defer to
others if they disagree:

On Tue, Apr 10, 2012 at 11:04, Mark Walters  
wrote:
> @@ -895,10 +905,11 @@ show_messages (void *ctx,
> ? ? ? ? ? ?if (status && !res)
> ? ? ? ? ? ? ? ?res = status;
> ? ? ? ? ? ?next_indent = indent + 1;
> + ? ? ? } else
> + ? ? ? ? ? status = show_null_message (format);

I accept, but don't particularly like, the notmuch style of omitting
braces where they aren't required. However, an else with a brace on
only one side just looks weird. If they're like this everywhere else
then I guess it's best to be consistent, but to me it's a lot more
readable as } else {.

As I said above, I'll defer to others' judgement here, just thought it
was worth pointing out.

-- Adam


[PATCH] emacs: get rid of trailing spaces in notmuch-hello view

2012-04-10 Thread Adam Wolfe Gordon
On Fri, Mar 9, 2012 at 20:54, Dmitry Kurochkin
 wrote:
> This patch removes trailing spaces in notmuch-hello view.
>
> A side effect of this change is that tag/query buttons no longer
> include a space at the end. ?This means that pressing RET when the
> point is at the first character after the tag/query button no longer
> works (note that this is the standard behavior for buttons). ?We may
> change this behavior in the future (without adding trailing spaces
> back) if people would find this change inconvenient.

LGTM, and works as expected.

(Sorry if you get this twice, Dmitry.)


[PATCH 4/4] Explicitly type void* pointers

2012-04-10 Thread Vladimir Marek
[...]

> I'm throwing in a third alternative below. Does it work for you? I think
> it's both prettier and uglier than the above at the same time! ;)
> 
> A middle ground would be to change the callers to use
> "notmuch_talloc_steal", and just #define notmuch_talloc_steal
> talloc_steal if __GNUC__ >= 3.
> 
> One could argue upstream talloc should have this, but OTOH it's a C
> library.

That's a nice trick, and it indeed works for me. And I like it more than
what I suggested.

Thank you
-- 
Vlad


[PATCH 4/4] Explicitly type void* pointers

2012-04-10 Thread Jani Nikula
Vladimir Marek  writes:

> Hi,
>
>> Hi, does notmuch not compile without this? IIRC talloc_steal is a macro
>> that's supposed to provide type safety (at least with GCC), and I'd be
>> hesitant about adding the casts. Please look in your talloc.h.
>
> It does not compile. It might be that I'm using Sun/Oracle CC instead of
> gcc. The error looks like this:
>
> "lib/database.cc", line 1368: Error: Cannot assign void* to const char*.

In general, that's not a difference in the C++ compilers. You can't
assign 'void *' to 'T *' in C++.

> When looking into talloc documentation, the definition seems to be:
>
> void* talloc_steal ( const void * new_ctx, const void * ptr )
>
> http://talloc.samba.org/talloc/doc/html/group__talloc.html#gaccc66139273e727183fb5bdda11ef82c
>
>
> When looking into talloc.h, it says:
>
> /* try to make talloc_set_destructor() and talloc_steal() type safe,
>if we have a recent gcc */

It just so happens that the trick for type safety fixes the problem for
recent GCC by having an explicit cast.

> So, maybe the way to satisfy everyone would be:
>
> notmuch_message_t *tmp_message = message;
> talloc_steal(notmuch, tmp_message);
> return(tmp_message);
>
> Or alternatively,
>
> #if (__GNUC__ >= 3)
>return talloc_steal (notmuch, message);
> #else
>return (notmuch_message_t*) talloc_steal (notmuch, message);
> #fi
>
>
> Of course I'm happy either way :)

I'm throwing in a third alternative below. Does it work for you? I think
it's both prettier and uglier than the above at the same time! ;)

A middle ground would be to change the callers to use
"notmuch_talloc_steal", and just #define notmuch_talloc_steal
talloc_steal if __GNUC__ >= 3.

One could argue upstream talloc should have this, but OTOH it's a C
library.

BR,
Jani.


diff --git a/lib/notmuch-private.h b/lib/notmuch-private.h
index ea836f7..83b46e8 100644
--- a/lib/notmuch-private.h
+++ b/lib/notmuch-private.h
@@ -499,4 +499,22 @@ _notmuch_filenames_create (const void *ctx,

 NOTMUCH_END_DECLS

+#ifdef __cplusplus
+/* Implicit typecast from 'void *' to 'T *' is okay in C, but not in
+ * C++. In talloc_steal, an explicit cast is provided for type safety
+ * in some GCC versions. Otherwise, a cast is required. Provide a
+ * template function for this to maintain type safety, and redefine
+ * talloc_steal to use it.
+ */
+#if !(__GNUC__ >= 3)
+template 
+T *notmuch_talloc_steal(const void *new_ctx, const T *ptr)
+{
+return static_cast(talloc_steal(new_ctx, ptr));
+}
+#undef talloc_steal
+#define talloc_steal notmuch_talloc_steal
+#endif
+#endif
+
 #endif


[PATCH v3 2/5] test: Add tests for 'config' command

2012-04-10 Thread Jameson Graef Rollins
On Thu, Apr 05 2012, Peter Wang  wrote:
> +test_begin_subtest "Set string value"
> +notmuch config set foo.bar baz
> +test_expect_equal "$(notmuch config get foo.bar)" "baz"
> +
> +test_begin_subtest "Set list value"
> +notmuch config set foo.list xxx "yyy yyy" "zzz zzz"
> +test_expect_equal "$(notmuch config get foo.list)" "\
> +xxx
> +yyy yyy
> +zzz zzz"

I find it slightly strange to use non-existent fields here, but I also
don't see that it hurts anything either.  At least at the moment.
Another option would be to use an existing field, and change it back
when you're done.

jamie.
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: not available
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20120410/296e2171/attachment.pgp>


Re: [PATCH 4/4] Explicitly type void* pointers

2012-04-10 Thread Vladimir Marek
[...]

 I'm throwing in a third alternative below. Does it work for you? I think
 it's both prettier and uglier than the above at the same time! ;)
 
 A middle ground would be to change the callers to use
 notmuch_talloc_steal, and just #define notmuch_talloc_steal
 talloc_steal if __GNUC__ = 3.
 
 One could argue upstream talloc should have this, but OTOH it's a C
 library.

That's a nice trick, and it indeed works for me. And I like it more than
what I suggested.

Thank you
-- 
Vlad
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH v3 4/5] config: Add 'config list' command

2012-04-10 Thread Jameson Graef Rollins
On Thu, Apr 05 2012, Peter Wang noval...@gmail.com wrote:
 Add a command to list all configuration items with their associated
 values.

 One use is as follows: a MUA may prefer to store data in a central
 notmuch configuration file so that the data is accessible across
 different machines, e.g. an addressbook.  The list command helps
 to implement features such as tab completion on the keys.
 ---
  notmuch-config.c |   66 ++---
  test/config  |1 -
  2 files changed, 62 insertions(+), 5 deletions(-)

 diff --git a/notmuch-config.c b/notmuch-config.c
 index 85fc774..d5540ac 100644
 --- a/notmuch-config.c
 +++ b/notmuch-config.c
 @@ -799,20 +799,78 @@ notmuch_config_command_set (void *ctx, char *item, int 
 argc, char *argv[])
  return ret;
  }
  
 +static int
 +notmuch_config_command_list (void *ctx)
 +{
 +notmuch_config_t *config;
 +char **groups;
 +size_t g, groups_length;
 +
 +config = notmuch_config_open (ctx, NULL, NULL);
 +if (config == NULL)
 + return 1;
 +
 +groups = g_key_file_get_groups (config-key_file, groups_length);
 +if (groups == NULL)
 + return 1;
 +
 +for (g = 0; g  groups_length; g++) {
 + char **keys;
 + size_t k, keys_length;
 +
 + keys = g_key_file_get_keys (config-key_file,
 + groups[g], keys_length, NULL);
 + if (keys == NULL)
 + continue;
 +
 + for (k = 0; k  keys_length; k++) {
 + char *value;
 +
 + value = g_key_file_get_string (config-key_file,
 +groups[g], keys[k], NULL);
 + if (value != NULL) {
 + printf (%s.%s=%s\n, groups[g], keys[k], value);
 + free (value);
 + }
 + }
 +
 + g_strfreev (keys);
 +}
 +
 +g_strfreev (groups);
 +
 +notmuch_config_close (config);
 +
 +return 0;
 +}
 +
  int
  notmuch_config_command (void *ctx, int argc, char *argv[])
  {
  argc--; argv++; /* skip subcommand argument */
  
 -if (argc  2) {
 - fprintf (stderr, Error: notmuch config requires at least two 
 arguments.\n);
 +if (argc  1) {
 + fprintf (stderr, Error: notmuch config requires at least one 
 argument.\n);
   return 1;
  }

Hey, Peter.  I would say everything up to here looks great.

 -if (strcmp (argv[0], get) == 0)
 +if (strcmp (argv[0], get) == 0) {
 + if (argc  2) {
 + fprintf (stderr, Error: notmuch config get requires at least 
 +  two arguments.\n);
 + return 1;
 + }
   return notmuch_config_command_get (ctx, argv[1]);
 -else if (strcmp (argv[0], set) == 0)
 +} else if (strcmp (argv[0], set) == 0) {
 + if (argc  2) {
 + fprintf (stderr, Error: notmuch config set requires at least 
 +  two arguments.\n);
 + return 1;
 + }
   return notmuch_config_command_set (ctx, argv[1], argc - 2, argv + 2);

But then these changes look unrelated to me.  They do look good
intentioned, though.  It's probably best to submit these changes in a
separate unrelated patch.

jamie.


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


Re: [PATCH v3 2/5] test: Add tests for 'config' command

2012-04-10 Thread Jameson Graef Rollins
On Thu, Apr 05 2012, Peter Wang noval...@gmail.com wrote:
 +test_begin_subtest Set string value
 +notmuch config set foo.bar baz
 +test_expect_equal $(notmuch config get foo.bar) baz
 +
 +test_begin_subtest Set list value
 +notmuch config set foo.list xxx yyy yyy zzz zzz
 +test_expect_equal $(notmuch config get foo.list) \
 +xxx
 +yyy yyy
 +zzz zzz

I find it slightly strange to use non-existent fields here, but I also
don't see that it hurts anything either.  At least at the moment.
Another option would be to use an existing field, and change it back
when you're done.

jamie.


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


Re: [PATCH] replace gnu xargs usage in notmuch-mutt with perl

2012-04-10 Thread Stefano Zacchiroli
Hi Taylor, thanks for your patch. It makes sense to me, and has the
beneficial side effect of avoiding a sed pass to do some poor men shell
escaping.

Before applying, however, can you please update it to:

- include a reasonable comment (as suggested by David)
- avoid patching the shebang line (ditto)
- coalesce the sprintf() line into the following symlink line (using
  sprintf seems redundant here: it's plain string concatenation)

Thanks!
Cheers.

PS please Cc:-me on replies
-- 
Stefano Zacchiroli zack@{upsilon.cc,pps.jussieu.fr,debian.org} . o .
Maître de conférences   ..   http://upsilon.cc/zack   ..   . . o
Debian Project Leader...   @zack on identi.ca   ...o o o
« the first rule of tautology club is the first rule of tautology club »
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH v3 4/5] config: Add 'config list' command

2012-04-10 Thread Peter Wang
On Tue, 10 Apr 2012 00:22:01 -0700, Jameson Graef Rollins 
jroll...@finestructure.net wrote:
 On Thu, Apr 05 2012, Peter Wang noval...@gmail.com wrote:
 
  -if (strcmp (argv[0], get) == 0)
  +if (strcmp (argv[0], get) == 0) {
  +   if (argc  2) {
  +   fprintf (stderr, Error: notmuch config get requires at least 
  +two arguments.\n);
  +   return 1;
  +   }
  return notmuch_config_command_get (ctx, argv[1]);
  -else if (strcmp (argv[0], set) == 0)
  +} else if (strcmp (argv[0], set) == 0) {
  +   if (argc  2) {
  +   fprintf (stderr, Error: notmuch config set requires at least 
  +two arguments.\n);
  +   return 1;
  +   }
  return notmuch_config_command_set (ctx, argv[1], argc - 2, argv + 2);
 
 But then these changes look unrelated to me.  They do look good
 intentioned, though.  It's probably best to submit these changes in a
 separate unrelated patch.

Well, the only reason to duplicate the arity check is due to the
introduction of the 'list' subcommand.  But I see that the error
messages are wrong anyway, so I will separate out the changes in another
patch series.

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


how to make postfix running with notmuch-deliver

2012-04-10 Thread David Belohrad
Dear All,
is there any 'standard' setup procedure how to make notmuch-deliver
(from contrib/notmuch-deliver repo) working correctly with postfix? I
was thinking to make a record in master.cf, but I'm not sure how this
would have to be setup. As well what is not clear to me is, whether
notmuch-deliver calls notmuch post-new hook (where I store additional
tagging instructions)...

any help appreciated

david

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


Re: [PATCH] emacs: get rid of trailing spaces in notmuch-hello view

2012-04-10 Thread Adam Wolfe Gordon
On Fri, Mar 9, 2012 at 20:54, Dmitry Kurochkin
dmitry.kuroch...@gmail.com wrote:
 This patch removes trailing spaces in notmuch-hello view.

 A side effect of this change is that tag/query buttons no longer
 include a space at the end.  This means that pressing RET when the
 point is at the first character after the tag/query button no longer
 works (note that this is the standard behavior for buttons).  We may
 change this behavior in the future (without adding trailing spaces
 back) if people would find this change inconvenient.

LGTM, and works as expected.

(Sorry if you get this twice, Dmitry.)
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH] emacs: get rid of trailing spaces in notmuch-hello view

2012-04-10 Thread Tomi Ollila
On Sat, Mar 10 2012, Dmitry Kurochkin dmitry.kuroch...@gmail.com wrote:

 This patch removes trailing spaces in notmuch-hello view.

 A side effect of this change is that tag/query buttons no longer
 include a space at the end.  This means that pressing RET when the
 point is at the first character after the tag/query button no longer
 works (note that this is the standard behavior for buttons).  We may
 change this behavior in the future (without adding trailing spaces
 back) if people would find this change inconvenient.
 ---

LGTM.

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


Re: [PATCH] replace gnu xargs usage in notmuch-mutt with perl

2012-04-10 Thread Tomi Ollila
On Tue, Apr 10 2012, Taylor Carpenter wrote:

 ---

what if instead of

 +my @filelist = `notmuch search --output=files $query`;
 +foreach(@filelist) {

there is:

  open my $fh, '-|', qw/notmuch search --output=files/, $query;
  while ($fh) { 
   ...
  }
  unless (close $fh) {
 # handle error case
  }

Tomi

(in addition to more verbose commit message  unrelated change moved to
another commit)


  contrib/notmuch-mutt/notmuch-mutt |   12 
  1 files changed, 8 insertions(+), 4 deletions(-)

 diff --git a/contrib/notmuch-mutt/notmuch-mutt 
 b/contrib/notmuch-mutt/notmuch-mutt
 index 71206c3..dbe7f2d 100755
 --- a/contrib/notmuch-mutt/notmuch-mutt
 +++ b/contrib/notmuch-mutt/notmuch-mutt
 @@ -1,4 +1,4 @@
 -#!/usr/bin/perl -w
 +#!/usr/bin/env perl -w
  #
  # notmuch-mutt - notmuch (of a) helper for Mutt
  #
 @@ -12,6 +12,7 @@ use strict;
  use warnings;
  
  use File::Path;
 +use File::Basename;
  use Getopt::Long qw(:config no_getopt_compat);
  use Mail::Internet;
  use Mail::Box::Maildir;
 @@ -41,9 +42,12 @@ sub search($$) {
  $query = shell_quote($query);
  
  empty_maildir($maildir);
 -system(notmuch search --output=files $query
 -.  | sed -e 's: : :g'
 -.  | xargs --no-run-if-empty ln -s -t $maildir/cur/);
 +my @filelist = `notmuch search --output=files $query`;
 +foreach(@filelist) {
 +chomp;
 +my $target = sprintf($maildir/cur/%s, basename($_));
 +symlink($_, $target);
 +}
  }
  
  sub prompt($$) {
 -- 
 1.7.7.4

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


[PATCH 0/2] Allow JSON to use non-entire thread, and use for elide

2012-04-10 Thread Mark Walters
These two patches supersede the series [1] and the first patch
replaces [2].

The first patch allows --entire-thread=false for notmuch-show.c when
the output format is JSON. In the previous version [2] Austin
suggested that we should output an empty message (i.e., {}) for
non-matching messages rather than just omitting them. This version
does that.

Note the first patch is entirely functional without the second.

The second patch uses the first to implement the elide functionality
in the emacs interface on the cli-side rather than on the emacs
side. This is substantially faster in some cases. In current emacs
show view it is a relatively small speed-up which is only noticable
with large threads. However, it will be used by notmuch-pick [3] and
there the speed up will be important. (I have a current version of
notmuch-pick which I will submit in the near future.)

Best wishes

Mark


[1] id:1330033294-21980-1-git-send-email-markwalters1...@gmail.com
[2] id:1331377533-30262-3-git-send-email-markwalters1...@gmail.com
[3] id:1329072579-27340-1-git-send-email-markwalters1...@gmail.com

Mark Walters (2):
  cli: make --entire-thread=false work for format=json.
  emacs: make elide messages use notmuch-show for omitting messages.

 emacs/notmuch-show.el |   17 +
 notmuch-show.c|   33 -
 2 files changed, 37 insertions(+), 13 deletions(-)

-- 
1.7.9.1

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


[PATCH 2/2] emacs: make elide messages use notmuch-show for omitting messages.

2012-04-10 Thread Mark Walters
Previously the elide messages code got the entire-thread from
notmuch-show.c and then threw away all non-matching messages. This
version calls notmuch-show.c without the --entire-thread flag so
it never receives the non-matching messages in the first place.

This makes it substantially faster.
---
 emacs/notmuch-show.el |   17 +
 1 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 30b26d1..31e6937 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -976,9 +976,9 @@ current buffer, if possible.
   Insert the message tree TREE at depth DEPTH in the current thread.
   (let ((msg (car tree))
(replies (cadr tree)))
-(if (or (not notmuch-show-elide-non-matching-messages)
-   (plist-get msg :match))
-   (notmuch-show-insert-msg msg depth))
+;; We test whether there is a message or just some replies.
+(when msg
+  (notmuch-show-insert-msg msg depth))
 (notmuch-show-insert-thread replies (1+ depth
 
 (defun notmuch-show-insert-thread (thread depth)
@@ -1059,16 +1059,17 @@ function is used.
 (args (if notmuch-show-query-context
   (append (list \') basic-args
   (list and ( notmuch-show-query-context )\'))
-(append (list \') basic-args (list \')
-   (notmuch-show-insert-forest (notmuch-query-get-threads
-(cons --exclude=false args)))
+(append (list \') basic-args (list \'
+(cli-args (when notmuch-show-elide-non-matching-messages
+(list --entire-thread=false --exclude=false
+
+   (notmuch-show-insert-forest (notmuch-query-get-threads (append cli-args 
args)))
;; If the query context reduced the results to nothing, run
;; the basic query.
(when (and (eq (buffer-size) 0)
   notmuch-show-query-context)
  (notmuch-show-insert-forest
-  (notmuch-query-get-threads
-   (cons --exclude=false basic-args)
+  (notmuch-query-get-threads (append cli-args basic-args)
 
   (jit-lock-register #'notmuch-show-buttonise-links)
 
-- 
1.7.9.1

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


Re: [PATCH 1/2] cli: make --entire-thread=false work for format=json.

2012-04-10 Thread Adam Wolfe Gordon
Hi Mark,

This looks good to me, but I haven't tested it. It's probably worth
adding a test for the new functionality.

One style issue below, which is a matter of taste and I'll defer to
others if they disagree:

On Tue, Apr 10, 2012 at 11:04, Mark Walters markwalters1...@gmail.com wrote:
 @@ -895,10 +905,11 @@ show_messages (void *ctx,
            if (status  !res)
                res = status;
            next_indent = indent + 1;
 +       } else
 +           status = show_null_message (format);

I accept, but don't particularly like, the notmuch style of omitting
braces where they aren't required. However, an else with a brace on
only one side just looks weird. If they're like this everywhere else
then I guess it's best to be consistent, but to me it's a lot more
readable as } else {.

As I said above, I'll defer to others' judgement here, just thought it
was worth pointing out.

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


Re: [PATCH 1/4] Make configure use /bin/bash instead of /bin/sh

2012-04-10 Thread Tomi Ollila
On Mon, Apr 09 2012, Vladimir Marek wrote:

  Posix /bin/sh is not capable of running this configure and fails.
 
 What fails? What would it take to make this work on posix sh instead?
 
 The tests do require bash, but generally I think it would be preferable to
 not depend on bash to build.

 Well I gave it a quick stab. This is not posix:

 BLAH=$( ... )
 BLAH=$(( ... ))
 ${option%=*}
 ${option%%=*}
 ${option#=*}
 ${option##=*}

According to 

http://pubs.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html

all of those are part of Shell Command Language...

Does the configure script work if you replace /bin/sh with /bin/ksh
in your Solaris box

If yes, something like the following could be added to the beginning
of 'configure'

option=option=value
if test ! x${option$*=} = xvalue 2/dev/null; then
if test x${PREVENT_LOOPING-} = x; then
PREVENT_LOOPING=true; export PREVENT_LOOPING
test ! -x /bin/ksh || exec /bin/ksh $0 $@
test ! -x /bin/bash || exec /bin/bash $0 $@
fi
echo Cannot find compatible shell for '$0' 2
exit 1
fi




 First two cases are easy to replace by `...` resp `expr ...`. The rest
 leads to external utility like sed. The dirtiest part of configure is
 parsing the commandline arguments, but that could be replaced by
 /usr/bin/getopts.

 If it is appealing way of doing that, I can rework my patch and submit
 it for consideration.

 Thank you
 -- 
   Vlad
 ___
 notmuch mailing list
 notmuch@notmuchmail.org
 http://notmuchmail.org/mailman/listinfo/notmuch
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: how to make postfix running with notmuch-deliver

2012-04-10 Thread Jani Nikula
David Belohrad da...@belohrad.ch writes:
 is there any 'standard' setup procedure how to make notmuch-deliver
 (from contrib/notmuch-deliver repo) working correctly with postfix? I
 was thinking to make a record in master.cf, but I'm not sure how this
 would have to be setup. As well what is not clear to me is, whether
 notmuch-deliver calls notmuch post-new hook (where I store additional
 tagging instructions)...

Only notmuch new runs pre-new and post-new hooks.

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


Re: [PATCH 1/2] cli: make --entire-thread=false work for format=json.

2012-04-10 Thread Mark Walters
On Tue, 10 Apr 2012, Adam Wolfe Gordon awg+notm...@xvx.ca wrote:
 Hi Mark,

 This looks good to me, but I haven't tested it. It's probably worth
 adding a test for the new functionality.

Yes I agree. I could add a test to the json tests, or I could update the
pair of test patches at
id:1332171061-27983-1-git-send-email-markwalters1...@gmail.com as
there do not seem to be any tests for --entire-thread or not for the
other formats either. What do you think?

 One style issue below, which is a matter of taste and I'll defer to
 others if they disagree:

 On Tue, Apr 10, 2012 at 11:04, Mark Walters markwalters1...@gmail.com wrote:
 @@ -895,10 +905,11 @@ show_messages (void *ctx,
            if (status  !res)
                res = status;
            next_indent = indent + 1;
 +       } else
 +           status = show_null_message (format);

 I accept, but don't particularly like, the notmuch style of omitting
 braces where they aren't required. However, an else with a brace on
 only one side just looks weird. If they're like this everywhere else
 then I guess it's best to be consistent, but to me it's a lot more
 readable as } else {.

 As I said above, I'll defer to others' judgement here, just thought it
 was worth pointing out.

Yes I will fix this in the next version (I recall Jani agreed with you
so I will take that as preferred unless someone says otherwise.)

thanks

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