unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH] Add 'G' keybinding to folder and search view that triggers external poll
@ 2010-04-09 19:53 Dirk Hohndel
  2010-04-22 21:50 ` Carl Worth
  0 siblings, 1 reply; 7+ messages in thread
From: Dirk Hohndel @ 2010-04-09 19:53 UTC (permalink / raw)
  To: notmuch


The new functions first check if an external poll script has been defined in
the variable 'notmuch-external-refresh-script and if yes, runs that script
before executing the existing refresh function (which is bound to '=')

This can be used to have 'G' mimic the mutt behavior of polling an external
mail server - or if the mail polling is already automatic, it can trigger
the call to notmuch new and any necessary automatic tagging of new email.

Signed-off-by: Dirk Hohndel <hohndel@infradead.org>
---
 emacs/notmuch.el |   24 ++++++++++++++++++++++++
 1 files changed, 24 insertions(+), 0 deletions(-)

diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index 517c53a..a56b949 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -260,6 +260,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-poll-and-search-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)
@@ -747,6 +748,17 @@ same relative position within the new buffer."
     (goto-char (point-min))
     ))
 
+(defun notmuch-poll-and-search-refresh-view ()
+  "Run external script to import mail and refresh the current view.
+
+Checks if the variable 'notmuch-external-refresh-script is defined
+and runs the external program defined it provides. Then calls
+notmuch-search-refresh-view to refresh the current view."
+  (interactive)
+  (if (boundp 'notmuch-external-refresh-script)
+      (call-process notmuch-external-refresh-script nil nil))
+  (notmuch-search-refresh-view))
+
 (defun notmuch-search-toggle-order ()
   "Toggle the current search order.
 
@@ -801,6 +813,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-poll-and-folder)
     (define-key map "s" 'notmuch-search)
     (define-key map [mouse-1] 'notmuch-folder-show-search)
     (define-key map (kbd "RET") 'notmuch-folder-show-search)
@@ -919,6 +932,17 @@ Currently available key bindings:
     (if search
 	(notmuch-search (cdr search) notmuch-search-oldest-first))))
 
+(defun notmuch-poll-and-folder ()
+  "Run external script to import mail and refresh the folder view.
+
+Checks if the variable 'notmuch-external-refresh-script is defined
+and runs the external program defined it provides. Then calls
+notmuch-folder to refresh the current view."
+  (interactive)
+  (if (boundp 'notmuch-external-refresh-script)
+      (call-process notmuch-external-refresh-script nil nil))
+  (notmuch-folder))
+
 ;;;###autoload
 (defun notmuch-folder ()
   "Show the notmuch folder view and update the displayed counts."
-- 
1.6.6.1


-- 
Dirk Hohndel
Intel Open Source Technology Center

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2010-04-23 17:41 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-04-09 19:53 [PATCH] Add 'G' keybinding to folder and search view that triggers external poll Dirk Hohndel
2010-04-22 21:50 ` Carl Worth
2010-04-22 22:17   ` Dirk Hohndel
2010-04-23  8:09     ` Sebastian Spaeth
2010-04-23 14:04       ` Dirk Hohndel
2010-04-23 15:20       ` Carl Worth
2010-04-23 17:14         ` Dirk Hohndel

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).