From: David Edmondson Date: Wed, 29 Oct 2014 14:18:49 +0000 (+0000) Subject: emacs: Improve the behaviour of the 'q' binding. X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=30f1c43efe32c83193a6b9ae1f31ab2667e4195d;p=notmuch.git emacs: Improve the behaviour of the 'q' binding. When a user hits 'q' in a notmuch buffer, kill the buffer only if there are no other windows currently showing it. --- diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el index 1e166c6a..fd25f7c9 100644 --- a/emacs/notmuch-lib.el +++ b/emacs/notmuch-lib.el @@ -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." diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el index a9974826..6e03f1e7 100644 --- a/emacs/notmuch-show.el +++ b/emacs/notmuch-show.el @@ -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 diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el index e859cc24..8b6cd510 100644 --- a/emacs/notmuch-tree.el +++ b/emacs/notmuch-tree.el @@ -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. diff --git a/emacs/notmuch.el b/emacs/notmuch.el index b44a907a..218486ac 100644 --- a/emacs/notmuch.el +++ b/emacs/notmuch.el @@ -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 "") '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))))