Re: [PATCH] emacs: support "notmuch new" as a notmuch-poll-script
authorDmitry Kurochkin <dmitry.kurochkin@gmail.com>
Sun, 11 Dec 2011 22:00:45 +0000 (02:00 +0400)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:40:45 +0000 (09:40 -0800)
41/0e6031b699d8f2c4d4c9c7ef58ba773058bc82 [new file with mode: 0644]

diff --git a/41/0e6031b699d8f2c4d4c9c7ef58ba773058bc82 b/41/0e6031b699d8f2c4d4c9c7ef58ba773058bc82
new file mode 100644 (file)
index 0000000..7672c92
--- /dev/null
@@ -0,0 +1,164 @@
+Return-Path: <dmitry.kurochkin@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 757E1429E25\r
+       for <notmuch@notmuchmail.org>; Sun, 11 Dec 2011 14:01:26 -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 kNYTfS1kfsNt for <notmuch@notmuchmail.org>;\r
+       Sun, 11 Dec 2011 14:01:22 -0800 (PST)\r
+Received: from mail-bw0-f53.google.com (mail-bw0-f53.google.com\r
+       [209.85.214.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id 66A44431FB6\r
+       for <notmuch@notmuchmail.org>; Sun, 11 Dec 2011 14:01:22 -0800 (PST)\r
+Received: by bkat8 with SMTP id t8so5100843bka.26\r
+       for <notmuch@notmuchmail.org>; Sun, 11 Dec 2011 14:01:20 -0800 (PST)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;\r
+       h=from:to:subject:in-reply-to:references:user-agent:date:message-id\r
+       :mime-version:content-type;\r
+       bh=rk+3zV3GRXOJ67abum9B2ls8lr+N2BWJ/mIHvvDJ/J8=;\r
+       b=S3rdMxfxVdsKBPHWdHKgPmrwFjir+iYq/dYbrqPU1xy/eCsqMmKWdykgMDq2RUpq97\r
+       n58VjCN30C1BG66Vo5+sZaQOAjw/KNpf0EtfUndkfXKv5NbFoFWJdZZaJxT/CCdiX9PY\r
+       tFhHbjf5RWyw9WIO0IKPUkrpzXLTpfC+E7+1s=\r
+Received: by 10.204.152.3 with SMTP id e3mr8796211bkw.70.1323640880628;\r
+       Sun, 11 Dec 2011 14:01:20 -0800 (PST)\r
+Received: from localhost ([91.144.186.21])\r
+       by mx.google.com with ESMTPS id fa8sm26874060bkc.14.2011.12.11.14.01.19\r
+       (version=TLSv1/SSLv3 cipher=OTHER);\r
+       Sun, 11 Dec 2011 14:01:20 -0800 (PST)\r
+From: Dmitry Kurochkin <dmitry.kurochkin@gmail.com>\r
+To: Jani Nikula <jani@nikula.org>, notmuch@notmuchmail.org\r
+Subject: Re: [PATCH] emacs: support "notmuch new" as a notmuch-poll-script\r
+In-Reply-To: <1323640100-18326-1-git-send-email-jani@nikula.org>\r
+References: <1323640100-18326-1-git-send-email-jani@nikula.org>\r
+User-Agent: Notmuch/0.10.2+94~g948b41d (http://notmuchmail.org) Emacs/23.3.1\r
+       (x86_64-pc-linux-gnu)\r
+Date: Mon, 12 Dec 2011 02:00:45 +0400\r
+Message-ID: <87wra26a5u.fsf@gmail.com>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=us-ascii\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, 11 Dec 2011 22:01:26 -0000\r
+\r
+Hi Jani.\r
+\r
+On Sun, 11 Dec 2011 23:48:20 +0200, Jani Nikula <jani@nikula.org> wrote:\r
+> Let notmuch-poll-script be a function as well as a string. Make default\r
+> value nil instead of an empty string, but allow "" for backwards\r
+> compatibility. Add a notmuch poll function to call "notmuch new" using the\r
+> configured notmuch-command.\r
+> \r
+> This allows taking better advantage of the "notmuch new" hooks from emacs\r
+> without intermediate scripts.\r
+> \r
+\r
+I was just thinking about working on this myself :)\r
+\r
+I think a better solution would be to allow running a command with\r
+arguments.  Creating a elisp function just to run a command with some\r
+parameters feels wrong.  This way we would have to add another function\r
+each time we want to add another argument.\r
+\r
+Function support for notmuch-poll-script seems like a useful feature on\r
+it's own.\r
+\r
+Regards,\r
+  Dmitry\r
+\r
+> Signed-off-by: Jani Nikula <jani@nikula.org>\r
+> ---\r
+>  emacs/notmuch.el |   44 ++++++++++++++++++++++++++++++++------------\r
+>  1 files changed, 32 insertions(+), 12 deletions(-)\r
+> \r
+> diff --git a/emacs/notmuch.el b/emacs/notmuch.el\r
+> index 8936149..6c7e800 100644\r
+> --- a/emacs/notmuch.el\r
+> +++ b/emacs/notmuch.el\r
+> @@ -965,28 +965,48 @@ same relative position within the new buffer."\r
+>      (notmuch-search query oldest-first target-thread target-line continuation)\r
+>      (goto-char (point-min))))\r
+>  \r
+> -(defcustom notmuch-poll-script ""\r
+> -  "An external script to incorporate new mail into the notmuch database.\r
+> +(defcustom notmuch-poll-script nil\r
+> +  "A script or a function to incorporate new mail into the notmuch database.\r
+>  \r
+> -If this variable is non empty, then it should name a script to be\r
+> -invoked by `notmuch-search-poll-and-refresh-view' and\r
+> -`notmuch-hello-poll-and-update' (each have a default keybinding\r
+> -of 'G'). The script could do any of the following depending on\r
+> +This variable can be set to a function or the name of an external\r
+> +script to be invoked by `notmuch-search-poll-and-refresh-view'\r
+> +and `notmuch-hello-poll-and-update' (each have a default\r
+> +keybinding of 'G'). Set to nil to do nothing.\r
+> +\r
+> +The function or script could do any of the following depending on\r
+>  the user's needs:\r
+>  \r
+>  1. Invoke a program to transfer mail to the local mail store\r
+>  2. Invoke \"notmuch new\" to incorporate the new mail\r
+> -3. Invoke one or more \"notmuch tag\" commands to classify the mail"\r
+> -  :type 'string\r
+> +3. Invoke one or more \"notmuch tag\" commands to classify the mail\r
+> +\r
+> +You can also choose to use \"notmuch new\" through the provided\r
+> +`notmuch-poll-script-notmuch-new' function, and have the\r
+> +\"notmuch new\" hooks perform the actions above."\r
+> +  :type '(choice (const :tag "Not set" nil)\r
+> +             (const :tag "Notmuch new" notmuch-poll-script-notmuch-new)\r
+> +             (function :tag "Custom function"\r
+> +                       :value notmuch-poll-script-notmuch-new)\r
+> +             (string :tag "Custom script"))\r
+>    :group 'notmuch)\r
+>  \r
+> +(defun notmuch-poll-script-notmuch-new ()\r
+> +  "Run \"notmuch new\"."\r
+> +  (call-process notmuch-command nil nil nil "new"))\r
+> +\r
+>  (defun notmuch-poll ()\r
+> -  "Run external script to import mail.\r
+> +  "Run external script or call a function to import mail.\r
+>  \r
+> -Invokes `notmuch-poll-script' if it is not set to an empty string."\r
+> +Invokes `notmuch-poll-script', which can be a function or the\r
+> +name of an external script. Does nothing if `notmuch-poll-script'\r
+> +is nil or an empty string."\r
+>    (interactive)\r
+> -  (if (not (string= notmuch-poll-script ""))\r
+> -      (call-process notmuch-poll-script nil nil)))\r
+> +  (cond\r
+> +   ((stringp notmuch-poll-script)\r
+> +    (if (not (string= notmuch-poll-script "")) ;; for backwards compatibility\r
+> +    (call-process notmuch-poll-script nil nil)))\r
+> +   ((functionp notmuch-poll-script)\r
+> +    (funcall notmuch-poll-script))))\r
+>  \r
+>  (defun notmuch-search-poll-and-refresh-view ()\r
+>    "Invoke `notmuch-poll' to import mail, then refresh the current view."\r
+> -- \r
+> 1.7.5.4\r
+> \r
+> _______________________________________________\r
+> notmuch mailing list\r
+> notmuch@notmuchmail.org\r
+> http://notmuchmail.org/mailman/listinfo/notmuch\r