From a86b330f8fa754c4b919ea14d0c5dcf261f055c4 Mon Sep 17 00:00:00 2001 From: Juri Linkov Date: Sun, 16 Mar 2008 17:44:20 +0000 Subject: [PATCH] (kill-this-buffer): Use menu-bar-non-minibuffer-window-p to check if the current buffer is the minibuffer, and in this case call abort-recursive-edit to kill the minibuffer. Doc fix. (kill-this-buffer-enabled-p): Allow this function to return non-nil when the current buffer is the minibuffer. --- lisp/menu-bar.el | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lisp/menu-bar.el b/lisp/menu-bar.el index 6d9e4608186..bd7cd8257ef 100644 --- a/lisp/menu-bar.el +++ b/lisp/menu-bar.el @@ -1439,9 +1439,13 @@ for the definition of the menu frame." (not (window-minibuffer-p (frame-selected-window menu-frame))))) (defun kill-this-buffer () ; for the menu bar - "Kill the current buffer." + "Kill the current buffer. +When called in the minibuffer, get out of the minibuffer +using `abort-recursive-edit'." (interactive) - (kill-buffer (current-buffer))) + (if (menu-bar-non-minibuffer-window-p) + (kill-buffer (current-buffer)) + (abort-recursive-edit))) (defun kill-this-buffer-enabled-p () (let ((count 0) @@ -1450,8 +1454,8 @@ for the definition of the menu frame." (or (string-match "^ " (buffer-name (car buffers))) (setq count (1+ count))) (setq buffers (cdr buffers))) - (and (menu-bar-non-minibuffer-window-p) - (> count 1)))) + (or (not (menu-bar-non-minibuffer-window-p)) + (> count 1)))) (put 'dired 'menu-enable '(menu-bar-non-minibuffer-window-p)) -- 2.39.2