--- /dev/null
+Return-Path: <jani@nikula.org>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by olra.theworths.org (Postfix) with ESMTP id 77D11431E64\r
+ for <notmuch@notmuchmail.org>; Mon, 22 Sep 2014 02:55:47 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References"\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.7\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
+ tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+ by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id 6ZhzrI+MIBb7 for <notmuch@notmuchmail.org>;\r
+ Mon, 22 Sep 2014 02:55:42 -0700 (PDT)\r
+Received: from mail-wi0-f178.google.com (mail-wi0-f178.google.com\r
+ [209.85.212.178]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+ (No client certificate requested)\r
+ by olra.theworths.org (Postfix) with ESMTPS id E08AA431FB6\r
+ for <notmuch@notmuchmail.org>; Mon, 22 Sep 2014 02:55:03 -0700 (PDT)\r
+Received: by mail-wi0-f178.google.com with SMTP id z2so2595047wiv.17\r
+ for <notmuch@notmuchmail.org>; Mon, 22 Sep 2014 02:55:02 -0700 (PDT)\r
+X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
+ d=1e100.net; s=20130820;\r
+ h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\r
+ :references:in-reply-to:references;\r
+ bh=PBJQxHSoX9KA16B5+BILW0xYv/wo2GniPJ2bC1fie3E=;\r
+ b=OG7lLkpFaelii1+5V3dnr1Eztt+xPnFaeuGH0TLevUN6ZakOAIcXg5SdBC3fDaRL7u\r
+ B/n5Is2o9EETQnXp71uZC/HDyHoLfd1M3s4+pKGK+gCMtgUL3DWTzIZGVuzTKqe65E57\r
+ 48Pe7WxobnKu71xQtoou3DXBlECWgXeatChqDA2T6COOWtgjG3k35O1wLgIhVgQWCV8W\r
+ PdqTnWnhANfafwgy/8xleXe8u6pwAZrDVJIvdcvOENIBxS2BtMgd+Fq5PDDaA5+h6Kdf\r
+ qvYoaK73hrtoksvEFDsMjfBOfiqpf/CgV9LRnFelhgDABz+P2GAULJz+w8zaZOKG9pdk\r
+ tqIg==\r
+X-Gm-Message-State:\r
+ ALoCoQmEffzZ+vvEaj58uiSQjuGWf4MYUVedCNAfbQQKtpZe78xE1qImA452OHG5u3LGQlzeqEHE\r
+X-Received: by 10.194.24.101 with SMTP id t5mr19093082wjf.76.1411379702760;\r
+ Mon, 22 Sep 2014 02:55:02 -0700 (PDT)\r
+Received: from localhost ([2001:4b98:dc0:43:216:3eff:fe1b:25f3])\r
+ by mx.google.com with ESMTPSA id fo6sm11499896wic.3.2014.09.22.02.55.02\r
+ for <multiple recipients>\r
+ (version=TLSv1.1 cipher=RC4-SHA bits=128/128);\r
+ Mon, 22 Sep 2014 02:55:02 -0700 (PDT)\r
+From: Jani Nikula <jani@nikula.org>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH 11/11] cli/insert: add post-insert hook\r
+Date: Mon, 22 Sep 2014 11:55:02 +0200\r
+Message-Id:\r
+ <d9ec63c04f86a9b7fce95be900258bfbb1ce2bbd.1411379395.git.jani@nikula.org>\r
+X-Mailer: git-send-email 1.7.2.5\r
+In-Reply-To: <cover.1411379395.git.jani@nikula.org>\r
+References: <cover.1411379395.git.jani@nikula.org>\r
+In-Reply-To: <cover.1411379395.git.jani@nikula.org>\r
+References: <cover.1411379395.git.jani@nikula.org>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Mon, 22 Sep 2014 09:55:47 -0000\r
+\r
+The post-new hook might no longer be needed or run very often if\r
+notmuch insert is being used. Therefore a post-insert hook is needed\r
+(arguably pre-insert not so much, so don't add one). Also add the\r
+--no-hooks option to skip hooks.\r
+---\r
+ notmuch-insert.c | 7 +++++++\r
+ 1 files changed, 7 insertions(+), 0 deletions(-)\r
+\r
+diff --git a/notmuch-insert.c b/notmuch-insert.c\r
+index f27b9cb..adadd12 100644\r
+--- a/notmuch-insert.c\r
++++ b/notmuch-insert.c\r
+@@ -444,6 +444,7 @@ notmuch_insert_command (notmuch_config_t *config, int argc, char *argv[])\r
+ const char *folder = NULL;\r
+ notmuch_bool_t create_folder = FALSE;\r
+ notmuch_bool_t keep = FALSE;\r
++ notmuch_bool_t no_hooks = FALSE;\r
+ notmuch_bool_t synchronize_flags;\r
+ const char *maildir;\r
+ char *newpath;\r
+@@ -454,6 +455,7 @@ notmuch_insert_command (notmuch_config_t *config, int argc, char *argv[])\r
+ { NOTMUCH_OPT_STRING, &folder, "folder", 0, 0 },\r
+ { NOTMUCH_OPT_BOOLEAN, &create_folder, "create-folder", 0, 0 },\r
+ { NOTMUCH_OPT_BOOLEAN, &keep, "keep", 0, 0 },\r
++ { NOTMUCH_OPT_BOOLEAN, &no_hooks, "no-hooks", 'n', 0 },\r
+ { NOTMUCH_OPT_END, 0, 0, 0, 0 }\r
+ };\r
+ \r
+@@ -541,5 +543,10 @@ notmuch_insert_command (notmuch_config_t *config, int argc, char *argv[])\r
+ \r
+ notmuch_database_destroy (notmuch);\r
+ \r
++ if (! no_hooks && status == NOTMUCH_STATUS_SUCCESS) {\r
++ /* Ignore hook failures. */\r
++ notmuch_run_hook (db_path, "post-insert");\r
++ }\r
++\r
+ return status ? EXIT_FAILURE : EXIT_SUCCESS;\r
+ }\r
+-- \r
+1.7.2.5\r
+\r