From 1c6c6fde92555a8a927d65defccab5f21998bdf1 Mon Sep 17 00:00:00 2001 From: "Richard M. Stallman" Date: Thu, 15 Dec 1994 02:02:04 +0000 Subject: [PATCH] (buffer-quit-function): New variable. (keyboard-escape-quit): Use it. (delete-completion-window): New function. (completion-list-mode-map): Bind that to ESC ESC ESC. (keyboard-escape-quit): Bind this globally to ESC ESC ESC. --- lisp/simple.el | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/lisp/simple.el b/lisp/simple.el index 157a5cb90d0..7c53aa2df1c 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -2501,12 +2501,18 @@ At top-level, as an editor command, this simply beeps." (define-key global-map "\C-g" 'keyboard-quit) +(defvar buffer-quit-function nil + "Function to call to \"quit\" the current buffer, or nil if none. +\\[keyboard-escape-quit] calls this function when its more local actions +\(such as cancelling a prefix argument, minibuffer or region) do not apply.") + (defun keyboard-escape-quit () "Exit the current \"mode\" (in a generalized sense of the word). This command can exit an interactive command such as `query-replace', can clear out a prefix argument or a region, can get out of the minibuffer or other recursive edit, -or delete other windows." +cancel the use of the current buffer (for special-purpose buffers), +or go back to just one window (by deleting all but the selected window)." (interactive) (cond ((eq last-command 'mode-exited) nil) ((> (minibuffer-depth) 0) @@ -2516,11 +2522,12 @@ or delete other windows." ((and transient-mark-mode mark-active) (deactivate-mark)) + (buffer-quit-function + (funcall buffer-quit-function)) ((not (one-window-p t)) (delete-other-windows)))) -;;; This may not be safe yet. -;;;(define-key global-map "\e\e\e" 'keyboard-escape-quit) +(define-key global-map "\e\e\e" 'keyboard-escape-quit) (defun set-variable (var val) "Set VARIABLE to VALUE. VALUE is a Lisp object. @@ -2569,6 +2576,7 @@ it were the arg to `interactive' (which see) to interactively read the value." (define-key map [down-mouse-2] nil) (define-key map "\C-m" 'choose-completion) (define-key map [return] 'choose-completion) + (define-key map "\e\e\e" 'delete-completion-window) (setq completion-list-mode-map map))) ;; Completion mode is suitable only for specially formatted data. @@ -2581,6 +2589,15 @@ it were the arg to `interactive' (which see) to interactively read the value." ;; which was not included in the completion. (defvar completion-base-size nil) +(defun delete-completion-window () + "Delete the completion list window. +Go to the window from which completion was requested." + (interactive) + (let ((buf completion-reference-buffer)) + (delete-window (selected-window)) + (if (get-buffer-window buf) + (select-window (get-buffer-window buf))))) + (defun choose-completion () "Choose the completion that point is in or next to." (interactive) -- 2.39.5