From: Eli Zaretskii Date: Wed, 12 Apr 2017 20:14:20 +0000 (+0300) Subject: Don't call 'kill-this-buffer' outside of menus X-Git-Tag: emacs-26.0.90~521^2~646 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=2e4f4c9d48c563ff8bec102b66da0225587786c6;p=emacs.git Don't call 'kill-this-buffer' outside of menus * lisp/simple.el (kill-current-buffer): New function. (completion-list-mode-map): Use it instead of kill-this-buffer. * lisp/type-break.el (type-break-mode): * lisp/term/ns-win.el (global-map): * lisp/progmodes/gdb-mi.el (gdb-memory-mode-map) (gdb-disassembly-mode-map, gdb-frames-mode-map) (gdb-locals-mode-map, gdb-registers-mode-map): * lisp/org/org-mhe.el (org-mhe-follow-link): * lisp/net/secrets.el (secrets-mode-map): * lisp/net/eudc.el (eudc-mode-map): * lisp/net/eudc-hotlist.el (eudc-hotlist-mode-map): Use kill-current-buffer instead of kill-this-buffer. (Bug#26466) --- diff --git a/lisp/net/eudc-hotlist.el b/lisp/net/eudc-hotlist.el index 5c170d0aea6..083fd7fe7e4 100644 --- a/lisp/net/eudc-hotlist.el +++ b/lisp/net/eudc-hotlist.el @@ -42,7 +42,7 @@ (define-key map "s" 'eudc-hotlist-select-server) (define-key map "t" 'eudc-hotlist-transpose-servers) (define-key map "q" 'eudc-hotlist-quit-edit) - (define-key map "x" 'kill-this-buffer) + (define-key map "x" 'kill-current-buffer) map)) (define-derived-mode eudc-hotlist-mode fundamental-mode "EUDC-Servers" diff --git a/lisp/net/eudc.el b/lisp/net/eudc.el index bdd69bf53e1..644df7ab786 100644 --- a/lisp/net/eudc.el +++ b/lisp/net/eudc.el @@ -68,8 +68,8 @@ (defvar eudc-mode-map (let ((map (make-sparse-keymap))) - (define-key map "q" 'kill-this-buffer) - (define-key map "x" 'kill-this-buffer) + (define-key map "q" 'kill-current-buffer) + (define-key map "x" 'kill-current-buffer) (define-key map "f" 'eudc-query-form) (define-key map "b" 'eudc-try-bbdb-insert) (define-key map "n" 'eudc-move-to-next-record) diff --git a/lisp/net/secrets.el b/lisp/net/secrets.el index 4d6e48ba2e0..9bcfc378f42 100644 --- a/lisp/net/secrets.el +++ b/lisp/net/secrets.el @@ -737,7 +737,7 @@ If there is no such item, or the item doesn't own this attribute, return nil." (set-keymap-parent map (make-composed-keymap special-mode-map widget-keymap)) (define-key map "n" 'next-line) (define-key map "p" 'previous-line) - (define-key map "z" 'kill-this-buffer) + (define-key map "z" 'kill-current-buffer) map) "Keymap used in `secrets-mode' buffers.") diff --git a/lisp/org/org-mhe.el b/lisp/org/org-mhe.el index 72c2eeec22e..d1067cd57e9 100644 --- a/lisp/org/org-mhe.el +++ b/lisp/org/org-mhe.el @@ -212,7 +212,7 @@ folders." (mh-search folder (list "--message-id" article)) (when (and org-mhe-search-all-folders (not (org-mhe-get-message-real-folder))) - (kill-this-buffer) + (kill-current-buffer) (mh-search "+" (list "--message-id" article)))) (if mh-search-regexp-builder (mh-search "+" (funcall mh-search-regexp-builder @@ -220,7 +220,7 @@ folders." (mh-search "+" article))) (if (org-mhe-get-message-real-folder) (mh-show-msg 1) - (kill-this-buffer) + (kill-current-buffer) (error "Message not found")))) (provide 'org-mhe) diff --git a/lisp/progmodes/gdb-mi.el b/lisp/progmodes/gdb-mi.el index a30669d6bde..1af520dbc32 100644 --- a/lisp/progmodes/gdb-mi.el +++ b/lisp/progmodes/gdb-mi.el @@ -3484,7 +3484,7 @@ in `gdb-memory-format'." (defvar gdb-memory-mode-map (let ((map (make-sparse-keymap))) (suppress-keymap map t) - (define-key map "q" 'kill-this-buffer) + (define-key map "q" 'kill-current-buffer) (define-key map "n" 'gdb-memory-show-next-page) (define-key map "p" 'gdb-memory-show-previous-page) (define-key map "a" 'gdb-memory-set-address) @@ -3838,7 +3838,7 @@ DOC is an optional documentation string." ;; TODO (let ((map (make-sparse-keymap))) (suppress-keymap map) - (define-key map "q" 'kill-this-buffer) + (define-key map "q" 'kill-current-buffer) map)) (define-derived-mode gdb-disassembly-mode gdb-parent-mode "Disassembly" @@ -4042,7 +4042,7 @@ member." (defvar gdb-frames-mode-map (let ((map (make-sparse-keymap))) (suppress-keymap map) - (define-key map "q" 'kill-this-buffer) + (define-key map "q" 'kill-current-buffer) (define-key map "\r" 'gdb-select-frame) (define-key map [mouse-2] 'gdb-select-frame) (define-key map [follow-link] 'mouse-face) @@ -4168,7 +4168,7 @@ member." (defvar gdb-locals-mode-map (let ((map (make-sparse-keymap))) (suppress-keymap map) - (define-key map "q" 'kill-this-buffer) + (define-key map "q" 'kill-current-buffer) (define-key map "\t" (lambda () (interactive) (gdb-set-window-buffer @@ -4259,7 +4259,7 @@ member." (suppress-keymap map) (define-key map "\r" 'gdb-edit-register-value) (define-key map [mouse-2] 'gdb-edit-register-value) - (define-key map "q" 'kill-this-buffer) + (define-key map "q" 'kill-current-buffer) (define-key map "\t" (lambda () (interactive) (gdb-set-window-buffer diff --git a/lisp/simple.el b/lisp/simple.el index 48c1a9b15d6..a58164a1121 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -5147,6 +5147,21 @@ If ARG is zero, move to the beginning of the current line." (point-max))) (goto-char (next-overlay-change (point)))) (end-of-line))) + +(defun kill-current-buffer () + "Kill the current buffer. +When called in the minibuffer, get out of the minibuffer +using `abort-recursive-edit'. + +This is like `kill-this-buffer', but it doesn't have to be invoked +via the menu bar, and pays no attention to the menu-bar's frame." + (interactive) + (let ((frame (selected-frame))) + (if (and (frame-live-p frame) + (not (window-minibuffer-p (frame-selected-window frame)))) + (kill-buffer (current-buffer)) + (abort-recursive-edit)))) + (defun insert-buffer (buffer) "Insert after point the contents of BUFFER. @@ -7892,7 +7907,7 @@ With a prefix argument, set VARIABLE to VALUE buffer-locally." (define-key map [?\t] 'next-completion) (define-key map [backtab] 'previous-completion) (define-key map "q" 'quit-window) - (define-key map "z" 'kill-this-buffer) + (define-key map "z" 'kill-current-buffer) map) "Local map for completion list buffers.") diff --git a/lisp/term/ns-win.el b/lisp/term/ns-win.el index caad5155fbc..70bd817d930 100644 --- a/lisp/term/ns-win.el +++ b/lisp/term/ns-win.el @@ -109,7 +109,7 @@ The properties returned may include `top', `left', `height', and `width'." (define-key global-map [?\s-:] 'ispell) (define-key global-map [?\s-?] 'info) (define-key global-map [?\s-^] 'kill-some-buffers) -(define-key global-map [?\s-&] 'kill-this-buffer) +(define-key global-map [?\s-&] 'kill-current-buffer) (define-key global-map [?\s-C] 'ns-popup-color-panel) (define-key global-map [?\s-D] 'dired) (define-key global-map [?\s-E] 'edit-abbrevs) @@ -125,7 +125,7 @@ The properties returned may include `top', `left', `height', and `width'." (define-key global-map [?\s-h] 'ns-do-hide-emacs) (define-key global-map [?\s-H] 'ns-do-hide-others) (define-key global-map [?\s-j] 'exchange-point-and-mark) -(define-key global-map [?\s-k] 'kill-this-buffer) +(define-key global-map [?\s-k] 'kill-current-buffer) (define-key global-map [?\s-l] 'goto-line) (define-key global-map [?\s-m] 'iconify-frame) (define-key global-map [?\s-n] 'make-frame) diff --git a/lisp/type-break.el b/lisp/type-break.el index fb131d6ebfa..8cb81d496ee 100644 --- a/lisp/type-break.el +++ b/lisp/type-break.el @@ -402,7 +402,7 @@ problems." 'nowarn) (set-buffer-modified-p nil) (unlock-buffer) - (kill-this-buffer)))))) + (kill-current-buffer)))))) (define-minor-mode type-break-mode-line-message-mode "Toggle warnings about typing breaks in the mode line.