--- /dev/null
+Return-Path: <dme@dme.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 68D3F431FD2\r
+ for <notmuch@notmuchmail.org>; Wed, 29 Oct 2014 07:19:04 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.699\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.699 tagged_above=-999 required=5\r
+ tests=[RCVD_IN_DNSWL_LOW=-0.7, UNPARSEABLE_RELAY=0.001]\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 hVREQkypuBHG for <notmuch@notmuchmail.org>;\r
+ Wed, 29 Oct 2014 07:18:59 -0700 (PDT)\r
+Received: from mail-wi0-f171.google.com (mail-wi0-f171.google.com\r
+ [209.85.212.171]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+ (No client certificate requested)\r
+ by olra.theworths.org (Postfix) with ESMTPS id 7F107431FC7\r
+ for <notmuch@notmuchmail.org>; Wed, 29 Oct 2014 07:18:55 -0700 (PDT)\r
+Received: by mail-wi0-f171.google.com with SMTP id q5so1825165wiv.16\r
+ for <notmuch@notmuchmail.org>; Wed, 29 Oct 2014 07:18:54 -0700 (PDT)\r
+X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
+ d=1e100.net; s=20130820;\r
+ h=x-gm-message-state:user-agent:from:to:subject:date:message-id\r
+ :in-reply-to:references;\r
+ bh=3t6o74ayQMiwaxEy7OOv4p8ZHhInL1Ew8Mz4BejQ9bc=;\r
+ b=FcfnKnLb+hs4rfw8tMGaPl7qJ/pjQSD+jWySZk9I4iPq2NsWeisBRLWpxs8RanejkK\r
+ 9Ua8BsR8oaZssNi8AdDyt00rVg0RoX9E/EPTkhGmn2JVQygiY4V7kLhDN/i5eIqaTCQh\r
+ uWW7/SP1DRrfOYsqFZgQB/G+6g9ZiOFjKMAy9FtePmSWz7SOWGTOrUgUjfPdHWf86xBA\r
+ IORhz6VWPP+W6emiMtGIXbiZoj+aElwzO2ABfpr2xBrtjTq7oXFBE3F852UOD55UfvC+\r
+ vRQQwrUqEdfcAotfL3Un1StQdwNXnbwHOa+fzMVQg/C61/TyFCukkJXOGue+WO0jK11B\r
+ O2lg==\r
+X-Gm-Message-State:\r
+ ALoCoQmRD++vCZoAMmkO8B5MTAFf7ECIkHyc8IcgLdqf51dYqLEAdJtyfqh8wnasl3MiPcnPaT48\r
+X-Received: by 10.194.24.197 with SMTP id w5mr13151329wjf.71.1414592333942;\r
+ Wed, 29 Oct 2014 07:18:53 -0700 (PDT)\r
+Received: from disaster-area.hh.sledj.net\r
+ ([2a01:348:1a2:1:ea39:35ff:fe2c:a227])\r
+ by mx.google.com with ESMTPSA id dr5sm5701390wib.4.2014.10.29.07.18.53\r
+ for <notmuch@notmuchmail.org>\r
+ (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\r
+ Wed, 29 Oct 2014 07:18:53 -0700 (PDT)\r
+Received: from localhost (30000@localhost [local]);\r
+ by localhost (OpenSMTPD) with ESMTPA id 3af29b73;\r
+ for <notmuch@notmuchmail.org>; Wed, 29 Oct 2014 14:18:49 +0000 (UTC)\r
+User-Agent: OpenSMTPD enqueuer (Demoostik)\r
+From: David Edmondson <dme@dme.org>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH v2] emacs: Improve the behaviour of the 'q' binding.\r
+Date: Wed, 29 Oct 2014 14:18:49 +0000\r
+Message-Id: <1414592329-15899-2-git-send-email-dme@dme.org>\r
+X-Mailer: git-send-email 2.1.1\r
+In-Reply-To: <1414592329-15899-1-git-send-email-dme@dme.org>\r
+References: <1414592329-15899-1-git-send-email-dme@dme.org>\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: Wed, 29 Oct 2014 14:19:04 -0000\r
+\r
+When a user hits 'q' in a notmuch buffer, kill the buffer only if\r
+there are no other windows currently showing it.\r
+---\r
+ emacs/notmuch-lib.el | 13 +++++++++----\r
+ emacs/notmuch-show.el | 2 +-\r
+ emacs/notmuch-tree.el | 2 +-\r
+ emacs/notmuch.el | 4 ++--\r
+ 4 files changed, 13 insertions(+), 8 deletions(-)\r
+\r
+diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el\r
+index 1e166c6..fd25f7c 100644\r
+--- a/emacs/notmuch-lib.el\r
++++ b/emacs/notmuch-lib.el\r
+@@ -135,7 +135,7 @@ For example, if you wanted to remove an \"inbox\" tag and add an\r
+ (defvar notmuch-common-keymap\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-bury-or-kill-this-buffer)\r
+ (define-key map "s" 'notmuch-search)\r
+ (define-key map "z" 'notmuch-tree)\r
+ (define-key map "m" 'notmuch-mua-new-mail)\r
+@@ -239,10 +239,15 @@ depending on the value of `notmuch-poll-script'."\r
+ (call-process notmuch-poll-script nil nil))\r
+ (call-process notmuch-command nil nil nil "new")))\r
+ \r
+-(defun notmuch-kill-this-buffer ()\r
+- "Kill the current buffer."\r
++(defun notmuch-bury-or-kill-this-buffer ()\r
++ "Undisplay the current buffer.\r
++\r
++Bury the current buffer, unless there is only one window showing\r
++it, in which case it is killed."\r
+ (interactive)\r
+- (kill-buffer (current-buffer)))\r
++ (if (> (length (get-buffer-window-list nil nil t)) 1)\r
++ (bury-buffer)\r
++ (kill-buffer)))\r
+ \r
+ (defun notmuch-documentation-first-line (symbol)\r
+ "Return the first line of the documentation string for SYMBOL."\r
+diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
+index a997482..6e03f1e 100644\r
+--- a/emacs/notmuch-show.el\r
++++ b/emacs/notmuch-show.el\r
+@@ -1956,7 +1956,7 @@ buffer. If PREVIOUS is non-nil, move to the previous item in the\r
+ search results instead."\r
+ (interactive "P")\r
+ (let ((parent-buffer notmuch-show-parent-buffer))\r
+- (notmuch-kill-this-buffer)\r
++ (notmuch-bury-or-kill-this-buffer)\r
+ (when (buffer-live-p parent-buffer)\r
+ (switch-to-buffer parent-buffer)\r
+ (and (if previous\r
+diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el\r
+index e859cc2..8b6cd51 100644\r
+--- a/emacs/notmuch-tree.el\r
++++ b/emacs/notmuch-tree.el\r
+@@ -234,7 +234,7 @@ FUNC."\r
+ ;; Override because we want to close message pane first.\r
+ (define-key map [remap notmuch-help] (notmuch-tree-close-message-pane-and #'notmuch-help))\r
+ ;; Override because we first close message pane and then close tree buffer.\r
+- (define-key map [remap notmuch-kill-this-buffer] 'notmuch-tree-quit)\r
++ (define-key map [remap notmuch-bury-or-kill-this-buffer] 'notmuch-tree-quit)\r
+ ;; Override because we close message pane after the search query is entered.\r
+ (define-key map [remap notmuch-search] 'notmuch-tree-to-search)\r
+ ;; Override because we want to close message pane first.\r
+diff --git a/emacs/notmuch.el b/emacs/notmuch.el\r
+index b44a907..218486a 100644\r
+--- a/emacs/notmuch.el\r
++++ b/emacs/notmuch.el\r
+@@ -153,7 +153,7 @@ there will be called at other points of notmuch execution."\r
+ (defvar notmuch-search-mode-map\r
+ (let ((map (make-sparse-keymap)))\r
+ (set-keymap-parent map notmuch-common-keymap)\r
+- (define-key map "x" 'notmuch-kill-this-buffer)\r
++ (define-key map "x" 'notmuch-bury-or-kill-this-buffer)\r
+ (define-key map (kbd "<DEL>") 'notmuch-search-scroll-down)\r
+ (define-key map "b" 'notmuch-search-scroll-down)\r
+ (define-key map " " 'notmuch-search-scroll-up)\r
+@@ -961,7 +961,7 @@ same relative position within the new buffer."\r
+ (oldest-first notmuch-search-oldest-first)\r
+ (target-thread (notmuch-search-find-thread-id 'bare))\r
+ (query notmuch-search-query-string))\r
+- (notmuch-kill-this-buffer)\r
++ (notmuch-bury-or-kill-this-buffer)\r
+ (notmuch-search query oldest-first target-thread target-line)\r
+ (goto-char (point-min))))\r
+ \r
+-- \r
+2.1.1\r
+\r