]> git.notmuchmail.org Git - notmuch/commitdiff
emacs: Improve the behaviour of the 'q' binding.
authorDavid Edmondson <dme@dme.org>
Wed, 29 Oct 2014 14:18:49 +0000 (14:18 +0000)
committerDavid Bremner <david@tethera.net>
Fri, 31 Oct 2014 16:54:21 +0000 (17:54 +0100)
When a user hits 'q' in a notmuch buffer, kill the buffer only if
there are no other windows currently showing it.

emacs/notmuch-lib.el
emacs/notmuch-show.el
emacs/notmuch-tree.el
emacs/notmuch.el

index 1e166c6afce53a501689c616f6478d7d3d496412..fd25f7c9e6279b528c81b1908948ff7554a12015 100644 (file)
@@ -135,7 +135,7 @@ For example, if you wanted to remove an \"inbox\" tag and add an
 (defvar notmuch-common-keymap
   (let ((map (make-sparse-keymap)))
     (define-key map "?" 'notmuch-help)
-    (define-key map "q" 'notmuch-kill-this-buffer)
+    (define-key map "q" 'notmuch-bury-or-kill-this-buffer)
     (define-key map "s" 'notmuch-search)
     (define-key map "z" 'notmuch-tree)
     (define-key map "m" 'notmuch-mua-new-mail)
@@ -239,10 +239,15 @@ depending on the value of `notmuch-poll-script'."
        (call-process notmuch-poll-script nil nil))
     (call-process notmuch-command nil nil nil "new")))
 
-(defun notmuch-kill-this-buffer ()
-  "Kill the current buffer."
+(defun notmuch-bury-or-kill-this-buffer ()
+  "Undisplay the current buffer.
+
+Bury the current buffer, unless there is only one window showing
+it, in which case it is killed."
   (interactive)
-  (kill-buffer (current-buffer)))
+  (if (> (length (get-buffer-window-list nil nil t)) 1)
+      (bury-buffer)
+    (kill-buffer)))
 
 (defun notmuch-documentation-first-line (symbol)
   "Return the first line of the documentation string for SYMBOL."
index a9974826e824133e1d905986d7d4343ad9e1aacc..6e03f1e7820fa209e309b76b0047c389617d6816 100644 (file)
@@ -1956,7 +1956,7 @@ buffer. If PREVIOUS is non-nil, move to the previous item in the
 search results instead."
   (interactive "P")
   (let ((parent-buffer notmuch-show-parent-buffer))
-    (notmuch-kill-this-buffer)
+    (notmuch-bury-or-kill-this-buffer)
     (when (buffer-live-p parent-buffer)
       (switch-to-buffer parent-buffer)
       (and (if previous
index e859cc244f8f46f501b750746416ec65f64be4f1..8b6cd51017947c27ff90dbff44bde1fbdac98add 100644 (file)
@@ -234,7 +234,7 @@ FUNC."
     ;; Override because we want to close message pane first.
     (define-key map [remap notmuch-help] (notmuch-tree-close-message-pane-and #'notmuch-help))
     ;; Override because we first close message pane and then close tree buffer.
-    (define-key map [remap notmuch-kill-this-buffer] 'notmuch-tree-quit)
+    (define-key map [remap notmuch-bury-or-kill-this-buffer] 'notmuch-tree-quit)
     ;; Override because we close message pane after the search query is entered.
     (define-key map [remap notmuch-search] 'notmuch-tree-to-search)
     ;; Override because we want to close message pane first.
index b44a907a74c7eb7d8ea4320176417a3534d3d55f..218486ace24d2b69914618de636f69be37addcf4 100644 (file)
@@ -153,7 +153,7 @@ there will be called at other points of notmuch execution."
 (defvar notmuch-search-mode-map
   (let ((map (make-sparse-keymap)))
     (set-keymap-parent map notmuch-common-keymap)
-    (define-key map "x" 'notmuch-kill-this-buffer)
+    (define-key map "x" 'notmuch-bury-or-kill-this-buffer)
     (define-key map (kbd "<DEL>") 'notmuch-search-scroll-down)
     (define-key map "b" 'notmuch-search-scroll-down)
     (define-key map " " 'notmuch-search-scroll-up)
@@ -961,7 +961,7 @@ same relative position within the new buffer."
        (oldest-first notmuch-search-oldest-first)
        (target-thread (notmuch-search-find-thread-id 'bare))
        (query notmuch-search-query-string))
-    (notmuch-kill-this-buffer)
+    (notmuch-bury-or-kill-this-buffer)
     (notmuch-search query oldest-first target-thread target-line)
     (goto-char (point-min))))