[PATCH v2 2/2] cli: add support for pre and post notmuch new hooks

2011-12-03 Thread Austin Clements
Quoth Jani Nikula on Dec 04 at  1:16 am:
> Run notmuch new pre and post hooks, named "pre-new" and "post-new", if
> present in the notmuch hooks directory. The hooks will be run before and
> after incorporating new messages to the database.
> 
> Typical use cases for pre-new and post-new hooks are fetching or delivering
> new mail to the maildir, and custom tagging of the mail incorporated to the
> database.
> 
> Also add command line option --no-hooks to notmuch new to bypass the hooks.
> 
> Signed-off-by: Jani Nikula 
> ---
>  notmuch-new.c |   12 
>  notmuch.1 |   50 +-
>  2 files changed, 61 insertions(+), 1 deletions(-)
> 
> diff --git a/notmuch-new.c b/notmuch-new.c
> index 81a9350..27dde0c 100644
> --- a/notmuch-new.c
> +++ b/notmuch-new.c
> @@ -811,6 +811,7 @@ notmuch_new_command (void *ctx, int argc, char *argv[])
>  _filename_node_t *f;
>  int i;
>  notmuch_bool_t timer_is_active = FALSE;
> +int run_hooks = 1;

notmuch_bool_t?

>  
>  add_files_state.verbose = 0;
>  add_files_state.output_is_a_tty = isatty (fileno (stdout));
> @@ -820,6 +821,8 @@ notmuch_new_command (void *ctx, int argc, char *argv[])
>  for (i = 0; i < argc && argv[i][0] == '-'; i++) {
>   if (STRNCMP_LITERAL (argv[i], "--verbose") == 0) {
>   add_files_state.verbose = 1;
> + } else if (STRNCMP_LITERAL (argv[i], "--no-hooks") == 0) {

I see this mistake all over notmuch, so maybe it's better to
perpetuate it here and fix it everywhere in another patch, but this
should be strcmp, not STRNCMP_LITERAL.  STRNCMP_LITERAL is the right
thing for options that take values, but for boolean options like this,
it will accept
  notmuch new --no-hooks-just-kidding

> + run_hooks = 0;
>   } else {
>   fprintf (stderr, "Unrecognized option: %s\n", argv[i]);
>   return 1;
> @@ -833,6 +836,12 @@ notmuch_new_command (void *ctx, int argc, char *argv[])
>  add_files_state.synchronize_flags = 
> notmuch_config_get_maildir_synchronize_flags (config);
>  db_path = notmuch_config_get_database_path (config);
>  
> +if (run_hooks) {
> + ret = notmuch_run_hook (db_path, "pre-new");
> + if (ret)
> + return ret;
> +}
> +
>  dot_notmuch_path = talloc_asprintf (ctx, "%s/%s", db_path, ".notmuch");
>  
>  if (stat (dot_notmuch_path, )) {
> @@ -981,5 +990,8 @@ notmuch_new_command (void *ctx, int argc, char *argv[])
>  
>  notmuch_database_close (notmuch);
>  
> +if (run_hooks && !ret && !interrupted)
> + ret = notmuch_run_hook (db_path, "post-new");

Does it matter at this point if the hook fails?  I'm not sure.

> +
>  return ret || interrupted;
>  }
> diff --git a/notmuch.1 b/notmuch.1
> index 92931d7..66f82e9 100644
> --- a/notmuch.1
> +++ b/notmuch.1

I am willfully ignorant of nroff, so somebody else will have to
comment if any of the nroff code/formatting is wrong.

> @@ -85,7 +85,7 @@ The
>  command is used to incorporate new mail into the notmuch database.
>  .RS 4
>  .TP 4
> -.B new
> +.BR new " [options...]"
>  
>  Find and import any new messages to the database.
>  
> @@ -118,6 +118,22 @@ if
>  has previously been completed, but
>  .B "notmuch new"
>  has not previously been run.
> +
> +The
> +.B new
> +command supports hooks. See the
> +.B "HOOKS"
> +section below for more details on hooks.
> +
> +Supported options for
> +.B new
> +include
> +.RS 4
> +.TP 4
> +.BR \-\-no\-hooks
> +
> +Prevents hooks from being run.
> +.RE
>  .RE
>  
>  Several of the notmuch commands accept search terms with a common
> @@ -705,6 +721,38 @@ specify a date range to return messages from 
> 2009\-10\-01 until the
>  current time:
>  
>   $(date +%s \-d 2009\-10\-01)..$(date +%s)
> +.SH HOOKS
> +Hooks are scripts (or arbitrary executables or symlinks to such) you can 
> place
> +in the notmuch hooks directory to trigger action at certain points. The hooks
> +directory is .notmuch/hooks within the database directory. The user must have
> +executable permission set on the scripts.

Could be more concise.  Maybe something like "Hooks are scripts (or
arbitrary executables or symlinks to such) that notmuch invokes before
and after certain actions.  These scripts reside in the .notmuch/hooks
directory within the database directory and must have executable
permissions."

> +
> +The currently available hooks are described below.
> +.RS 4
> +.TP 4
> +.B pre\-new
> +This hook is invoked by the
> +.B new
> +command before scanning or importing new messages into the database. Any 
> errors
> +in running the hook will abort further processing of the

"If this script exits with a non-zero status, notmuch will abort ..."?

> +.B new
> +command.
> +
> +Typical use case for this hook is fetching or delivering new mail to be 
> imported
> +into the database.

Perhaps "Typically this hook is used for ..."?

> +.RE
> +.RS 4
> +.TP 4
> +.B post\-new
> +This hook is invoked by the
> +.B new
> 

[PATCH v2 1/2] cli: introduce the concept of user defined hooks

2011-12-03 Thread Austin Clements
I like it.  See below for some nits.

Quoth Jani Nikula on Dec 04 at  1:16 am:
> Add mechanism for running user defined hooks. Hooks are executables or
> symlinks to executables stored under the new notmuch hooks directory,
> /.notmuch/hooks.
> 
> No hooks are introduced here, but adding support for a hook is now a simple
> matter of calling the new notmuch_run_hook() function at an appropriate
> location with the hook name.
> 
> Signed-off-by: Jani Nikula 
> 
> ---
> 
> v2: Switch to git style hooks in a hook directory as suggested by Austin
> Clements in IRC. Update manpage and add polish.
> ---
>  Makefile.local   |1 +
>  notmuch-client.h |3 ++
>  notmuch-hook.c   |   63 
> ++
>  3 files changed, 67 insertions(+), 0 deletions(-)
>  create mode 100644 notmuch-hook.c
> 
> diff --git a/Makefile.local b/Makefile.local
> index c94402b..a1665e1 100644
> --- a/Makefile.local
> +++ b/Makefile.local
> @@ -302,6 +302,7 @@ notmuch_client_srcs = \
>   notmuch-config.c\
>   notmuch-count.c \
>   notmuch-dump.c  \
> + notmuch-hook.c  \
>   notmuch-new.c   \
>   notmuch-reply.c \
>   notmuch-restore.c   \
> diff --git a/notmuch-client.h b/notmuch-client.h
> index b50cb38..a91ad6c 100644
> --- a/notmuch-client.h
> +++ b/notmuch-client.h
> @@ -235,6 +235,9 @@ void
>  notmuch_config_set_maildir_synchronize_flags (notmuch_config_t *config,
> notmuch_bool_t synchronize_flags);
>  
> +int
> +notmuch_run_hook (const char *db_path, const char *hook);
> +
>  notmuch_bool_t
>  debugger_is_active (void);
>  
> diff --git a/notmuch-hook.c b/notmuch-hook.c
> new file mode 100644
> index 000..fc32044
> --- /dev/null
> +++ b/notmuch-hook.c
> @@ -0,0 +1,63 @@
> +/* notmuch - Not much of an email program, (just index and search)
> + *
> + * This file is part of notmuch.
> + *
> + * Copyright ? 2011 Jani Nikula
> + *
> + * This program is free software: you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation, either version 3 of the License, or
> + * (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program.  If not, see http://www.gnu.org/licenses/ .
> + *
> + * Author: Jani Nikula 
> + */
> +
> +#include "notmuch-client.h"
> +
> +int
> +notmuch_run_hook (const char *db_path, const char *hook)
> +{
> +char *hook_path;
> +int status = 0;

You use status as both a notmuch_status_t and for generic C library
results.  This seems a little weird.  You may or may not want to do
anything about it.

> +
> +if (asprintf (_path, "%s/%s/%s/%s", db_path, ".notmuch", "hooks",
> +   hook) == -1)

asprintf isn't very portable.  Perhaps talloc_asprintf would be
better?  (And more idiomatic.)

> + return NOTMUCH_STATUS_OUT_OF_MEMORY;
> +
> +if (access (hook_path, X_OK) == -1) {
> + /* Ignore ENOENT. It's okay not to have a hook, hook dir, or even
> +  * notmuch dir. Dangling symbolic links also result in ENOENT, but
> +  * we'll ignore that too for simplicity. */
> + if (errno != ENOENT) {
> + fprintf (stderr, "Error: %s hook access failed: %s\n", hook,
> +  strerror (errno));
> + status = NOTMUCH_STATUS_FILE_ERROR;
> + }
> + goto DONE;
> +}
> +
> +status = system (hook_path);

It would probably be better to fork/execl.  system is sensitive to all
sorts of weird things because it invokes the shell (e.g., spaces or
funny characters in db_path) and it plays funny games with signals.

Really proper error handling with fork/exec is a pain, but I think you
can get away with something simpler and even get rid of the access
call in the process.  Something like

ret = fork();
if (ret < 0) ...
else if (ret == 0) {
  ret = execl(hook_path, hook_path, NULL);
  if (ret != ENOENT && ret != EACCESS)
print a real error message
  exit(0);
} else {
  waitpid(ret, , 0);
  if (status) .. checks you do now ..
}

I guess this wastes a fork if there is no hook script, so maybe the
access call is worth doing anyway.

> +if (status) {
> + if (WIFSIGNALED(status))
> + fprintf(stderr, "Error: %s hook terminated with signal %d\n", hook,
> + WTERMSIG(status));
> + else
> + fprintf(stderr, "Error: %s hook failed with status %d\n", hook,
> + WEXITSTATUS(status));
> +
> + status = NOTMUCH_STATUS_FILE_ERROR; /* Close enough */
> +}
> +
> +  DONE:
> +free (hook_path);
> +
> +return 

[PATCH] have LATEST-notmuch-.tar.gz on releases web page

2011-12-03 Thread David Bremner
On Thu, 24 Nov 2011 22:41:01 +0200, Tomi Ollila  wrote:
> The notmuchmail/releases page used to have LATEST-notmuch-
> to link to the latest notmuch source tarball. This is confusing on
> web page and on disk when the file has been downloaded. This change
> looks a bit inconsistent with the 'rm' command just executed before.
> $(TAR_FILE) is defined (currently) as $(PACKAGE)-$(VERSION).tar.gz;
> as long as the prefix stays $(PACKAGE)-$(VERSION) and version begins
> with a digit then this line is good in execution point of view.

On IRC we talked about changing the rm command in this since I
bootstrapped the process by hand. Did you come to a conclusion one way
or the other?

d


[PATCH 1/2] python: add classes to wrap all notmuch_*_t types

2011-12-03 Thread Justus Winter
Quoting James Westby (2011-12-03 00:24:18)
>On Fri, 02 Dec 2011 09:20:35 -0500, James Westby <jw+debian at 
>jameswestby.net> wrote:
>> I'll test again to make sure that I have this correct, but my tests
>> yesterday certainly suggested that your patches fixed this.
>
>Yep, segfaults a plenty dropping your second patch that go away again
>when it is applied once more.

Happy to hear that :)

Justus
-- next part --
A non-text attachment was scrubbed...
Name: .signature
Type: application/octet-stream
Size: 17 bytes
Desc: not available
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20111203/a1d273c5/attachment.obj>


Re: [PATCH] have LATEST-notmuch-version.tar.gz on releases web page

2011-12-03 Thread David Bremner
On Thu, 24 Nov 2011 22:41:01 +0200, Tomi Ollila tomi.oll...@nixu.com wrote:
 The notmuchmail/releases page used to have LATEST-notmuch-version
 to link to the latest notmuch source tarball. This is confusing on
 web page and on disk when the file has been downloaded. This change
 looks a bit inconsistent with the 'rm' command just executed before.
 $(TAR_FILE) is defined (currently) as $(PACKAGE)-$(VERSION).tar.gz;
 as long as the prefix stays $(PACKAGE)-$(VERSION) and version begins
 with a digit then this line is good in execution point of view.

On IRC we talked about changing the rm command in this since I
bootstrapped the process by hand. Did you come to a conclusion one way
or the other?

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


[PATCH v2 1/2] cli: introduce the concept of user defined hooks

2011-12-03 Thread Jani Nikula
Add mechanism for running user defined hooks. Hooks are executables or
symlinks to executables stored under the new notmuch hooks directory,
database-path/.notmuch/hooks.

No hooks are introduced here, but adding support for a hook is now a simple
matter of calling the new notmuch_run_hook() function at an appropriate
location with the hook name.

Signed-off-by: Jani Nikula j...@nikula.org

---

v2: Switch to git style hooks in a hook directory as suggested by Austin
Clements in IRC. Update manpage and add polish.
---
 Makefile.local   |1 +
 notmuch-client.h |3 ++
 notmuch-hook.c   |   63 ++
 3 files changed, 67 insertions(+), 0 deletions(-)
 create mode 100644 notmuch-hook.c

diff --git a/Makefile.local b/Makefile.local
index c94402b..a1665e1 100644
--- a/Makefile.local
+++ b/Makefile.local
@@ -302,6 +302,7 @@ notmuch_client_srcs =   \
notmuch-config.c\
notmuch-count.c \
notmuch-dump.c  \
+   notmuch-hook.c  \
notmuch-new.c   \
notmuch-reply.c \
notmuch-restore.c   \
diff --git a/notmuch-client.h b/notmuch-client.h
index b50cb38..a91ad6c 100644
--- a/notmuch-client.h
+++ b/notmuch-client.h
@@ -235,6 +235,9 @@ void
 notmuch_config_set_maildir_synchronize_flags (notmuch_config_t *config,
  notmuch_bool_t synchronize_flags);
 
+int
+notmuch_run_hook (const char *db_path, const char *hook);
+
 notmuch_bool_t
 debugger_is_active (void);
 
diff --git a/notmuch-hook.c b/notmuch-hook.c
new file mode 100644
index 000..fc32044
--- /dev/null
+++ b/notmuch-hook.c
@@ -0,0 +1,63 @@
+/* notmuch - Not much of an email program, (just index and search)
+ *
+ * This file is part of notmuch.
+ *
+ * Copyright © 2011 Jani Nikula
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see http://www.gnu.org/licenses/ .
+ *
+ * Author: Jani Nikula j...@nikula.org
+ */
+
+#include notmuch-client.h
+
+int
+notmuch_run_hook (const char *db_path, const char *hook)
+{
+char *hook_path;
+int status = 0;
+
+if (asprintf (hook_path, %s/%s/%s/%s, db_path, .notmuch, hooks,
+ hook) == -1)
+   return NOTMUCH_STATUS_OUT_OF_MEMORY;
+
+if (access (hook_path, X_OK) == -1) {
+   /* Ignore ENOENT. It's okay not to have a hook, hook dir, or even
+* notmuch dir. Dangling symbolic links also result in ENOENT, but
+* we'll ignore that too for simplicity. */
+   if (errno != ENOENT) {
+   fprintf (stderr, Error: %s hook access failed: %s\n, hook,
+strerror (errno));
+   status = NOTMUCH_STATUS_FILE_ERROR;
+   }
+   goto DONE;
+}
+
+status = system (hook_path);
+if (status) {
+   if (WIFSIGNALED(status))
+   fprintf(stderr, Error: %s hook terminated with signal %d\n, hook,
+   WTERMSIG(status));
+   else
+   fprintf(stderr, Error: %s hook failed with status %d\n, hook,
+   WEXITSTATUS(status));
+
+   status = NOTMUCH_STATUS_FILE_ERROR; /* Close enough */
+}
+
+  DONE:
+free (hook_path);
+
+return status;
+}
-- 
1.7.5.4

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


Re: [PATCH v2 1/2] cli: introduce the concept of user defined hooks

2011-12-03 Thread Austin Clements
I like it.  See below for some nits.

Quoth Jani Nikula on Dec 04 at  1:16 am:
 Add mechanism for running user defined hooks. Hooks are executables or
 symlinks to executables stored under the new notmuch hooks directory,
 database-path/.notmuch/hooks.
 
 No hooks are introduced here, but adding support for a hook is now a simple
 matter of calling the new notmuch_run_hook() function at an appropriate
 location with the hook name.
 
 Signed-off-by: Jani Nikula j...@nikula.org
 
 ---
 
 v2: Switch to git style hooks in a hook directory as suggested by Austin
 Clements in IRC. Update manpage and add polish.
 ---
  Makefile.local   |1 +
  notmuch-client.h |3 ++
  notmuch-hook.c   |   63 
 ++
  3 files changed, 67 insertions(+), 0 deletions(-)
  create mode 100644 notmuch-hook.c
 
 diff --git a/Makefile.local b/Makefile.local
 index c94402b..a1665e1 100644
 --- a/Makefile.local
 +++ b/Makefile.local
 @@ -302,6 +302,7 @@ notmuch_client_srcs = \
   notmuch-config.c\
   notmuch-count.c \
   notmuch-dump.c  \
 + notmuch-hook.c  \
   notmuch-new.c   \
   notmuch-reply.c \
   notmuch-restore.c   \
 diff --git a/notmuch-client.h b/notmuch-client.h
 index b50cb38..a91ad6c 100644
 --- a/notmuch-client.h
 +++ b/notmuch-client.h
 @@ -235,6 +235,9 @@ void
  notmuch_config_set_maildir_synchronize_flags (notmuch_config_t *config,
 notmuch_bool_t synchronize_flags);
  
 +int
 +notmuch_run_hook (const char *db_path, const char *hook);
 +
  notmuch_bool_t
  debugger_is_active (void);
  
 diff --git a/notmuch-hook.c b/notmuch-hook.c
 new file mode 100644
 index 000..fc32044
 --- /dev/null
 +++ b/notmuch-hook.c
 @@ -0,0 +1,63 @@
 +/* notmuch - Not much of an email program, (just index and search)
 + *
 + * This file is part of notmuch.
 + *
 + * Copyright © 2011 Jani Nikula
 + *
 + * This program is free software: you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
 + * the Free Software Foundation, either version 3 of the License, or
 + * (at your option) any later version.
 + *
 + * This program is distributed in the hope that it will be useful,
 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 + * GNU General Public License for more details.
 + *
 + * You should have received a copy of the GNU General Public License
 + * along with this program.  If not, see http://www.gnu.org/licenses/ .
 + *
 + * Author: Jani Nikula j...@nikula.org
 + */
 +
 +#include notmuch-client.h
 +
 +int
 +notmuch_run_hook (const char *db_path, const char *hook)
 +{
 +char *hook_path;
 +int status = 0;

You use status as both a notmuch_status_t and for generic C library
results.  This seems a little weird.  You may or may not want to do
anything about it.

 +
 +if (asprintf (hook_path, %s/%s/%s/%s, db_path, .notmuch, hooks,
 +   hook) == -1)

asprintf isn't very portable.  Perhaps talloc_asprintf would be
better?  (And more idiomatic.)

 + return NOTMUCH_STATUS_OUT_OF_MEMORY;
 +
 +if (access (hook_path, X_OK) == -1) {
 + /* Ignore ENOENT. It's okay not to have a hook, hook dir, or even
 +  * notmuch dir. Dangling symbolic links also result in ENOENT, but
 +  * we'll ignore that too for simplicity. */
 + if (errno != ENOENT) {
 + fprintf (stderr, Error: %s hook access failed: %s\n, hook,
 +  strerror (errno));
 + status = NOTMUCH_STATUS_FILE_ERROR;
 + }
 + goto DONE;
 +}
 +
 +status = system (hook_path);

It would probably be better to fork/execl.  system is sensitive to all
sorts of weird things because it invokes the shell (e.g., spaces or
funny characters in db_path) and it plays funny games with signals.

Really proper error handling with fork/exec is a pain, but I think you
can get away with something simpler and even get rid of the access
call in the process.  Something like

ret = fork();
if (ret  0) ...
else if (ret == 0) {
  ret = execl(hook_path, hook_path, NULL);
  if (ret != ENOENT  ret != EACCESS)
print a real error message
  exit(0);
} else {
  waitpid(ret, status, 0);
  if (status) .. checks you do now ..
}

I guess this wastes a fork if there is no hook script, so maybe the
access call is worth doing anyway.

 +if (status) {
 + if (WIFSIGNALED(status))
 + fprintf(stderr, Error: %s hook terminated with signal %d\n, hook,
 + WTERMSIG(status));
 + else
 + fprintf(stderr, Error: %s hook failed with status %d\n, hook,
 + WEXITSTATUS(status));
 +
 + status = NOTMUCH_STATUS_FILE_ERROR; /* Close enough */
 +}
 +
 +  DONE:
 +free (hook_path);
 +
 +return status;
 +}
___
notmuch mailing 

Re: [PATCH v2 2/2] cli: add support for pre and post notmuch new hooks

2011-12-03 Thread Austin Clements
Quoth Jani Nikula on Dec 04 at  1:16 am:
 Run notmuch new pre and post hooks, named pre-new and post-new, if
 present in the notmuch hooks directory. The hooks will be run before and
 after incorporating new messages to the database.
 
 Typical use cases for pre-new and post-new hooks are fetching or delivering
 new mail to the maildir, and custom tagging of the mail incorporated to the
 database.
 
 Also add command line option --no-hooks to notmuch new to bypass the hooks.
 
 Signed-off-by: Jani Nikula j...@nikula.org
 ---
  notmuch-new.c |   12 
  notmuch.1 |   50 +-
  2 files changed, 61 insertions(+), 1 deletions(-)
 
 diff --git a/notmuch-new.c b/notmuch-new.c
 index 81a9350..27dde0c 100644
 --- a/notmuch-new.c
 +++ b/notmuch-new.c
 @@ -811,6 +811,7 @@ notmuch_new_command (void *ctx, int argc, char *argv[])
  _filename_node_t *f;
  int i;
  notmuch_bool_t timer_is_active = FALSE;
 +int run_hooks = 1;

notmuch_bool_t?

  
  add_files_state.verbose = 0;
  add_files_state.output_is_a_tty = isatty (fileno (stdout));
 @@ -820,6 +821,8 @@ notmuch_new_command (void *ctx, int argc, char *argv[])
  for (i = 0; i  argc  argv[i][0] == '-'; i++) {
   if (STRNCMP_LITERAL (argv[i], --verbose) == 0) {
   add_files_state.verbose = 1;
 + } else if (STRNCMP_LITERAL (argv[i], --no-hooks) == 0) {

I see this mistake all over notmuch, so maybe it's better to
perpetuate it here and fix it everywhere in another patch, but this
should be strcmp, not STRNCMP_LITERAL.  STRNCMP_LITERAL is the right
thing for options that take values, but for boolean options like this,
it will accept
  notmuch new --no-hooks-just-kidding

 + run_hooks = 0;
   } else {
   fprintf (stderr, Unrecognized option: %s\n, argv[i]);
   return 1;
 @@ -833,6 +836,12 @@ notmuch_new_command (void *ctx, int argc, char *argv[])
  add_files_state.synchronize_flags = 
 notmuch_config_get_maildir_synchronize_flags (config);
  db_path = notmuch_config_get_database_path (config);
  
 +if (run_hooks) {
 + ret = notmuch_run_hook (db_path, pre-new);
 + if (ret)
 + return ret;
 +}
 +
  dot_notmuch_path = talloc_asprintf (ctx, %s/%s, db_path, .notmuch);
  
  if (stat (dot_notmuch_path, st)) {
 @@ -981,5 +990,8 @@ notmuch_new_command (void *ctx, int argc, char *argv[])
  
  notmuch_database_close (notmuch);
  
 +if (run_hooks  !ret  !interrupted)
 + ret = notmuch_run_hook (db_path, post-new);

Does it matter at this point if the hook fails?  I'm not sure.

 +
  return ret || interrupted;
  }
 diff --git a/notmuch.1 b/notmuch.1
 index 92931d7..66f82e9 100644
 --- a/notmuch.1
 +++ b/notmuch.1

I am willfully ignorant of nroff, so somebody else will have to
comment if any of the nroff code/formatting is wrong.

 @@ -85,7 +85,7 @@ The
  command is used to incorporate new mail into the notmuch database.
  .RS 4
  .TP 4
 -.B new
 +.BR new  [options...]
  
  Find and import any new messages to the database.
  
 @@ -118,6 +118,22 @@ if
  has previously been completed, but
  .B notmuch new
  has not previously been run.
 +
 +The
 +.B new
 +command supports hooks. See the
 +.B HOOKS
 +section below for more details on hooks.
 +
 +Supported options for
 +.B new
 +include
 +.RS 4
 +.TP 4
 +.BR \-\-no\-hooks
 +
 +Prevents hooks from being run.
 +.RE
  .RE
  
  Several of the notmuch commands accept search terms with a common
 @@ -705,6 +721,38 @@ specify a date range to return messages from 
 2009\-10\-01 until the
  current time:
  
   $(date +%s \-d 2009\-10\-01)..$(date +%s)
 +.SH HOOKS
 +Hooks are scripts (or arbitrary executables or symlinks to such) you can 
 place
 +in the notmuch hooks directory to trigger action at certain points. The hooks
 +directory is .notmuch/hooks within the database directory. The user must have
 +executable permission set on the scripts.

Could be more concise.  Maybe something like Hooks are scripts (or
arbitrary executables or symlinks to such) that notmuch invokes before
and after certain actions.  These scripts reside in the .notmuch/hooks
directory within the database directory and must have executable
permissions.

 +
 +The currently available hooks are described below.
 +.RS 4
 +.TP 4
 +.B pre\-new
 +This hook is invoked by the
 +.B new
 +command before scanning or importing new messages into the database. Any 
 errors
 +in running the hook will abort further processing of the

If this script exits with a non-zero status, notmuch will abort ...?

 +.B new
 +command.
 +
 +Typical use case for this hook is fetching or delivering new mail to be 
 imported
 +into the database.

Perhaps Typically this hook is used for ...?

 +.RE
 +.RS 4
 +.TP 4
 +.B post\-new
 +This hook is invoked by the
 +.B new
 +command after new messages have been imported into the database and initial 
 tags
 +have been applied. The hook will not be run if there have been any 

Re: [DRAFT PATCH] emacs: support limiting the number of results shown in search results

2011-12-03 Thread Aneesh Kumar K.V
On Thu, 17 Nov 2011 22:07:38 +0200, Jani Nikula j...@nikula.org wrote:
 Add support for limiting the maximum number of results initially displayed
 in search results. When enabled, the search results will contain push
 buttons to double the number of results displayed or to show unlimited
 results.
 
 The approach is inspired by vc-print-log in Emacs vc.el.
 
 Signed-off-by: Jani Nikula j...@nikula.org
 

This break notmuch-search-operate-all, I guess the change should also
make sure notmuch-search-operate-all also limit its operation to
notmuch-search-limit ?

-aneesh

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