[PATCH v2] emacs: Improve the behaviour of the 'q' binding.
[notmuch-archives.git] / a7 / a3ed5cd6a76dfcc12ffa54f18f3b18a3a0a22e
1 Return-Path: <dme@dme.org>\r
2 X-Original-To: notmuch@notmuchmail.org\r
3 Delivered-To: notmuch@notmuchmail.org\r
4 Received: from localhost (localhost [127.0.0.1])\r
5         by olra.theworths.org (Postfix) with ESMTP id 68D3F431FD2\r
6         for <notmuch@notmuchmail.org>; Wed, 29 Oct 2014 07:19:04 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -0.699\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.699 tagged_above=-999 required=5\r
12         tests=[RCVD_IN_DNSWL_LOW=-0.7, UNPARSEABLE_RELAY=0.001]\r
13         autolearn=disabled\r
14 Received: from olra.theworths.org ([127.0.0.1])\r
15         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
16         with ESMTP id hVREQkypuBHG for <notmuch@notmuchmail.org>;\r
17         Wed, 29 Oct 2014 07:18:59 -0700 (PDT)\r
18 Received: from mail-wi0-f171.google.com (mail-wi0-f171.google.com\r
19         [209.85.212.171]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
20         (No client certificate requested)\r
21         by olra.theworths.org (Postfix) with ESMTPS id 7F107431FC7\r
22         for <notmuch@notmuchmail.org>; Wed, 29 Oct 2014 07:18:55 -0700 (PDT)\r
23 Received: by mail-wi0-f171.google.com with SMTP id q5so1825165wiv.16\r
24         for <notmuch@notmuchmail.org>; Wed, 29 Oct 2014 07:18:54 -0700 (PDT)\r
25 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
26         d=1e100.net; s=20130820;\r
27         h=x-gm-message-state:user-agent:from:to:subject:date:message-id\r
28         :in-reply-to:references;\r
29         bh=3t6o74ayQMiwaxEy7OOv4p8ZHhInL1Ew8Mz4BejQ9bc=;\r
30         b=FcfnKnLb+hs4rfw8tMGaPl7qJ/pjQSD+jWySZk9I4iPq2NsWeisBRLWpxs8RanejkK\r
31         9Ua8BsR8oaZssNi8AdDyt00rVg0RoX9E/EPTkhGmn2JVQygiY4V7kLhDN/i5eIqaTCQh\r
32         uWW7/SP1DRrfOYsqFZgQB/G+6g9ZiOFjKMAy9FtePmSWz7SOWGTOrUgUjfPdHWf86xBA\r
33         IORhz6VWPP+W6emiMtGIXbiZoj+aElwzO2ABfpr2xBrtjTq7oXFBE3F852UOD55UfvC+\r
34         vRQQwrUqEdfcAotfL3Un1StQdwNXnbwHOa+fzMVQg/C61/TyFCukkJXOGue+WO0jK11B\r
35         O2lg==\r
36 X-Gm-Message-State:\r
37  ALoCoQmRD++vCZoAMmkO8B5MTAFf7ECIkHyc8IcgLdqf51dYqLEAdJtyfqh8wnasl3MiPcnPaT48\r
38 X-Received: by 10.194.24.197 with SMTP id w5mr13151329wjf.71.1414592333942;\r
39         Wed, 29 Oct 2014 07:18:53 -0700 (PDT)\r
40 Received: from disaster-area.hh.sledj.net\r
41         ([2a01:348:1a2:1:ea39:35ff:fe2c:a227])\r
42         by mx.google.com with ESMTPSA id dr5sm5701390wib.4.2014.10.29.07.18.53\r
43         for <notmuch@notmuchmail.org>\r
44         (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\r
45         Wed, 29 Oct 2014 07:18:53 -0700 (PDT)\r
46 Received: from localhost (30000@localhost [local]);\r
47         by localhost (OpenSMTPD) with ESMTPA id 3af29b73;\r
48         for <notmuch@notmuchmail.org>; Wed, 29 Oct 2014 14:18:49 +0000 (UTC)\r
49 User-Agent: OpenSMTPD enqueuer (Demoostik)\r
50 From: David Edmondson <dme@dme.org>\r
51 To: notmuch@notmuchmail.org\r
52 Subject: [PATCH v2] emacs: Improve the behaviour of the 'q' binding.\r
53 Date: Wed, 29 Oct 2014 14:18:49 +0000\r
54 Message-Id: <1414592329-15899-2-git-send-email-dme@dme.org>\r
55 X-Mailer: git-send-email 2.1.1\r
56 In-Reply-To: <1414592329-15899-1-git-send-email-dme@dme.org>\r
57 References: <1414592329-15899-1-git-send-email-dme@dme.org>\r
58 X-BeenThere: notmuch@notmuchmail.org\r
59 X-Mailman-Version: 2.1.13\r
60 Precedence: list\r
61 List-Id: "Use and development of the notmuch mail system."\r
62         <notmuch.notmuchmail.org>\r
63 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
64         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
65 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
66 List-Post: <mailto:notmuch@notmuchmail.org>\r
67 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
68 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
69         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
70 X-List-Received-Date: Wed, 29 Oct 2014 14:19:04 -0000\r
71 \r
72 When a user hits 'q' in a notmuch buffer, kill the buffer only if\r
73 there are no other windows currently showing it.\r
74 ---\r
75  emacs/notmuch-lib.el  | 13 +++++++++----\r
76  emacs/notmuch-show.el |  2 +-\r
77  emacs/notmuch-tree.el |  2 +-\r
78  emacs/notmuch.el      |  4 ++--\r
79  4 files changed, 13 insertions(+), 8 deletions(-)\r
80 \r
81 diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el\r
82 index 1e166c6..fd25f7c 100644\r
83 --- a/emacs/notmuch-lib.el\r
84 +++ b/emacs/notmuch-lib.el\r
85 @@ -135,7 +135,7 @@ For example, if you wanted to remove an \"inbox\" tag and add an\r
86  (defvar notmuch-common-keymap\r
87    (let ((map (make-sparse-keymap)))\r
88      (define-key map "?" 'notmuch-help)\r
89 -    (define-key map "q" 'notmuch-kill-this-buffer)\r
90 +    (define-key map "q" 'notmuch-bury-or-kill-this-buffer)\r
91      (define-key map "s" 'notmuch-search)\r
92      (define-key map "z" 'notmuch-tree)\r
93      (define-key map "m" 'notmuch-mua-new-mail)\r
94 @@ -239,10 +239,15 @@ depending on the value of `notmuch-poll-script'."\r
95         (call-process notmuch-poll-script nil nil))\r
96      (call-process notmuch-command nil nil nil "new")))\r
97  \r
98 -(defun notmuch-kill-this-buffer ()\r
99 -  "Kill the current buffer."\r
100 +(defun notmuch-bury-or-kill-this-buffer ()\r
101 +  "Undisplay the current buffer.\r
102 +\r
103 +Bury the current buffer, unless there is only one window showing\r
104 +it, in which case it is killed."\r
105    (interactive)\r
106 -  (kill-buffer (current-buffer)))\r
107 +  (if (> (length (get-buffer-window-list nil nil t)) 1)\r
108 +      (bury-buffer)\r
109 +    (kill-buffer)))\r
110  \r
111  (defun notmuch-documentation-first-line (symbol)\r
112    "Return the first line of the documentation string for SYMBOL."\r
113 diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
114 index a997482..6e03f1e 100644\r
115 --- a/emacs/notmuch-show.el\r
116 +++ b/emacs/notmuch-show.el\r
117 @@ -1956,7 +1956,7 @@ buffer. If PREVIOUS is non-nil, move to the previous item in the\r
118  search results instead."\r
119    (interactive "P")\r
120    (let ((parent-buffer notmuch-show-parent-buffer))\r
121 -    (notmuch-kill-this-buffer)\r
122 +    (notmuch-bury-or-kill-this-buffer)\r
123      (when (buffer-live-p parent-buffer)\r
124        (switch-to-buffer parent-buffer)\r
125        (and (if previous\r
126 diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el\r
127 index e859cc2..8b6cd51 100644\r
128 --- a/emacs/notmuch-tree.el\r
129 +++ b/emacs/notmuch-tree.el\r
130 @@ -234,7 +234,7 @@ FUNC."\r
131      ;; Override because we want to close message pane first.\r
132      (define-key map [remap notmuch-help] (notmuch-tree-close-message-pane-and #'notmuch-help))\r
133      ;; Override because we first close message pane and then close tree buffer.\r
134 -    (define-key map [remap notmuch-kill-this-buffer] 'notmuch-tree-quit)\r
135 +    (define-key map [remap notmuch-bury-or-kill-this-buffer] 'notmuch-tree-quit)\r
136      ;; Override because we close message pane after the search query is entered.\r
137      (define-key map [remap notmuch-search] 'notmuch-tree-to-search)\r
138      ;; Override because we want to close message pane first.\r
139 diff --git a/emacs/notmuch.el b/emacs/notmuch.el\r
140 index b44a907..218486a 100644\r
141 --- a/emacs/notmuch.el\r
142 +++ b/emacs/notmuch.el\r
143 @@ -153,7 +153,7 @@ there will be called at other points of notmuch execution."\r
144  (defvar notmuch-search-mode-map\r
145    (let ((map (make-sparse-keymap)))\r
146      (set-keymap-parent map notmuch-common-keymap)\r
147 -    (define-key map "x" 'notmuch-kill-this-buffer)\r
148 +    (define-key map "x" 'notmuch-bury-or-kill-this-buffer)\r
149      (define-key map (kbd "<DEL>") 'notmuch-search-scroll-down)\r
150      (define-key map "b" 'notmuch-search-scroll-down)\r
151      (define-key map " " 'notmuch-search-scroll-up)\r
152 @@ -961,7 +961,7 @@ same relative position within the new buffer."\r
153         (oldest-first notmuch-search-oldest-first)\r
154         (target-thread (notmuch-search-find-thread-id 'bare))\r
155         (query notmuch-search-query-string))\r
156 -    (notmuch-kill-this-buffer)\r
157 +    (notmuch-bury-or-kill-this-buffer)\r
158      (notmuch-search query oldest-first target-thread target-line)\r
159      (goto-char (point-min))))\r
160  \r
161 -- \r
162 2.1.1\r
163 \r