[PATCH] emacs: support "notmuch new" as a notmuch-poll-script
authorJani Nikula <jani@nikula.org>
Sun, 11 Dec 2011 21:48:20 +0000 (23:48 +0200)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:40:45 +0000 (09:40 -0800)
bb/c63db875d3ed39f5343663acc56e1d79bcd8fd [new file with mode: 0644]

diff --git a/bb/c63db875d3ed39f5343663acc56e1d79bcd8fd b/bb/c63db875d3ed39f5343663acc56e1d79bcd8fd
new file mode 100644 (file)
index 0000000..1c133f3
--- /dev/null
@@ -0,0 +1,130 @@
+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 0C9AF429E25\r
+       for <notmuch@notmuchmail.org>; Sun, 11 Dec 2011 13:48:29 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\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 bsS+-TrbXBI1 for <notmuch@notmuchmail.org>;\r
+       Sun, 11 Dec 2011 13:48:28 -0800 (PST)\r
+Received: from mail-ey0-f181.google.com (mail-ey0-f181.google.com\r
+       [209.85.215.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id 29EB7431FB6\r
+       for <notmuch@notmuchmail.org>; Sun, 11 Dec 2011 13:48:28 -0800 (PST)\r
+Received: by eaan11 with SMTP id n11so681245eaa.26\r
+       for <notmuch@notmuchmail.org>; Sun, 11 Dec 2011 13:48:25 -0800 (PST)\r
+Received: by 10.213.108.142 with SMTP id f14mr1162030ebp.80.1323640105319;\r
+       Sun, 11 Dec 2011 13:48:25 -0800 (PST)\r
+Received: from localhost (dsl-hkibrasgw4-fe5cdc00-23.dhcp.inet.fi.\r
+       [80.220.92.23])\r
+       by mx.google.com with ESMTPS id 17sm66496406eej.3.2011.12.11.13.48.22\r
+       (version=SSLv3 cipher=OTHER); Sun, 11 Dec 2011 13:48:23 -0800 (PST)\r
+From: Jani Nikula <jani@nikula.org>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH] emacs: support "notmuch new" as a notmuch-poll-script\r
+Date: Sun, 11 Dec 2011 23:48:20 +0200\r
+Message-Id: <1323640100-18326-1-git-send-email-jani@nikula.org>\r
+X-Mailer: git-send-email 1.7.5.4\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 21:48:29 -0000\r
+\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
+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