From 5109821af557477006dca63782e788d88f09c672 Mon Sep 17 00:00:00 2001 From: Austin Clements Date: Fri, 30 Aug 2013 12:25:54 +2000 Subject: [PATCH] [PATCH 6/9] emacs: Add unified refresh-this-buffer function --- 2d/82f066fe54a83579a38f6aae09ce213b023e4c | 229 ++++++++++++++++++++++ 1 file changed, 229 insertions(+) create mode 100644 2d/82f066fe54a83579a38f6aae09ce213b023e4c diff --git a/2d/82f066fe54a83579a38f6aae09ce213b023e4c b/2d/82f066fe54a83579a38f6aae09ce213b023e4c new file mode 100644 index 000000000..412712dd7 --- /dev/null +++ b/2d/82f066fe54a83579a38f6aae09ce213b023e4c @@ -0,0 +1,229 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id CBEED431FDF + for ; Thu, 29 Aug 2013 09:26:45 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: -0.7 +X-Spam-Level: +X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 + tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled +Received: from olra.theworths.org ([127.0.0.1]) + by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id T9kmMr5OdUUR for ; + Thu, 29 Aug 2013 09:26:41 -0700 (PDT) +Received: from dmz-mailsec-scanner-2.mit.edu (dmz-mailsec-scanner-2.mit.edu + [18.9.25.13]) + by olra.theworths.org (Postfix) with ESMTP id A6AE9431E62 + for ; Thu, 29 Aug 2013 09:26:15 -0700 (PDT) +X-AuditID: 1209190d-b7f078e000000937-04-521f7627e10c +Received: from mailhub-auth-4.mit.edu ( [18.7.62.39]) + by dmz-mailsec-scanner-2.mit.edu (Symantec Messaging Gateway) with SMTP + id E2.0B.02359.7267F125; Thu, 29 Aug 2013 12:26:15 -0400 (EDT) +Received: from outgoing.mit.edu (outgoing-auth-1.mit.edu [18.9.28.11]) + by mailhub-auth-4.mit.edu (8.13.8/8.9.2) with ESMTP id r7TGQ3nZ018774; + Thu, 29 Aug 2013 12:26:04 -0400 +Received: from drake.dyndns.org + (216-15-114-40.c3-0.arl-ubr1.sbo-arl.ma.cable.rcn.com + [216.15.114.40]) (authenticated bits=0) + (User authenticated as amdragon@ATHENA.MIT.EDU) + by outgoing.mit.edu (8.13.8/8.12.4) with ESMTP id r7TGQ1Te014999 + (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); + Thu, 29 Aug 2013 12:26:02 -0400 +Received: from amthrax by drake.dyndns.org with local (Exim 4.77) + (envelope-from ) + id 1VF52n-0007Ww-3S; Thu, 29 Aug 2013 12:26:01 -0400 +From: Austin Clements +To: notmuch@notmuchmail.org +Subject: [PATCH 6/9] emacs: Add unified refresh-this-buffer function +Date: Thu, 29 Aug 2013 12:25:54 -0400 +Message-Id: <1377793557-28878-7-git-send-email-amdragon@mit.edu> +X-Mailer: git-send-email 1.7.10.4 +In-Reply-To: <1377793557-28878-1-git-send-email-amdragon@mit.edu> +References: <1377793557-28878-1-git-send-email-amdragon@mit.edu> +X-Brightmail-Tracker: + H4sIAAAAAAAAA+NgFlrPIsWRmVeSWpSXmKPExsUixG6nrqteJh9k8Pgfs8X1mzOZHRg9nq26 + xRzAGMVlk5Kak1mWWqRvl8CVsXJWA1vBBuOK/1ttGhjna3cxcnJICJhInP48gRXCFpO4cG89 + G4gtJLCPUeLMbcYuRi4geyOjxKt/d9khEneYJBauMYRIzGWUmNo/FyzBJqAhsW3/ckYQW0RA + WmLn3dlAUzk4mAXUJP50qYCEhQVcJBYe3AVWwiKgKjFvzk82kBJeAQeJ9X9qIG5QlOh+NgHs + Bk4BR4n+u29ZINY6SPy5+JR9AiP/AkaGVYyyKblVurmJmTnFqcm6xcmJeXmpRbpGermZJXqp + KaWbGEHhwinJu4Px3UGlQ4wCHIxKPLwPg+WDhFgTy4orcw8xSnIwKYnyBpYAhfiS8lMqMxKL + M+KLSnNSiw8xSnAwK4nwvuUEyvGmJFZWpRblw6SkOViUxHmfPj0bKCSQnliSmp2aWpBaBJOV + 4eBQkuCNLwVqFCxKTU+tSMvMKUFIM3FwggznARpuBVLDW1yQmFucmQ6RP8WoKCXOawaSEABJ + ZJTmwfXC4vkVozjQK8K8YSBVPMBUANf9CmgwE9DgCflyIINLEhFSUg2My99/cY80ydhsvSh7 + Vu3dq6qqh7QOfO1vXLP4R+yaV8syVbaq7Jr+Z/WHLQ3nBTnOBm3cZLPxx699GbVMrUdaH67Y + P8lQwrpp8bbl76Vv2e6blWo6selcksDMJT0XWA9vjnSLXHFqf8XWqZ3yAdtKJbifzfKNeOLo + z5K62f3yq49Pzx9T/X3j6SklluKMREMt5qLiRAC4zM/qwgIAAA== +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.13 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Thu, 29 Aug 2013 16:26:46 -0000 + +This unifies the various refresh and poll-and-refresh functions we +have for different modes. Now all modes bind "=" and "G" (except +show, which doesn't bind "G" for some reason) to +`notmuch-refresh-this-buffer' and +`notmuch-poll-and-refresh-this-buffer', respectively. +--- + emacs/notmuch-hello.el | 12 +++--------- + emacs/notmuch-lib.el | 20 +++++++++++++++++++- + emacs/notmuch-show.el | 3 ++- + emacs/notmuch.el | 12 +++--------- + 4 files changed, 27 insertions(+), 20 deletions(-) + +diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el +index c9d484c..147e2dd 100644 +--- a/emacs/notmuch-hello.el ++++ b/emacs/notmuch-hello.el +@@ -476,15 +476,8 @@ Such a list can be computed with `notmuch-hello-query-counts'." + (defun notmuch-hello-update (&optional no-display) + "Update the current notmuch view." + ;; Lazy - rebuild everything. +- (interactive) + (notmuch-hello no-display)) + +-(defun notmuch-hello-poll-and-update () +- "Invoke `notmuch-poll' to import mail, then refresh the current view." +- (interactive) +- (notmuch-poll) +- (notmuch-hello-update)) +- + (defvar notmuch-hello-inhibit-auto-refresh nil + "Don't refresh notmuch-hello on window configuration changes.") + +@@ -523,8 +516,8 @@ Such a list can be computed with `notmuch-hello-query-counts'." + (message "notmuch version %s" (notmuch-version)))) + (define-key map "?" 'notmuch-help) + (define-key map "q" 'notmuch-kill-this-buffer) +- (define-key map "=" 'notmuch-hello-update) +- (define-key map "G" 'notmuch-hello-poll-and-update) ++ (define-key map "=" 'notmuch-refresh-this-buffer) ++ (define-key map "G" 'notmuch-poll-and-refresh-this-buffer) + (define-key map (kbd "") 'widget-backward) + (define-key map "m" 'notmuch-mua-new-mail) + (define-key map "s" 'notmuch-search) +@@ -540,6 +533,7 @@ Complete list of currently available key bindings: + \\{notmuch-hello-mode-map}" + (interactive) + (kill-all-local-variables) ++ (setq notmuch-buffer-refresh-function #'notmuch-hello-update) + (use-local-map notmuch-hello-mode-map) + (setq major-mode 'notmuch-hello-mode + mode-name "notmuch-hello") +diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el +index 9754e16..782badb 100644 +--- a/emacs/notmuch-lib.el ++++ b/emacs/notmuch-lib.el +@@ -204,6 +204,25 @@ depending on the value of `notmuch-poll-script'." + (interactive) + (kill-buffer (current-buffer))) + ++(defvar notmuch-buffer-refresh-function nil ++ "Function to call to refresh the current buffer.") ++(make-variable-buffer-local 'notmuch-buffer-refresh-function) ++ ++(defun notmuch-refresh-this-buffer () ++ "Refresh the current buffer." ++ (interactive) ++ (when notmuch-buffer-refresh-function ++ (if (commandp notmuch-buffer-refresh-function) ++ ;; Pass prefix argument, etc. ++ (call-interactively notmuch-buffer-refresh-function) ++ (funcall notmuch-buffer-refresh-function)))) ++ ++(defun notmuch-poll-and-refresh-this-buffer () ++ "Invoke `notmuch-poll' to import mail, then refresh the current buffer." ++ (interactive) ++ (notmuch-poll) ++ (notmuch-refresh-this-buffer)) ++ + (defun notmuch-prettify-subject (subject) + ;; This function is used by `notmuch-search-process-filter' which + ;; requires that we not disrupt its' matching state. +@@ -596,7 +615,6 @@ status." + (defvar notmuch-show-process-crypto nil) + (make-variable-buffer-local 'notmuch-show-process-crypto) + +- + (provide 'notmuch-lib) + + ;; Local Variables: +diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el +index 82b70ba..380df66 100644 +--- a/emacs/notmuch-show.el ++++ b/emacs/notmuch-show.el +@@ -1279,7 +1279,7 @@ reset based on the original query." + (define-key map "w" 'notmuch-show-save-attachments) + (define-key map "V" 'notmuch-show-view-raw-message) + (define-key map "c" 'notmuch-show-stash-map) +- (define-key map "=" 'notmuch-show-refresh-view) ++ (define-key map "=" 'notmuch-refresh-this-buffer) + (define-key map "h" 'notmuch-show-toggle-visibility-headers) + (define-key map "*" 'notmuch-show-tag-all) + (define-key map "-" 'notmuch-show-remove-tag) +@@ -1338,6 +1338,7 @@ All currently available key bindings: + \\{notmuch-show-mode-map}" + (interactive) + (kill-all-local-variables) ++ (setq notmuch-buffer-refresh-function #'notmuch-show-refresh-view) + (use-local-map notmuch-show-mode-map) + (setq major-mode 'notmuch-show-mode + mode-name "notmuch-show") +diff --git a/emacs/notmuch.el b/emacs/notmuch.el +index 82cece8..80446be 100644 +--- a/emacs/notmuch.el ++++ b/emacs/notmuch.el +@@ -228,8 +228,8 @@ For a mouse binding, return nil." + (define-key map "s" 'notmuch-search) + (define-key map "o" 'notmuch-search-toggle-order) + (define-key map "c" 'notmuch-search-stash-map) +- (define-key map "=" 'notmuch-search-refresh-view) +- (define-key map "G" 'notmuch-search-poll-and-refresh-view) ++ (define-key map "=" 'notmuch-refresh-this-buffer) ++ (define-key map "G" 'notmuch-poll-and-refresh-this-buffer) + (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) +@@ -403,6 +403,7 @@ Complete list of currently available key bindings: + (make-local-variable 'notmuch-search-oldest-first) + (make-local-variable 'notmuch-search-target-thread) + (make-local-variable 'notmuch-search-target-line) ++ (setq notmuch-buffer-refresh-function #'notmuch-search-refresh-view) + (set (make-local-variable 'scroll-preserve-screen-position) t) + (add-to-invisibility-spec (cons 'ellipsis t)) + (use-local-map notmuch-search-mode-map) +@@ -950,7 +951,6 @@ query string as the current search. If the current thread is in + the new search results, then point will be placed on the same + thread. Otherwise, point will be moved to attempt to be in the + same relative position within the new buffer." +- (interactive) + (let ((target-line (line-number-at-pos)) + (oldest-first notmuch-search-oldest-first) + (target-thread (notmuch-search-find-thread-id 'bare)) +@@ -959,12 +959,6 @@ same relative position within the new buffer." + (notmuch-search query oldest-first target-thread target-line) + (goto-char (point-min)))) + +-(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. + +-- +1.7.10.4 + -- 2.26.2