aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1994-12-15 02:02:04 +0000
committerRichard M. Stallman1994-12-15 02:02:04 +0000
commit1c6c6fde92555a8a927d65defccab5f21998bdf1 (patch)
tree65e5454ab18e75c20eaf7d9a00c0390fae025a4c
parent80f14e531fc113ceb19f3e93d789e437d4b2dfdd (diff)
downloademacs-1c6c6fde92555a8a927d65defccab5f21998bdf1.tar.gz
emacs-1c6c6fde92555a8a927d65defccab5f21998bdf1.zip
(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.
-rw-r--r--lisp/simple.el23
1 files 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."
2501 2501
2502(define-key global-map "\C-g" 'keyboard-quit) 2502(define-key global-map "\C-g" 'keyboard-quit)
2503 2503
2504(defvar buffer-quit-function nil
2505 "Function to call to \"quit\" the current buffer, or nil if none.
2506\\[keyboard-escape-quit] calls this function when its more local actions
2507\(such as cancelling a prefix argument, minibuffer or region) do not apply.")
2508
2504(defun keyboard-escape-quit () 2509(defun keyboard-escape-quit ()
2505 "Exit the current \"mode\" (in a generalized sense of the word). 2510 "Exit the current \"mode\" (in a generalized sense of the word).
2506This command can exit an interactive command such as `query-replace', 2511This command can exit an interactive command such as `query-replace',
2507can clear out a prefix argument or a region, 2512can clear out a prefix argument or a region,
2508can get out of the minibuffer or other recursive edit, 2513can get out of the minibuffer or other recursive edit,
2509or delete other windows." 2514cancel the use of the current buffer (for special-purpose buffers),
2515or go back to just one window (by deleting all but the selected window)."
2510 (interactive) 2516 (interactive)
2511 (cond ((eq last-command 'mode-exited) nil) 2517 (cond ((eq last-command 'mode-exited) nil)
2512 ((> (minibuffer-depth) 0) 2518 ((> (minibuffer-depth) 0)
@@ -2516,11 +2522,12 @@ or delete other windows."
2516 ((and transient-mark-mode 2522 ((and transient-mark-mode
2517 mark-active) 2523 mark-active)
2518 (deactivate-mark)) 2524 (deactivate-mark))
2525 (buffer-quit-function
2526 (funcall buffer-quit-function))
2519 ((not (one-window-p t)) 2527 ((not (one-window-p t))
2520 (delete-other-windows)))) 2528 (delete-other-windows))))
2521 2529
2522;;; This may not be safe yet. 2530(define-key global-map "\e\e\e" 'keyboard-escape-quit)
2523;;;(define-key global-map "\e\e\e" 'keyboard-escape-quit)
2524 2531
2525(defun set-variable (var val) 2532(defun set-variable (var val)
2526 "Set VARIABLE to VALUE. VALUE is a Lisp object. 2533 "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."
2569 (define-key map [down-mouse-2] nil) 2576 (define-key map [down-mouse-2] nil)
2570 (define-key map "\C-m" 'choose-completion) 2577 (define-key map "\C-m" 'choose-completion)
2571 (define-key map [return] 'choose-completion) 2578 (define-key map [return] 'choose-completion)
2579 (define-key map "\e\e\e" 'delete-completion-window)
2572 (setq completion-list-mode-map map))) 2580 (setq completion-list-mode-map map)))
2573 2581
2574;; Completion mode is suitable only for specially formatted data. 2582;; 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."
2581;; which was not included in the completion. 2589;; which was not included in the completion.
2582(defvar completion-base-size nil) 2590(defvar completion-base-size nil)
2583 2591
2592(defun delete-completion-window ()
2593 "Delete the completion list window.
2594Go to the window from which completion was requested."
2595 (interactive)
2596 (let ((buf completion-reference-buffer))
2597 (delete-window (selected-window))
2598 (if (get-buffer-window buf)
2599 (select-window (get-buffer-window buf)))))
2600
2584(defun choose-completion () 2601(defun choose-completion ()
2585 "Choose the completion that point is in or next to." 2602 "Choose the completion that point is in or next to."
2586 (interactive) 2603 (interactive)