[PATCH] Add 'G' keybinding to folder and search view that triggers external poll
authorDirk Hohndel <hohndel@infradead.org>
Fri, 9 Apr 2010 19:53:26 +0000 (12:53 +1700)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:36:33 +0000 (09:36 -0800)
ab/fcc2c9d11ba94d9edc5ae539bdc71d3d583b9f [new file with mode: 0644]

diff --git a/ab/fcc2c9d11ba94d9edc5ae539bdc71d3d583b9f b/ab/fcc2c9d11ba94d9edc5ae539bdc71d3d583b9f
new file mode 100644 (file)
index 0000000..0f8ab0e
--- /dev/null
@@ -0,0 +1,126 @@
+Return-Path: <BATV+95f6b7a4aaa7c13215e8+2420+infradead.org+hohndel@bombadil.srs.infradead.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 435E34196F0\r
+       for <notmuch@notmuchmail.org>; Fri,  9 Apr 2010 12:53:28 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -4.2\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-4.2 tagged_above=-999 required=5\r
+       tests=[BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3] autolearn=ham\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 7HYv0vt-mbIz for <notmuch@notmuchmail.org>;\r
+       Fri,  9 Apr 2010 12:53:27 -0700 (PDT)\r
+Received: from bombadil.infradead.org (bombadil.infradead.org [18.85.46.34])\r
+       by olra.theworths.org (Postfix) with ESMTP id 73200431FC1\r
+       for <notmuch@notmuchmail.org>; Fri,  9 Apr 2010 12:53:27 -0700 (PDT)\r
+Received: from localhost ([::1] helo=localhost.localdomain)\r
+       by bombadil.infradead.org with esmtp (Exim 4.69 #1 (Red Hat Linux))\r
+       id 1O0KGd-0007Mz-18\r
+       for notmuch@notmuchmail.org; Fri, 09 Apr 2010 19:53:27 +0000\r
+Received: by localhost.localdomain (Postfix, from userid 500)\r
+       id 3532AC00E1; Fri,  9 Apr 2010 12:53:26 -0700 (PDT)\r
+From: Dirk Hohndel <hohndel@infradead.org>\r
+To: <notmuch@notmuchmail.org>\r
+Subject: [PATCH] Add 'G' keybinding to folder and search view that triggers\r
+       external poll\r
+Date: Fri, 09 Apr 2010 12:53:26 -0700\r
+Message-ID: <m339z4csi1.fsf@x200.gr8dns.org>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=us-ascii\r
+X-SRS-Rewrite: SMTP reverse-path rewritten from <hohndel@infradead.org> by\r
+       bombadil.infradead.org See http://www.infradead.org/rpr.html\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: Fri, 09 Apr 2010 19:53:28 -0000\r
+\r
+\r
+The new functions first check if an external poll script has been defined in\r
+the variable 'notmuch-external-refresh-script and if yes, runs that script\r
+before executing the existing refresh function (which is bound to '=')\r
+\r
+This can be used to have 'G' mimic the mutt behavior of polling an external\r
+mail server - or if the mail polling is already automatic, it can trigger\r
+the call to notmuch new and any necessary automatic tagging of new email.\r
+\r
+Signed-off-by: Dirk Hohndel <hohndel@infradead.org>\r
+---\r
+ emacs/notmuch.el |   24 ++++++++++++++++++++++++\r
+ 1 files changed, 24 insertions(+), 0 deletions(-)\r
+\r
+diff --git a/emacs/notmuch.el b/emacs/notmuch.el\r
+index 517c53a..a56b949 100644\r
+--- a/emacs/notmuch.el\r
++++ b/emacs/notmuch.el\r
+@@ -260,6 +260,7 @@ For a mouse binding, return nil."\r
+     (define-key map "s" 'notmuch-search)\r
+     (define-key map "o" 'notmuch-search-toggle-order)\r
+     (define-key map "=" 'notmuch-search-refresh-view)\r
++    (define-key map "G" 'notmuch-poll-and-search-refresh-view)\r
+     (define-key map "t" 'notmuch-search-filter-by-tag)\r
+     (define-key map "f" 'notmuch-search-filter)\r
+     (define-key map [mouse-1] 'notmuch-search-show-thread)\r
+@@ -747,6 +748,17 @@ same relative position within the new buffer."\r
+     (goto-char (point-min))\r
+     ))\r
\r
++(defun notmuch-poll-and-search-refresh-view ()\r
++  "Run external script to import mail and refresh the current view.\r
++\r
++Checks if the variable 'notmuch-external-refresh-script is defined\r
++and runs the external program defined it provides. Then calls\r
++notmuch-search-refresh-view to refresh the current view."\r
++  (interactive)\r
++  (if (boundp 'notmuch-external-refresh-script)\r
++      (call-process notmuch-external-refresh-script nil nil))\r
++  (notmuch-search-refresh-view))\r
++\r
+ (defun notmuch-search-toggle-order ()\r
+   "Toggle the current search order.\r
\r
+@@ -801,6 +813,7 @@ current search results AND that are tagged with the given tag."\r
+     (define-key map ">" 'notmuch-folder-last)\r
+     (define-key map "<" 'notmuch-folder-first)\r
+     (define-key map "=" 'notmuch-folder)\r
++    (define-key map "G" 'notmuch-poll-and-folder)\r
+     (define-key map "s" 'notmuch-search)\r
+     (define-key map [mouse-1] 'notmuch-folder-show-search)\r
+     (define-key map (kbd "RET") 'notmuch-folder-show-search)\r
+@@ -919,6 +932,17 @@ Currently available key bindings:\r
+     (if search\r
+       (notmuch-search (cdr search) notmuch-search-oldest-first))))\r
\r
++(defun notmuch-poll-and-folder ()\r
++  "Run external script to import mail and refresh the folder view.\r
++\r
++Checks if the variable 'notmuch-external-refresh-script is defined\r
++and runs the external program defined it provides. Then calls\r
++notmuch-folder to refresh the current view."\r
++  (interactive)\r
++  (if (boundp 'notmuch-external-refresh-script)\r
++      (call-process notmuch-external-refresh-script nil nil))\r
++  (notmuch-folder))\r
++\r
+ ;;;###autoload\r
+ (defun notmuch-folder ()\r
+   "Show the notmuch folder view and update the displayed counts."\r
+-- \r
+1.6.6.1\r
+\r
+\r
+-- \r
+Dirk Hohndel\r
+Intel Open Source Technology Center\r