--- /dev/null
+Return-Path: <too@guru-group.fi>\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 19745431FAF\r
+ for <notmuch@notmuchmail.org>; Thu, 18 Jul 2013 09:07:17 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]\r
+ autolearn=disabled\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 nZ+yh1fjwFkr for <notmuch@notmuchmail.org>;\r
+ Thu, 18 Jul 2013 09:07:09 -0700 (PDT)\r
+Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34])\r
+ by olra.theworths.org (Postfix) with ESMTP id 82118431FAE\r
+ for <notmuch@notmuchmail.org>; Thu, 18 Jul 2013 09:07:09 -0700 (PDT)\r
+Received: by guru.guru-group.fi (Postfix, from userid 501)\r
+ id 400F91000F4; Thu, 18 Jul 2013 19:06:59 +0300 (EEST)\r
+From: Tomi Ollila <tomi.ollila@iki.fi>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH] emacs: show/search: switch to caller/parent buffer when quit\r
+Date: Thu, 18 Jul 2013 19:06:57 +0300\r
+Message-Id: <1374163617-23740-1-git-send-email-tomi.ollila@iki.fi>\r
+X-Mailer: git-send-email 1.8.0\r
+Cc: tomi.ollila@iki.fi\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: Thu, 18 Jul 2013 16:07:17 -0000\r
+\r
+hello/search: in notmuch-hello-search-continuation switch (eventually)\r
+call notmuch-hello with nil as no-display argument so that notmuch-hello\r
+buffer is always switched to, instead of possibly to some other buffer\r
+user may have visited in between.\r
+\r
+show: added function `notmuch-show-quit` which switches to parent buffer\r
+(of that is live) after killing current buffer. Otherwise control may\r
+go to some other buffer user may have visited in between. This function\r
+is now bound to "q" in notmuch-show-mode-map.\r
+---\r
+ emacs/notmuch-hello.el | 2 +-\r
+ emacs/notmuch-show.el | 10 +++++++++-\r
+ 2 files changed, 10 insertions(+), 2 deletions(-)\r
+\r
+diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el\r
+index 147c08c..00d8785 100644\r
+--- a/emacs/notmuch-hello.el\r
++++ b/emacs/notmuch-hello.el\r
+@@ -472,7 +472,7 @@ Such a list can be computed with `notmuch-hello-query-counts'."\r
+ (defimage notmuch-hello-logo ((:type png :file "notmuch-logo.png")))\r
+ \r
+ (defun notmuch-hello-search-continuation()\r
+- (notmuch-hello-update t))\r
++ (notmuch-hello-update nil))\r
+ \r
+ (defun notmuch-hello-update (&optional no-display)\r
+ "Update the current notmuch view."\r
+diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
+index e5de977..b346002 100644\r
+--- a/emacs/notmuch-show.el\r
++++ b/emacs/notmuch-show.el\r
+@@ -1262,7 +1262,7 @@ reset based on the original query."\r
+ (defvar notmuch-show-mode-map\r
+ (let ((map (make-sparse-keymap)))\r
+ (define-key map "?" 'notmuch-help)\r
+- (define-key map "q" 'notmuch-kill-this-buffer)\r
++ (define-key map "q" 'notmuch-show-quit)\r
+ (define-key map (kbd "<C-tab>") 'widget-backward)\r
+ (define-key map (kbd "M-TAB") 'notmuch-show-previous-button)\r
+ (define-key map (kbd "<backtab>") 'notmuch-show-previous-button)\r
+@@ -1540,6 +1540,14 @@ marked as unread, i.e. the tag changes in\r
+ \r
+ ;; Commands typically bound to keys.\r
+ \r
++(defun notmuch-show-quit ()\r
++ "Exit the show buffer, switching to parent buffer if it is live."\r
++ (interactive)\r
++ (let ((parent-buffer notmuch-show-parent-buffer))\r
++ (notmuch-kill-this-buffer)\r
++ (if (buffer-live-p parent-buffer)\r
++ (switch-to-buffer parent-buffer))))\r
++\r
+ (defun notmuch-show-advance ()\r
+ "Advance through thread.\r
+ \r
+-- \r
+1.8.0\r
+\r