]> git.notmuchmail.org Git - notmuch/commitdiff
emacs: Add unified refresh-this-buffer function
authorAustin Clements <amdragon@MIT.EDU>
Tue, 3 Sep 2013 21:45:22 +0000 (17:45 -0400)
committerDavid Bremner <bremner@debian.org>
Tue, 10 Sep 2013 11:07:06 +0000 (08:07 -0300)
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
emacs/notmuch-lib.el
emacs/notmuch-show.el
emacs/notmuch.el

index 94cc4b53cf50251f2ebdfcfdb15f843cf57a3fd1..6a7b884c5c433a056cfecaaf96b322a365ae2217 100644 (file)
@@ -481,15 +481,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))
-
 (defun notmuch-hello-window-configuration-change ()
   "Hook function to update the hello buffer when it is switched to."
   (let ((hello-buf (get-buffer "*notmuch-hello*"))
@@ -528,8 +521,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 "<C-tab>") 'widget-backward)
     (define-key map "m" 'notmuch-mua-new-mail)
     (define-key map "s" 'notmuch-search)
@@ -545,6 +538,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")
index 9754e163983d5d17d6548bcd9f07a0caeadec119..782badb0d5857155e5dd19e2aae0b8b7989d8d26 100644 (file)
@@ -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:
index 61a8c4cbd1e335c862cf8f5190044b54d35748b6..cb586e9246f96a4e4cb48669eabae04e7f059317 100644 (file)
@@ -1258,7 +1258,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)
@@ -1317,6 +1317,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")
index 82cece80868b436e28237271bdc866df0bfc38ce..80446be6b8b2a12b8de7be9396a322376b1c3332 100644 (file)
@@ -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.