[PATCH] emacs: show/search: switch to caller/parent buffer when quit

Subject: [PATCH] emacs: show/search: switch to caller/parent buffer when quit

Date: Thu, 18 Jul 2013 19:06:57 +0300

To: notmuch@notmuchmail.org

Cc: tomi.ollila@iki.fi

From: Tomi Ollila


hello/search: in notmuch-hello-search-continuation switch (eventually)
call notmuch-hello with nil as no-display argument so that notmuch-hello
buffer is always switched to, instead of possibly to some other buffer
user may have visited in between.

show: added function `notmuch-show-quit` which switches to parent buffer
(of that is live) after killing current buffer. Otherwise control may
go to some other buffer user may have visited in between. This function
is now bound to "q" in notmuch-show-mode-map.
---
 emacs/notmuch-hello.el |  2 +-
 emacs/notmuch-show.el  | 10 +++++++++-
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index 147c08c..00d8785 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -472,7 +472,7 @@ Such a list can be computed with `notmuch-hello-query-counts'."
 (defimage notmuch-hello-logo ((:type png :file "notmuch-logo.png")))
 
 (defun notmuch-hello-search-continuation()
-  (notmuch-hello-update t))
+  (notmuch-hello-update nil))
 
 (defun notmuch-hello-update (&optional no-display)
   "Update the current notmuch view."
diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index e5de977..b346002 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -1262,7 +1262,7 @@ reset based on the original query."
 (defvar notmuch-show-mode-map
       (let ((map (make-sparse-keymap)))
 	(define-key map "?" 'notmuch-help)
-	(define-key map "q" 'notmuch-kill-this-buffer)
+	(define-key map "q" 'notmuch-show-quit)
 	(define-key map (kbd "<C-tab>") 'widget-backward)
 	(define-key map (kbd "M-TAB") 'notmuch-show-previous-button)
 	(define-key map (kbd "<backtab>") 'notmuch-show-previous-button)
@@ -1540,6 +1540,14 @@ marked as unread, i.e. the tag changes in
 
 ;; Commands typically bound to keys.
 
+(defun notmuch-show-quit ()
+  "Exit the show buffer, switching to parent buffer if it is live."
+  (interactive)
+  (let ((parent-buffer notmuch-show-parent-buffer))
+    (notmuch-kill-this-buffer)
+    (if (buffer-live-p parent-buffer)
+	(switch-to-buffer parent-buffer))))
+
 (defun notmuch-show-advance ()
   "Advance through thread.
 
-- 
1.8.0


Thread: