annotate lisp/cmdloop.el @ 384:bbff43aa5eb7 r21-2-7

Import from CVS: tag r21-2-7
author cvs
date Mon, 13 Aug 2007 11:08:24 +0200
parents 8626e4521993
children 74fd4e045ea6
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1 ;;; cmdloop.el --- support functions for the top-level command loop.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3 ;; Copyright (C) 1992-4, 1997 Free Software Foundation, Inc.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
4
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
5 ;; Author: Richard Mlynarik
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
6 ;; Date: 8-Jul-92
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
7 ;; Maintainer: XEmacs Development Team
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
8 ;; Keywords: internal, dumped
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
9
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
10 ;; This file is part of XEmacs.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
11
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
12 ;; XEmacs is free software; you can redistribute it and/or modify it
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
13 ;; under the terms of the GNU General Public License as published by
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
14 ;; the Free Software Foundation; either version 2, or (at your option)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
15 ;; any later version.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
16
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
17 ;; XEmacs is distributed in the hope that it will be useful, but
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
18 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
20 ;; General Public License for more details.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
21
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
22 ;; You should have received a copy of the GNU General Public License
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
23 ;; along with XEmacs; see the file COPYING. If not, write to the
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
24 ;; Free Software Foundation, 59 Temple Place - Suite 330,
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
25 ;; Boston, MA 02111-1307, USA.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
26
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
27 ;;; Synched up with: FSF 19.30. (Some of the stuff below is in FSF's subr.el.)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
28
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
29 ;;; Commentary:
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
30
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
31 ;; This file is dumped with XEmacs.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
32
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
33 ;;; Code:
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
34
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
35 (defun recursion-depth ()
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
36 "Return the current depth in recursive edits."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
37 (+ command-loop-level (minibuffer-depth)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
38
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
39 (defun top-level ()
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
40 "Exit all recursive editing levels."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
41 (interactive)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
42 (throw 'top-level nil))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
43
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
44 (defun exit-recursive-edit ()
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
45 "Exit from the innermost recursive edit or minibuffer."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
46 (interactive)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
47 (if (> (recursion-depth) 0)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
48 (throw 'exit nil))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
49 (error "No recursive edit is in progress"))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
50
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
51 (defun abort-recursive-edit ()
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
52 "Abort the command that requested this recursive edit or minibuffer input."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
53 (interactive)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
54 (if (> (recursion-depth) 0)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
55 (throw 'exit t))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
56 (error "No recursive edit is in progress"))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
57
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
58 ;; (defun keyboard-quit ()
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
59 ;; "Signal a `quit' condition."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
60 ;; (interactive)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
61 ;; (deactivate-mark)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
62 ;; (signal 'quit nil))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
63
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
64 ;; moved here from pending-del.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
65 (defun keyboard-quit ()
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
66 "Signal a `quit' condition.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
67 If this character is typed while lisp code is executing, it will be treated
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
68 as an interrupt.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
69 If this character is typed at top-level, this simply beeps.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
70 If `zmacs-regions' is true, and the zmacs region is active in this buffer,
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
71 then this key deactivates the region without beeping or signalling."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
72 (interactive)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
73 (if (and (region-active-p)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
74 (eq (current-buffer) (zmacs-region-buffer)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
75 ;; pseudo-zmacs compatibility: don't beep if this ^G is simply
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
76 ;; deactivating the region. If it is inactive, beep.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
77 nil
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
78 (signal 'quit nil)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
79
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
80 (defvar buffer-quit-function nil
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
81 "Function to call to \"quit\" the current buffer, or nil if none.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
82 \\[keyboard-escape-quit] calls this function when its more local actions
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
83 \(such as cancelling a prefix argument, minibuffer or region) do not apply.")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
84
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
85 (defun keyboard-escape-quit ()
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
86 "Exit the current \"mode\" (in a generalized sense of the word).
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
87 This command can exit an interactive command such as `query-replace',
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
88 can clear out a prefix argument or a region,
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
89 can get out of the minibuffer or other recursive edit,
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
90 cancel the use of the current buffer (for special-purpose buffers),
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
91 or go back to just one window (by deleting all but the selected window)."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
92 (interactive)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
93 (cond ((eq last-command 'mode-exited) nil)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
94 ((> (minibuffer-depth) 0)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
95 (abort-recursive-edit))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
96 (current-prefix-arg
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
97 nil)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
98 ((region-active-p)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
99 (zmacs-deactivate-region))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
100 ((> (recursion-depth) 0)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
101 (exit-recursive-edit))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
102 (buffer-quit-function
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
103 (funcall buffer-quit-function))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
104 ((not (one-window-p t))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
105 (delete-other-windows))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
106 ((string-match "^ \\*" (buffer-name (current-buffer)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
107 (bury-buffer))))
290
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 284
diff changeset
108
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 284
diff changeset
109 ;; `cancel-mode-internal' is a function of a misc-user event, which is
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 284
diff changeset
110 ;; queued when window system directs XEmacs frame to cancel any modal
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 284
diff changeset
111 ;; behavior it exposes, like mouse pointer grabbing.
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 284
diff changeset
112 ;;
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 284
diff changeset
113 ;; This function does nothing at the top level, but the code which
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 284
diff changeset
114 ;; runs modal event loops, such as selection drag loop in `mouse-track',
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 284
diff changeset
115 ;; check if misc-user function symbol is `cancel-mode-internal', and
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 284
diff changeset
116 ;; takes necessary cleanup actions.
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 284
diff changeset
117 (defun cancel-mode-internal (object)
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 284
diff changeset
118 (setq zmacs-region-stays t))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
119
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
120 ;; Someone wrote: "This should really be a ring of last errors."
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
121 ;;
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
122 ;; But why bother? This stuff is not all that necessary now that we
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
123 ;; have message log, anyway.
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
124 (defvar last-error nil
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
125 "Object describing the last signaled error.")
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
126
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
127 (defcustom errors-deactivate-region nil
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
128 "*Non-nil means that errors will cause the region to be deactivated."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
129 :type 'boolean
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
130 :group 'editing-basics)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
131
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
132 (defun command-error (error-object)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
133 (let ((inhibit-quit t)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
134 (debug-on-error nil)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
135 (etype (car-safe error-object)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
136 (setq quit-flag nil)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
137 (setq standard-output t)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
138 (setq standard-input t)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
139 (setq executing-kbd-macro nil)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
140 (and errors-deactivate-region
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
141 (zmacs-deactivate-region))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
142 (discard-input)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
143
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
144 (setq last-error error-object)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
145
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
146 (message nil)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
147 (ding nil (cond ((eq etype 'undefined-keystroke-sequence)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
148 (if (and (vectorp (nth 1 error-object))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
149 (/= 0 (length (nth 1 error-object)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
150 (button-event-p (aref (nth 1 error-object) 0)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
151 'undefined-click
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
152 'undefined-key))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
153 ((eq etype 'quit)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
154 'quit)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
155 ((memq etype '(end-of-buffer beginning-of-buffer))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
156 'buffer-bound)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
157 ((eq etype 'buffer-read-only)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
158 'read-only)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
159 (t 'command-error)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
160 (display-error error-object t)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
161
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
162 (if (noninteractive)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
163 (progn
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 276
diff changeset
164 (message "%s exiting." emacs-program-name)
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
165 (kill-emacs -1)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
166 t))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
167
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
168 (defun describe-last-error ()
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
169 "Redisplay the last error-message. See the variable `last-error'."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
170 (interactive)
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
171 (if last-error
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
172 (with-displaying-help-buffer
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
173 (lambda ()
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
174 (princ "Last error was:\n" standard-output)
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
175 (display-error last-error standard-output)))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
176 (message "No error yet")))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
177
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
178
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
179 ;;#### Must be done later in the loadup sequence
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
180 ;(define-key (symbol-function 'help-command) "e" 'describe-last-error)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
181
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
182
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
183 (defun truncate-command-history-for-gc ()
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
184 (let ((tail (nthcdr 30 command-history)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
185 (if tail (setcdr tail nil)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
186 (let ((tail (nthcdr 30 values)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
187 (if tail (setcdr tail nil)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
188 )
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
189
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
190 (add-hook 'pre-gc-hook 'truncate-command-history-for-gc)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
191
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
192
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
193 ;;;; Object-oriented programming at its finest
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
194
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
195 ;; Now in src/print.c; used by Ferror_message_string and others
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
196 ;(defun display-error (error-object stream) ;(defgeneric report-condition ...)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
197 ; "Display `error-object' on `stream' in a user-friendly way."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
198 ; (funcall (or (let ((type (car-safe error-object)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
199 ; (catch 'error
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
200 ; (and (consp error-object)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
201 ; (symbolp type)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
202 ; ;;(stringp (get type 'error-message))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
203 ; (consp (get type 'error-conditions))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
204 ; (let ((tail (cdr error-object)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
205 ; (while (not (null tail))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
206 ; (if (consp tail)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
207 ; (setq tail (cdr tail))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
208 ; (throw 'error nil)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
209 ; t)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
210 ; ;; (check-type condition condition)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
211 ; (get type 'error-conditions)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
212 ; ;; Search class hierarchy
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
213 ; (let ((tail (get type 'error-conditions)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
214 ; (while (not (null tail))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
215 ; (cond ((not (and (consp tail)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
216 ; (symbolp (car tail))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
217 ; (throw 'error nil))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
218 ; ((get (car tail) 'display-error)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
219 ; (throw 'error (get (car tail)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
220 ; 'display-error)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
221 ; (t
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
222 ; (setq tail (cdr tail)))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
223 ; ;; Default method
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
224 ; #'(lambda (error-object stream)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
225 ; (let ((type (car error-object))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
226 ; (tail (cdr error-object))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
227 ; (first t)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
228 ; (print-message-label 'error))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
229 ; (if (eq type 'error)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
230 ; (progn (princ (car tail) stream)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
231 ; (setq tail (cdr tail)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
232 ; (princ (or (gettext (get type 'error-message)) type)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
233 ; stream))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
234 ; (while tail
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
235 ; (princ (if first ": " ", ") stream)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
236 ; (prin1 (car tail) stream)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
237 ; (setq tail (cdr tail)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
238 ; first nil))))))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
239 ; #'(lambda (error-object stream)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
240 ; (princ (gettext "Peculiar error ") stream)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
241 ; (prin1 error-object stream)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
242 ; error-object stream))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
243
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
244 (put 'file-error 'display-error
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
245 #'(lambda (error-object stream)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
246 (let ((tail (cdr error-object))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
247 (first t))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
248 (princ (car tail) stream)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
249 (while (setq tail (cdr tail))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
250 (princ (if first ": " ", ") stream)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
251 (princ (car tail) stream)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
252 (setq first nil)))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
253
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
254 (put 'undefined-keystroke-sequence 'display-error
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
255 #'(lambda (error-object stream)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
256 (princ (key-description (car (cdr error-object))) stream)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
257 ;; #### I18N3: doesn't localize properly.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
258 (princ (gettext " not defined.") stream) ; doo dah, doo dah.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
259 ))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
260
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
261
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
262 (defcustom teach-extended-commands-p t
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
263 "*If true, then `\\[execute-extended-command]' will teach you keybindings.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
264 Any time you execute a command with \\[execute-extended-command] which has a
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
265 shorter keybinding, you will be shown the alternate binding before the
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
266 command executes. There is a short pause after displaying the binding,
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
267 before executing it; the length can be controlled by
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
268 `teach-extended-commands-timeout'."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
269 :type 'boolean
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
270 :group 'keyboard)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
271
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
272 (defcustom teach-extended-commands-timeout 4
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
273 "*How long to pause after displaying a keybinding before executing.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
274 The value is measured in seconds. This only applies if
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
275 `teach-extended-commands-p' is true."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
276 :type 'number
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
277 :group 'keyboard)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
278
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 251
diff changeset
279 ;That damn RMS went off and implemented something differently, after
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 251
diff changeset
280 ;we had already implemented it. We can't support both properly until
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 251
diff changeset
281 ;we have Lisp magic variables.
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
282 ;(defvar suggest-key-bindings t
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
283 ; "*FSFmacs equivalent of `teach-extended-commands-*'.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
284 ;Provided for compatibility only.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
285 ;Non-nil means show the equivalent key-binding when M-x command has one.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
286 ;The value can be a length of time to show the message for.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
287 ;If the value is non-nil and not a number, we wait 2 seconds.")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
288 ;
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
289 ;(make-obsolete-variable 'suggest-key-bindings 'teach-extended-commands-p)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
290
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
291 (defun execute-extended-command (prefix-arg)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
292 "Read a command name from the minibuffer using 'completing-read'.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
293 Then call the specified command using 'command-execute' and return its
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
294 return value. If the command asks for a prefix argument, supply the
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
295 value of the current raw prefix argument, or the value of PREFIX-ARG
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
296 when called from Lisp."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
297 (interactive "P")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
298 ;; Note: This doesn't hack "this-command-keys"
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
299 (let ((prefix-arg prefix-arg))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
300 (setq this-command (read-command
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
301 ;; Note: this has the hard-wired
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
302 ;; "C-u" and "M-x" string bug in common
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
303 ;; with all GNU Emacs's.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
304 ;; (i.e. it prints C-u and M-x regardless of
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
305 ;; whether some other keys were actually bound
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
306 ;; to `execute-extended-command' and
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
307 ;; `universal-argument'.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
308 (cond ((eq prefix-arg '-)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
309 "- M-x ")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
310 ((equal prefix-arg '(4))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
311 "C-u M-x ")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
312 ((integerp prefix-arg)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
313 (format "%d M-x " prefix-arg))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
314 ((and (consp prefix-arg)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
315 (integerp (car prefix-arg)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
316 (format "%d M-x " (car prefix-arg)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
317 (t
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
318 "M-x ")))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
319
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
320 (if (and teach-extended-commands-p
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
321 (interactive-p))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
322 ;; We need to fiddle with keys: remember the keys, run the
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
323 ;; command, and show the keys (if any).
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
324 (let ((_execute_command_keys_ (where-is-internal this-command))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
325 (_execute_command_name_ this-command)) ; the name can change
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
326 (command-execute this-command t)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
327 (when (and _execute_command_keys_
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
328 ;; Wait for a while, so the user can see a message
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
329 ;; printed, if any.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
330 (sit-for 1))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
331 (display-message
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
332 'no-log
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
333 (format "Command `%s' is bound to key%s: %s"
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
334 _execute_command_name_
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
335 (if (cdr _execute_command_keys_) "s" "")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
336 (sorted-key-descriptions _execute_command_keys_)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
337 (sit-for teach-extended-commands-timeout)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
338 (clear-message 'no-log)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
339 ;; Else, just run the command.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
340 (command-execute this-command t)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
341
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
342
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
343 ;;; C code calls this; the underscores in the variable names are to avoid
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
344 ;;; cluttering the specbind namespace (lexical scope! lexical scope!)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
345 ;;; Putting this in Lisp instead of C slows kbd macros by 50%.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
346 ;(defun command-execute (_command &optional _record-flag)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
347 ; "Execute CMD as an editor command.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
348 ;CMD must be a symbol that satisfies the `commandp' predicate.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
349 ;Optional second arg RECORD-FLAG non-nil
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
350 ;means unconditionally put this command in `command-history'.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
351 ;Otherwise, that is done only if an arg is read using the minibuffer."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
352 ; (let ((_prefix prefix-arg)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
353 ; (_cmd (indirect-function _command)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
354 ; (setq prefix-arg nil
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
355 ; this-command _command
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
356 ; current-prefix-arg _prefix
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
357 ; zmacs-region-stays nil)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
358 ; ;; #### debug_on_next_call = 0;
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
359 ; (cond ((and (symbolp _command)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
360 ; (get _command 'disabled))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
361 ; (run-hooks disabled-command-hook))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
362 ; ((or (stringp _cmd) (vectorp _cmd))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
363 ; ;; If requested, place the macro in the command history.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
364 ; ;; For other sorts of commands, call-interactively takes
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
365 ; ;; care of this.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
366 ; (if _record-flag
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
367 ; (setq command-history
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
368 ; (cons (list 'execute-kbd-macro _cmd _prefix)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
369 ; command-history)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
370 ; (execute-kbd-macro _cmd _prefix))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
371 ; (t
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
372 ; (call-interactively _command _record-flag)))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
373
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
374 (defun y-or-n-p-minibuf (prompt)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
375 "Ask user a \"y or n\" question. Return t if answer is \"y\".
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
376 Takes one argument, which is the string to display to ask the question.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
377 It should end in a space; `y-or-n-p' adds `(y or n) ' to it.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
378 No confirmation of the answer is requested; a single character is enough.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
379 Also accepts Space to mean yes, or Delete to mean no."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
380 (save-excursion
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
381 (let* ((pre "")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
382 (yn (gettext "(y or n) "))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
383 ;; we need to translate the prompt ourselves because of the
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
384 ;; strange way we handle it.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
385 (prompt (gettext prompt))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
386 event)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
387 (while (stringp yn)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
388 (if (let ((cursor-in-echo-area t)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
389 (inhibit-quit t))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
390 (message "%s%s%s" pre prompt yn)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
391 (setq event (next-command-event event))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
392 (condition-case nil
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
393 (prog1
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
394 (or quit-flag (eq 'keyboard-quit (key-binding event)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
395 (setq quit-flag nil))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
396 (wrong-type-argument t)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
397 (progn
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
398 (message "%s%s%s%s" pre prompt yn (single-key-description event))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
399 (setq quit-flag nil)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
400 (signal 'quit '())))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
401 (let* ((keys (events-to-keys (vector event)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
402 (def (lookup-key query-replace-map keys)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
403 (cond ((eq def 'skip)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
404 (message "%s%sNo" prompt yn)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
405 (setq yn nil))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
406 ((eq def 'act)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
407 (message "%s%sYes" prompt yn)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
408 (setq yn t))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
409 ((eq def 'recenter)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
410 (recenter))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
411 ((or (eq def 'quit) (eq def 'exit-prefix))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
412 (signal 'quit '()))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
413 ((button-release-event-p event) ; ignore them
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
414 nil)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
415 (t
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
416 (message "%s%s%s%s" pre prompt yn
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
417 (single-key-description event))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
418 (ding nil 'y-or-n-p)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
419 (discard-input)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
420 (if (= (length pre) 0)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
421 (setq pre (gettext "Please answer y or n. ")))))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
422 yn)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
423
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
424 (defun yes-or-no-p-minibuf (prompt)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
425 "Ask user a yes-or-no question. Return t if answer is yes.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
426 Takes one argument, which is the string to display to ask the question.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
427 It should end in a space; `yes-or-no-p' adds `(yes or no) ' to it.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
428 The user must confirm the answer with RET,
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
429 and can edit it until it has been confirmed."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
430 (save-excursion
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
431 (let ((p (concat (gettext prompt) (gettext "(yes or no) ")))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
432 (ans ""))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
433 (while (stringp ans)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
434 (setq ans (downcase (read-string p nil t))) ;no history
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
435 (cond ((string-equal ans (gettext "yes"))
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 290
diff changeset
436 (setq ans t))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
437 ((string-equal ans (gettext "no"))
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 290
diff changeset
438 (setq ans nil))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
439 (t
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
440 (ding nil 'yes-or-no-p)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
441 (discard-input)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
442 (message "Please answer yes or no.")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
443 (sleep-for 2))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
444 ans)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
445
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
446 ;; these may be redefined later, but make the original def easily encapsulable
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
447 (define-function 'yes-or-no-p 'yes-or-no-p-minibuf)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
448 (define-function 'y-or-n-p 'y-or-n-p-minibuf)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
449
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
450
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
451 (defun read-char ()
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
452 "Read a character from the command input (keyboard or macro).
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
453 If a mouse click or non-ASCII character is detected, an error is
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
454 signalled. The character typed is returned as an ASCII value. This
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
455 is most likely the wrong thing for you to be using: consider using
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
456 the `next-command-event' function instead."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
457 (save-excursion
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
458 (let ((event (next-command-event)))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
459 (or inhibit-quit
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
460 (and (event-matches-key-specifier-p event (quit-char))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
461 (signal 'quit nil)))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
462 (prog1 (or (event-to-character event)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
463 ;; Kludge. If the event we read was a mouse-release,
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
464 ;; discard it and read the next one.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
465 (if (button-release-event-p event)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
466 (event-to-character (next-command-event event)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
467 (error "Key read has no ASCII equivalent %S" event))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
468 ;; this is not necessary, but is marginally more efficient than GC.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
469 (deallocate-event event)))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
470
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
471 (defun read-char-exclusive ()
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
472 "Read a character from the command input (keyboard or macro).
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
473 If a mouse click or non-ASCII character is detected, it is discarded.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
474 The character typed is returned as an ASCII value. This is most likely
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
475 the wrong thing for you to be using: consider using the
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
476 `next-command-event' function instead."
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
477 (let (event ch)
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
478 (while (progn
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
479 (setq event (next-command-event))
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
480 (or inhibit-quit
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
481 (and (event-matches-key-specifier-p event (quit-char))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
482 (signal 'quit nil)))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
483 (setq ch (event-to-character event))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
484 (deallocate-event event)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
485 (null ch)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
486 ch))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
487
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
488 (defun read-quoted-char (&optional prompt)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
489 "Like `read-char', except that if the first character read is an octal
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
490 digit, we read up to two more octal digits and return the character
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
491 represented by the octal number consisting of those digits.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
492 Optional argument PROMPT specifies a string to use to prompt the user."
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
493 (let ((count 0) (code 0) done
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
494 (prompt (and prompt (gettext prompt)))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
495 char event)
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
496 (while (and (not done) (< count 3))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
497 (let ((inhibit-quit (zerop count))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
498 ;; Don't let C-h get the help message--only help function keys.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
499 (help-char nil)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
500 (help-form
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
501 "Type the special character you want to use,
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
502 or three octal digits representing its character code."))
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
503 (and prompt (display-message 'prompt (format "%s-" prompt)))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
504 (setq event (next-command-event)
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
505 char (or (event-to-character event nil nil t)
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
506 (signal 'error
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
507 (list "key read cannot be inserted in a buffer"
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
508 event))))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
509 (if inhibit-quit (setq quit-flag nil)))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
510 (cond ((<= ?0 char ?7)
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
511 (setq code (+ (* code 8) (- char ?0))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
512 count (1+ count))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
513 (when prompt
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
514 (display-message 'prompt
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
515 (setq prompt (format "%s %c" prompt char)))))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
516 ((> count 0)
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
517 (setq unread-command-event event
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
518 done t))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
519 (t (setq code (char-int char)
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
520 done t))))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
521 (int-char code)
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
522 ;; Turn a meta-character into a character with the 0200 bit set.
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
523 ; (logior (if (/= (logand code ?\M-\^@) 0) 128 0)
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
524 ; (logand 255 code))))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
525 ))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
526
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
527 (defun momentary-string-display (string pos &optional exit-char message)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
528 "Momentarily display STRING in the buffer at POS.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
529 Display remains until next character is typed.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
530 If the char is EXIT-CHAR (optional third arg, default is SPC) it is swallowed;
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
531 otherwise it is then available as input (as a command if nothing else).
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
532 Display MESSAGE (optional fourth arg) in the echo area.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
533 If MESSAGE is nil, instructions to type EXIT-CHAR are displayed there."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
534 (or exit-char (setq exit-char ?\ ))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
535 (let ((buffer-read-only nil)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
536 ;; Don't modify the undo list at all.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
537 (buffer-undo-list t)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
538 (modified (buffer-modified-p))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
539 (name buffer-file-name)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
540 insert-end)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
541 (unwind-protect
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
542 (progn
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
543 (save-excursion
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
544 (goto-char pos)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
545 ;; defeat file locking... don't try this at home, kids!
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
546 (setq buffer-file-name nil)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
547 (insert-before-markers (gettext string))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
548 (setq insert-end (point))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
549 ;; If the message end is off frame, recenter now.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
550 (if (> (window-end) insert-end)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
551 (recenter (/ (window-height) 2)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
552 ;; If that pushed message start off the frame,
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
553 ;; scroll to start it at the top of the frame.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
554 (move-to-window-line 0)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
555 (if (> (point) pos)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
556 (progn
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
557 (goto-char pos)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
558 (recenter 0))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
559 (message (or message (gettext "Type %s to continue editing."))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
560 (single-key-description exit-char))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
561 (let ((event (save-excursion (next-command-event))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
562 (or (eq (event-to-character event) exit-char)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
563 (setq unread-command-event event))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
564 (if insert-end
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
565 (save-excursion
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
566 (delete-region pos insert-end)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
567 (setq buffer-file-name name)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
568 (set-buffer-modified-p modified))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
569
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
570 ;;; cmdloop.el ends here