--- /dev/null
+Return-Path: <novalazy@gmail.com>\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 B2FE1431FD6\r
+ for <notmuch@notmuchmail.org>; Sat, 19 Jan 2013 16:50:41 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.799\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5\r
+ tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
+ FREEMAIL_FROM=0.001, 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 XObZwNJscWfN for <notmuch@notmuchmail.org>;\r
+ Sat, 19 Jan 2013 16:50:40 -0800 (PST)\r
+Received: from mail-da0-f47.google.com (mail-da0-f47.google.com\r
+ [209.85.210.47]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+ (No client certificate requested)\r
+ by olra.theworths.org (Postfix) with ESMTPS id 2E560431FB6\r
+ for <notmuch@notmuchmail.org>; Sat, 19 Jan 2013 16:50:40 -0800 (PST)\r
+Received: by mail-da0-f47.google.com with SMTP id s35so2162804dak.34\r
+ for <notmuch@notmuchmail.org>; Sat, 19 Jan 2013 16:50:38 -0800 (PST)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
+ h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to\r
+ :references:mime-version:content-type:content-transfer-encoding;\r
+ bh=rH20fsxEfTcU/1UXvdaNpQTYJGGtR9D/WwNSv9grl4s=;\r
+ b=LZVtn0Vbbbv8o1B+LCFZJmfWrtKG0UdciQ3g2ptmksTTqBneD8X6uyohTQ6rxXzkWq\r
+ NBGcomp15Ldnv6w3TmbXSgoO4eP+MFEUpnif6ez8DJomKqh3k/odQpVc42gscmcXLBzG\r
+ DJivG+/7kHcMViTIMKHfw+JOIQa0GQt2H9KHgyVZBz2dp/TlAJTs96FlU4GskREWC7bt\r
+ vdd5xHo5VFbBwNFBCg4OO/fFZl47sw9t8fBKHCUbV2MD/Mb2DThXtexolX2QGy++jc+K\r
+ +kauFBk1QDXCxhZe7eEUis4IDZ3SqRmNrwkEP8L9RAOh+B0AOHhojGoNiaWBEO6aO5ld\r
+ HEOg==\r
+X-Received: by 10.66.84.232 with SMTP id c8mr36576008paz.8.1358643038139;\r
+ Sat, 19 Jan 2013 16:50:38 -0800 (PST)\r
+Received: from localhost (215.42.233.220.static.exetel.com.au.\r
+ [220.233.42.215])\r
+ by mx.google.com with ESMTPS id a9sm6265419pav.24.2013.01.19.16.50.35\r
+ (version=TLSv1.2 cipher=RC4-SHA bits=128/128);\r
+ Sat, 19 Jan 2013 16:50:37 -0800 (PST)\r
+From: Peter Wang <novalazy@gmail.com>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH v3 01/20] cli: add stub for insert command\r
+Date: Sun, 20 Jan 2013 11:49:45 +1100\r
+Message-Id: <1358643004-14522-2-git-send-email-novalazy@gmail.com>\r
+X-Mailer: git-send-email 1.7.12.1\r
+In-Reply-To: <1358643004-14522-1-git-send-email-novalazy@gmail.com>\r
+References: <1358643004-14522-1-git-send-email-novalazy@gmail.com>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=UTF-8\r
+Content-Transfer-Encoding: 8bit\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: Sun, 20 Jan 2013 00:50:41 -0000\r
+\r
+The notmuch insert command should read a message from standard input\r
+and deliver it to a Maildir folder, and then incorporate the message\r
+into the notmuch database. Essentially it moves the functionality of\r
+notmuch-deliver into notmuch.\r
+\r
+Though it could be used as an alternative to notmuch new, the reason\r
+I want this is to allow my notmuch frontend to add postponed or sent\r
+messages to the mail store and notmuch database, without resorting to\r
+another tool (e.g. notmuch-deliver) nor directly modifying the maildir.\r
+---\r
+ Makefile.local | 1 +\r
+ notmuch-client.h | 3 +++\r
+ notmuch-insert.c | 43 +++++++++++++++++++++++++++++++++++++++++++\r
+ notmuch.c | 3 +++\r
+ 4 files changed, 50 insertions(+)\r
+ create mode 100644 notmuch-insert.c\r
+\r
+diff --git a/Makefile.local b/Makefile.local\r
+index c274f07..bb2381d 100644\r
+--- a/Makefile.local\r
++++ b/Makefile.local\r
+@@ -261,6 +261,7 @@ notmuch_client_srcs = \\r
+ notmuch-config.c \\r
+ notmuch-count.c \\r
+ notmuch-dump.c \\r
++ notmuch-insert.c \\r
+ notmuch-new.c \\r
+ notmuch-reply.c \\r
+ notmuch-restore.c \\r
+diff --git a/notmuch-client.h b/notmuch-client.h\r
+index 5f28836..af7d094 100644\r
+--- a/notmuch-client.h\r
++++ b/notmuch-client.h\r
+@@ -175,6 +175,9 @@ int\r
+ notmuch_dump_command (void *ctx, int argc, char *argv[]);\r
+ \r
+ int\r
++notmuch_insert_command (void *ctx, int argc, char *argv[]);\r
++\r
++int\r
+ notmuch_new_command (void *ctx, int argc, char *argv[]);\r
+ \r
+ int\r
+diff --git a/notmuch-insert.c b/notmuch-insert.c\r
+new file mode 100644\r
+index 0000000..c1d359c\r
+--- /dev/null\r
++++ b/notmuch-insert.c\r
+@@ -0,0 +1,43 @@\r
++/* notmuch - Not much of an email program, (just index and search)\r
++ *\r
++ * Copyright © 2013 Peter Wang\r
++ *\r
++ * This program is free software: you can redistribute it and/or modify\r
++ * it under the terms of the GNU General Public License as published by\r
++ * the Free Software Foundation, either version 3 of the License, or\r
++ * (at your option) any later version.\r
++ *\r
++ * This program is distributed in the hope that it will be useful,\r
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
++ * GNU General Public License for more details.\r
++ *\r
++ * You should have received a copy of the GNU General Public License\r
++ * along with this program. If not, see http://www.gnu.org/licenses/ .\r
++ *\r
++ * Author: Peter Wang <novalazy@gmail.com>\r
++ */\r
++\r
++#include "notmuch-client.h"\r
++\r
++int\r
++notmuch_insert_command (void *ctx, int argc, char *argv[])\r
++{\r
++ notmuch_config_t *config;\r
++ notmuch_database_t *notmuch;\r
++ const char *db_path;\r
++\r
++ config = notmuch_config_open (ctx, NULL, NULL);\r
++ if (config == NULL)\r
++ return 1;\r
++\r
++ db_path = notmuch_config_get_database_path (config);\r
++\r
++ if (notmuch_database_open (notmuch_config_get_database_path (config),\r
++ NOTMUCH_DATABASE_MODE_READ_WRITE, ¬much))\r
++ return 1;\r
++\r
++ notmuch_database_destroy (notmuch);\r
++\r
++ return 1;\r
++}\r
+diff --git a/notmuch.c b/notmuch.c\r
+index 4fc0973..1c3b893 100644\r
+--- a/notmuch.c\r
++++ b/notmuch.c\r
+@@ -53,6 +53,9 @@ static command_t commands[] = {\r
+ { "new", notmuch_new_command,\r
+ "[options...]",\r
+ "Find and import new messages to the notmuch database." },\r
++ { "insert", notmuch_insert_command,\r
++ "[options...] [--] [+<tag>|-<tag> ...] < message",\r
++ "Add a new message into the maildir and notmuch database." },\r
+ { "search", notmuch_search_command,\r
+ "[options...] <search-terms> [...]",\r
+ "Search for messages matching the given search terms." },\r
+-- \r
+1.7.12.1\r
+\r