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