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