[PATCH v2] emacs: support "notmuch new" as a notmuch-poll-script
Jani Nikula
jani at nikula.org
Mon Dec 12 11:57:28 PST 2011
Support nil value for notmuch-poll-script to run "notmuch new" instead of
an external script, and make this the new default. "notmuch new" is run
using the configured notmuch-command.
This allows taking better advantage of the "notmuch new" hooks from emacs
without intermediate scripts.
Signed-off-by: Jani Nikula <jani at nikula.org>
---
emacs/notmuch.el | 34 ++++++++++++++++++++++++----------
1 files changed, 24 insertions(+), 10 deletions(-)
diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index 8936149..5a8ab9d 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -965,28 +965,42 @@ same relative position within the new buffer."
(notmuch-search query oldest-first target-thread target-line continuation)
(goto-char (point-min))))
-(defcustom notmuch-poll-script ""
+(defcustom notmuch-poll-script nil
"An external script to incorporate new mail into the notmuch database.
-If this variable is non empty, then it should name a script to be
-invoked by `notmuch-search-poll-and-refresh-view' and
+This variable controls the action invoked by
+`notmuch-search-poll-and-refresh-view' and
`notmuch-hello-poll-and-update' (each have a default keybinding
-of 'G'). The script could do any of the following depending on
+of 'G') to incorporate new mail into the notmuch database.
+
+If this variable is non empty, then it should name an external
+script to be run. If set to an empty string, no action is
+invoked. Finally, if set to nil (the default), \"notmuch new\" is
+run using the command specified by `notmuch-command'.
+
+The external script could do any of the following depending on
the user's needs:
1. Invoke a program to transfer mail to the local mail store
2. Invoke \"notmuch new\" to incorporate the new mail
-3. Invoke one or more \"notmuch tag\" commands to classify the mail"
- :type 'string
+3. Invoke one or more \"notmuch tag\" commands to classify the mail
+
+Note that the same can be achieved through \"notmuch new\" hooks."
+ :type '(choice (const :tag "Notmuch new" nil)
+ (const :tag "Disabled" "")
+ (string :tag "Custom script"))
:group 'notmuch)
(defun notmuch-poll ()
- "Run external script to import mail.
+ "Run \"notmuch new\" or an external script to import mail.
-Invokes `notmuch-poll-script' if it is not set to an empty string."
+Invokes `notmuch-poll-script', \"notmuch new\", or does nothing
+depending on the value of `notmuch-poll-script'."
(interactive)
- (if (not (string= notmuch-poll-script ""))
- (call-process notmuch-poll-script nil nil)))
+ (if (stringp notmuch-poll-script)
+ (if (not (string= notmuch-poll-script ""))
+ (call-process notmuch-poll-script nil nil))
+ (call-process notmuch-command nil nil nil "new")))
(defun notmuch-search-poll-and-refresh-view ()
"Invoke `notmuch-poll' to import mail, then refresh the current view."
--
1.7.5.4
More information about the notmuch
mailing list