(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)
(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."
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
;; 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.
(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)
(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))))