]> git.notmuchmail.org Git - notmuch/blobdiff - emacs/notmuch.el
notmuch setup: Fix new configuration-file groups to get comments
[notmuch] / emacs / notmuch.el
index 57b7fcf40e0bf790131a2871316fcebdba17adc8..e947e5d842f8a6114cd0cba6aa4e6846a9827335 100644 (file)
@@ -224,6 +224,7 @@ For a mouse binding, return nil."
     (define-key map "s" 'notmuch-search)
     (define-key map "o" 'notmuch-search-toggle-order)
     (define-key map "=" 'notmuch-search-refresh-view)
+    (define-key map "G" 'notmuch-search-poll-and-refresh-view)
     (define-key map "t" 'notmuch-search-filter-by-tag)
     (define-key map "f" 'notmuch-search-filter)
     (define-key map [mouse-1] 'notmuch-search-show-thread)
@@ -744,6 +745,35 @@ same relative position within the new buffer."
     (goto-char (point-min))
     ))
 
+(defcustom notmuch-poll-script ""
+  "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
+`notmuch-folder-poll-and-refresh-view' (each have a default
+keybinding of 'G'). The 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
+  :group 'notmuch)
+
+(defun notmuch-poll ()
+  "Run external script to import mail.
+
+Invokes `notmuch-poll-script' if it is not set to an empty string."
+  (interactive)
+  (if (not (string= notmuch-poll-script ""))
+      (call-process notmuch-poll-script nil nil)))
+
+(defun notmuch-search-poll-and-refresh-view ()
+  "Invoke `notmuch-poll' to import mail, then refresh the current view."
+  (interactive)
+  (notmuch-poll)
+  (notmuch-search-refresh-view))
+
 (defun notmuch-search-toggle-order ()
   "Toggle the current search order.
 
@@ -802,6 +832,7 @@ current search results AND that are tagged with the given tag."
     (define-key map ">" 'notmuch-folder-last)
     (define-key map "<" 'notmuch-folder-first)
     (define-key map "=" 'notmuch-folder)
+    (define-key map "G" 'notmuch-folder-poll-and-refresh-view)
     (define-key map "s" 'notmuch-search)
     (define-key map [mouse-1] 'notmuch-folder-show-search)
     (define-key map (kbd "RET") 'notmuch-folder-show-search)
@@ -915,6 +946,12 @@ Currently available key bindings:
     (if search
        (notmuch-search (cdr search) notmuch-search-oldest-first))))
 
+(defun notmuch-folder-poll-and-refresh-view ()
+  "Invoke `notmuch-poll' to import mail, then refresh the folder view."
+  (interactive)
+  (notmuch-poll)
+  (notmuch-folder))
+
 ;;;###autoload
 (defun notmuch-folder ()
   "Show the notmuch folder view and update the displayed counts."