0
|
1 /* Editor command loop.
|
|
2 Copyright (C) 1992, 1993, 1994 Free Software Foundation, Inc.
|
|
3 Copyright (C) 1995, 1996 Ben Wing.
|
|
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 the
|
|
9 Free Software Foundation; either version 2, or (at your option) any
|
|
10 later version.
|
|
11
|
|
12 XEmacs is distributed in the hope that it will be useful, but WITHOUT
|
|
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
15 for more details.
|
|
16
|
|
17 You should have received a copy of the GNU General Public License
|
|
18 along with XEmacs; see the file COPYING. If not, write to
|
|
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
20 Boston, MA 02111-1307, USA. */
|
|
21
|
|
22 /* Synched up with: Mule 2.0. Not synched with FSF.
|
|
23 This was renamed from keyboard.c. However, it only contains the
|
|
24 command-loop stuff from FSF's keyboard.c; all the rest is in
|
|
25 event*.c, console.c, or signal.c. */
|
|
26
|
|
27 /* #### This module purports to separate out the command-loop stuff
|
|
28 from event-stream.c, but it doesn't really. Perhaps this file
|
|
29 should just be merged into event-stream.c, given its shortness. */
|
|
30
|
|
31 #include <config.h>
|
|
32 #include "lisp.h"
|
|
33
|
|
34 #include "buffer.h"
|
|
35 #include "commands.h"
|
|
36 #include "frame.h"
|
|
37 #include "events.h"
|
|
38 #include "macros.h"
|
|
39 #include "window.h"
|
|
40
|
|
41 /* Current depth in recursive edits. */
|
|
42 int command_loop_level;
|
|
43
|
|
44 /* Total number of times command_loop has read a key sequence. */
|
|
45 int num_input_keys;
|
|
46
|
|
47 #ifndef LISP_COMMAND_LOOP
|
|
48 /* Form to evaluate (if non-nil) when Emacs is started. */
|
|
49 Lisp_Object Vtop_level;
|
|
50 #else
|
|
51 /* Function to call to evaluate to read and process events. */
|
|
52 Lisp_Object Vcommand_loop;
|
|
53 #endif /* LISP_COMMAND_LOOP */
|
|
54
|
|
55 Lisp_Object Venter_window_hook, Vleave_window_hook;
|
|
56
|
|
57 /* The error handler. */
|
|
58 Lisp_Object Qcommand_error;
|
|
59
|
|
60 /* The emergency error handler, before we're ready. */
|
|
61 Lisp_Object Qreally_early_error_handler;
|
|
62
|
|
63 static Lisp_Object command_loop_1 (Lisp_Object dummy);
|
|
64
|
|
65 /* There are two possible command loops -- one written entirely in
|
|
66 C and one written mostly in Lisp, except stuff written in C for
|
|
67 speed. The advantage of the Lisp command loop is that the user
|
|
68 can specify their own command loop to use by changing the variable
|
|
69 `command-loop'. Its disadvantage is that it's slow. */
|
|
70
|
|
71 static Lisp_Object
|
|
72 default_error_handler (Lisp_Object data)
|
|
73 {
|
|
74 int speccount = specpdl_depth ();
|
|
75
|
|
76 Fding (Qnil, Qnil, Qnil);
|
|
77 zmacs_deactivate_region ();
|
|
78 Fdiscard_input ();
|
|
79 specbind (Qinhibit_quit, Qt);
|
|
80 Vstandard_output = Qt;
|
|
81 Vstandard_input = Qt;
|
|
82 Vexecuting_macro = Qnil;
|
|
83 clear_echo_area (selected_frame (), Qnil, 0);
|
|
84 data = Fprin1_to_string (data, Qnil);
|
16
|
85 message ("Error: %s", XSTRING_DATA (data));
|
0
|
86 check_quit (); /* make Vquit_flag accurate */
|
|
87 Vquit_flag = Qnil;
|
|
88 return (unbind_to (speccount, Qt));
|
|
89 }
|
|
90
|
20
|
91 DEFUN ("really-early-error-handler", Freally_early_error_handler, 1, 1, 0, /*
|
0
|
92 You should almost certainly not be using this.
|
20
|
93 */
|
|
94 (x))
|
0
|
95 {
|
|
96 /* This is an error handler used when we're running temacs and when
|
|
97 we're in the early stages of XEmacs. No errors ought to be
|
|
98 occurring in those cases (or they ought to be trapped and
|
|
99 dealt with elsewhere), but if an error slips through, we need
|
|
100 to deal with it. We could write this function in Lisp (and it
|
|
101 used to be this way, at the beginning of loadup.el), but we do
|
|
102 it this way in case an error occurs before we get to loading
|
|
103 loadup.el. Note that there is also an `early-error-handler',
|
|
104 used in startup.el to catch more reasonable errors that
|
|
105 might occur during startup if the sysadmin or whoever fucked
|
|
106 up. This function is more conservative in what it does
|
|
107 and is used only as a last resort, indicating that the
|
|
108 programmer himself fucked up somewhere. */
|
|
109 stderr_out ("*** Error in XEmacs initialization");
|
|
110 Fprint (x, Qexternal_debugging_output);
|
|
111 stderr_out ("*** Backtrace\n");
|
|
112 Fbacktrace (Qexternal_debugging_output, Qt);
|
|
113 stderr_out ("*** Killing XEmacs\n");
|
|
114 return Fkill_emacs (make_int (-1));
|
|
115 }
|
|
116
|
|
117
|
|
118 /**********************************************************************/
|
|
119 /* Command-loop (in C) */
|
|
120 /**********************************************************************/
|
|
121
|
|
122 #ifndef LISP_COMMAND_LOOP
|
|
123
|
|
124 /* The guts of the command loop are in command_loop_1(). This function
|
|
125 doesn't catch errors, though -- that's the job of command_loop_2(),
|
|
126 which is a condition-case wrapper around command_loop_1().
|
|
127 command_loop_1() never returns, but may get thrown out of.
|
|
128
|
|
129 When an error occurs, cmd_error() is called, which usually
|
|
130 invokes the Lisp error handler in `command-error'; however,
|
|
131 a default error handler is provided if `command-error' is nil
|
|
132 (e.g. during startup). The purpose of the error handler is
|
|
133 simply to display the error message and do associated cleanup;
|
|
134 it does not need to throw anywhere. When the error handler
|
|
135 finishes, the condition-case in command_loop_2() will finish and
|
|
136 command_loop_2() will reinvoke command_loop_1().
|
|
137
|
|
138 command_loop_2() is invoked from three places: from
|
|
139 initial_command_loop() (called from main() at the end of
|
|
140 internal initialization), from the Lisp function `recursive-edit',
|
|
141 and from call_command_loop().
|
|
142
|
|
143 call_command_loop() is called when a macro is started and when the
|
|
144 minibuffer is entered; normal termination of the macro or
|
|
145 minibuffer causes a throw out of the recursive command loop. (To
|
|
146 'execute-kbd-macro for macros and 'exit for minibuffers. Note also
|
|
147 that the low-level minibuffer-entering function,
|
|
148 `read-minibuffer-internal', provides its own error handling and
|
|
149 does not need command_loop_2()'s error encapsulation; so it tells
|
|
150 call_command_loop() to invoke command_loop_1() directly.)
|
|
151
|
|
152 Note that both read-minibuffer-internal and recursive-edit set
|
|
153 up a catch for 'exit; this is why `abort-recursive-edit', which
|
|
154 throws to this catch, exits out of either one.
|
|
155
|
|
156 initial_command_loop(), called from main(), sets up a catch
|
|
157 for 'top-level when invoking command_loop_2(), allowing functions
|
|
158 to throw all the way to the top level if they really need to.
|
|
159 Before invoking command_loop_2(), initial_command_loop() calls
|
|
160 top_level_1(), which handles all of the startup stuff (creating
|
|
161 the initial frame, handling the command-line options, loading
|
|
162 the user's .emacs file, etc.). The function that actually does this
|
|
163 is in Lisp and is pointed to by the variable `top-level';
|
|
164 normally this function is `normal-top-level'. top_level_1() is
|
|
165 just an error-handling wrapper similar to command_loop_2().
|
|
166 Note also that initial_command_loop() sets up a catch for 'top-level
|
|
167 when invoking top_level_1(), just like when it invokes
|
|
168 command_loop_2(). */
|
|
169
|
|
170
|
|
171 static Lisp_Object
|
|
172 cmd_error (Lisp_Object data, Lisp_Object dummy)
|
|
173 {
|
|
174 /* This function can GC */
|
|
175 check_quit (); /* make Vquit_flag accurate */
|
|
176 Vquit_flag = Qnil;
|
|
177
|
|
178 any_console_state ();
|
|
179
|
|
180 if (!NILP (Ffboundp (Qcommand_error)))
|
|
181 return call1 (Qcommand_error, data);
|
|
182
|
|
183 return default_error_handler (data);
|
|
184 }
|
|
185
|
|
186 static Lisp_Object
|
|
187 top_level_1 (Lisp_Object dummy)
|
|
188 {
|
|
189 /* This function can GC */
|
|
190 /* On entry to the outer level, run the startup file */
|
|
191 if (!NILP (Vtop_level))
|
|
192 condition_case_1 (Qerror, Feval, Vtop_level, cmd_error, Qnil);
|
|
193 #if 1
|
|
194 else
|
|
195 {
|
|
196 message ("\ntemacs can only be run in -batch mode.");
|
|
197 noninteractive = 1; /* prevent things under kill-emacs from blowing up */
|
|
198 Fkill_emacs (make_int (-1));
|
|
199 }
|
|
200 #else
|
|
201 else if (purify_flag)
|
|
202 message ("Bare impure Emacs (standard Lisp code not loaded)");
|
|
203 else
|
|
204 message ("Bare Emacs (standard Lisp code not loaded)");
|
|
205 #endif
|
|
206
|
|
207 return Qnil;
|
|
208 }
|
|
209
|
|
210 /* Here we catch errors in execution of commands within the
|
|
211 editing loop, and reenter the editing loop.
|
|
212 When there is an error, cmd_error runs and the call
|
|
213 to condition_case_1() returns. */
|
|
214
|
|
215 /* Avoid confusing the compiler. A helper function for command_loop_2 */
|
|
216 static DOESNT_RETURN
|
|
217 command_loop_3 (void)
|
|
218 {
|
138
|
219 #ifdef LWLIB_MENUBARS_LUCID
|
|
220 extern int in_menu_callback; /* defined in menubar-x.c */
|
|
221 #endif /* LWLIB_MENUBARS_LUCID */
|
|
222
|
|
223 #ifdef LWLIB_MENUBARS_LUCID
|
|
224 /*
|
|
225 * #### Fix the menu code so this isn't necessary.
|
|
226 *
|
|
227 * We cannot allow the lwmenu code to be reentered, because the
|
|
228 * code is not written to be reentrant and will crash. Therefore
|
|
229 * paths from the menu callbacks back into the menu code have to
|
|
230 * be blocked. Fnext_event is the normal path into the menu code,
|
|
231 * but waiting to signal an error there is too late in case where
|
|
232 * a new command loop has been started. The error will be caught
|
|
233 * and Fnext_event will be called again, looping forever. So we
|
|
234 * signal an error here to avoid the loop.
|
|
235 */
|
|
236 if (in_menu_callback)
|
|
237 error ("Attempt to enter command_loop_3 inside menu callback");
|
|
238 #endif /* LWLIB_MENUBARS_LUCID */
|
0
|
239 /* This function can GC */
|
|
240 for (;;)
|
|
241 {
|
|
242 condition_case_1 (Qerror, command_loop_1, Qnil, cmd_error, Qnil);
|
|
243 /* #### wrong with selected-console? */
|
|
244 /* See command in initial_command_loop about why this value
|
|
245 is 0. */
|
|
246 reset_this_command_keys (Vselected_console, 0);
|
|
247 }
|
|
248 }
|
|
249
|
|
250 static Lisp_Object
|
|
251 command_loop_2 (Lisp_Object dummy)
|
|
252 {
|
|
253 command_loop_3(); /* doesn't return */
|
|
254 return Qnil;
|
|
255 }
|
|
256
|
|
257 /* This is called from emacs.c when it's done with initialization. */
|
|
258
|
|
259 DOESNT_RETURN
|
|
260 initial_command_loop (Lisp_Object load_me)
|
|
261 {
|
|
262 /* This function can GC */
|
|
263 if (!NILP (load_me))
|
|
264 Vtop_level = list2 (Qload, load_me);
|
|
265
|
|
266 /* First deal with startup and command-line arguments. A throw
|
|
267 to 'top-level gets us back here directly (does this ever happen?).
|
|
268 Otherwise, this function will return normally when all command-
|
|
269 line arguments have been processed, the user's initialization
|
|
270 file has been read in, and the first frame has been created. */
|
|
271 internal_catch (Qtop_level, top_level_1, Qnil, 0);
|
|
272
|
|
273 /* If an error occurred during startup and the initial console
|
|
274 wasn't created, then die now (the error was already printed out
|
|
275 on the terminal device). */
|
|
276 if (!noninteractive &&
|
|
277 (!CONSOLEP (Vselected_console) ||
|
|
278 CONSOLE_STREAM_P (XCONSOLE (Vselected_console))))
|
|
279 Fkill_emacs (make_int (-1));
|
185
|
280
|
0
|
281 /* End of -batch run causes exit here. */
|
|
282 if (noninteractive)
|
|
283 Fkill_emacs (Qt);
|
|
284
|
|
285 for (;;)
|
|
286 {
|
|
287 command_loop_level = 0;
|
|
288 MARK_MODELINE_CHANGED;
|
|
289 /* Now invoke the command loop. It never returns; however, a
|
|
290 throw to 'top-level will place us at the end of this loop. */
|
|
291 internal_catch (Qtop_level, command_loop_2, Qnil, 0);
|
|
292 /* #### wrong with selected-console? */
|
|
293 /* We don't actually call clear_echo_area() here, partially
|
|
294 at least because that runs Lisp code and it may be unsafe
|
|
295 to do so -- we are outside of the normal catches for
|
|
296 errors and such. */
|
|
297 reset_this_command_keys (Vselected_console, 0);
|
|
298 }
|
|
299 }
|
|
300
|
|
301 /* This function is invoked when a macro or minibuffer starts up.
|
|
302 Normal termination of the macro or minibuffer causes a throw past us.
|
|
303 See the comment above.
|
|
304
|
|
305 Note that this function never returns (but may be thrown out of). */
|
|
306
|
|
307 Lisp_Object
|
|
308 call_command_loop (Lisp_Object catch_errors)
|
|
309 {
|
|
310 /* This function can GC */
|
|
311 if (NILP (catch_errors))
|
|
312 return (command_loop_1 (Qnil));
|
|
313 else
|
|
314 return (command_loop_2 (Qnil));
|
|
315 }
|
|
316
|
|
317 static Lisp_Object
|
|
318 recursive_edit_unwind (Lisp_Object buffer)
|
|
319 {
|
|
320 if (!NILP (buffer))
|
|
321 Fset_buffer (buffer);
|
|
322
|
|
323 command_loop_level--;
|
|
324 MARK_MODELINE_CHANGED;
|
|
325
|
|
326 return Qnil;
|
|
327 }
|
|
328
|
20
|
329 DEFUN ("recursive-edit", Frecursive_edit, 0, 0, "", /*
|
0
|
330 Invoke the editor command loop recursively.
|
|
331 To get out of the recursive edit, a command can do `(throw 'exit nil)';
|
|
332 that tells this function to return.
|
|
333 Alternately, `(throw 'exit t)' makes this function signal an error.
|
20
|
334 */
|
|
335 ())
|
0
|
336 {
|
|
337 /* This function can GC */
|
|
338 Lisp_Object val;
|
|
339 int speccount = specpdl_depth ();
|
|
340
|
|
341 command_loop_level++;
|
|
342 MARK_MODELINE_CHANGED;
|
|
343
|
|
344 record_unwind_protect (recursive_edit_unwind,
|
|
345 ((current_buffer
|
|
346 != XBUFFER (XWINDOW (Fselected_window
|
|
347 (Qnil))->buffer))
|
|
348 ? Fcurrent_buffer ()
|
|
349 : Qnil));
|
|
350
|
|
351 specbind (Qstandard_output, Qt);
|
|
352 specbind (Qstandard_input, Qt);
|
|
353
|
|
354 val = internal_catch (Qexit, command_loop_2, Qnil, 0);
|
|
355
|
|
356 if (EQ (val, Qt))
|
|
357 /* Turn abort-recursive-edit into a quit. */
|
|
358 Fsignal (Qquit, Qnil);
|
|
359
|
|
360 return unbind_to (speccount, Qnil);
|
|
361 }
|
|
362
|
|
363 #endif /* !LISP_COMMAND_LOOP */
|
|
364
|
|
365
|
|
366 /**********************************************************************/
|
|
367 /* Alternate command-loop (largely in Lisp) */
|
|
368 /**********************************************************************/
|
|
369
|
|
370 #ifdef LISP_COMMAND_LOOP
|
|
371
|
|
372 static Lisp_Object
|
|
373 load1 (Lisp_Object name)
|
|
374 {
|
|
375 /* This function can GC */
|
|
376 call4 (Qload, name, Qnil, Qt, Qnil);
|
|
377 return (Qnil);
|
|
378 }
|
|
379
|
|
380 /* emergency backups for cold-load-stream use */
|
|
381 static Lisp_Object
|
|
382 cold_load_command_error (Lisp_Object datum, Lisp_Object ignored)
|
|
383 {
|
|
384 /* This function can GC */
|
|
385 check_quit (); /* make Vquit_flag accurate */
|
|
386 Vquit_flag = Qnil;
|
|
387
|
|
388 return default_error_handler (datum);
|
|
389 }
|
|
390
|
|
391 static Lisp_Object
|
|
392 cold_load_command_loop (Lisp_Object dummy)
|
|
393 {
|
|
394 /* This function can GC */
|
|
395 return (condition_case_1 (Qt,
|
|
396 command_loop_1, Qnil,
|
|
397 cold_load_command_error, Qnil));
|
|
398 }
|
|
399
|
|
400 Lisp_Object
|
|
401 call_command_loop (Lisp_Object catch_errors)
|
|
402 {
|
|
403 /* This function can GC */
|
|
404 reset_this_command_keys (Vselected_console, Qnil); /* #### bleagh */
|
|
405
|
|
406 loop:
|
|
407 for (;;)
|
|
408 {
|
|
409 if (NILP (Vcommand_loop))
|
|
410 break;
|
|
411 call1 (Vcommand_loop, catch_errors);
|
|
412 }
|
|
413
|
|
414 /* This isn't a "correct" definition, but you're pretty hosed if
|
|
415 you broke "command-loop" anyway */
|
|
416 /* #### not correct with Vselected_console */
|
|
417 XCONSOLE (Vselected_console)->prefix_arg = Qnil;
|
|
418 if (NILP (catch_errors))
|
|
419 Fcommand_loop_1 ();
|
185
|
420 else
|
0
|
421 internal_catch (Qtop_level,
|
|
422 cold_load_command_loop, Qnil, 0);
|
|
423 goto loop;
|
|
424 return Qnil;
|
|
425 }
|
|
426
|
|
427 static Lisp_Object
|
|
428 initial_error_handler (Lisp_Object datum, Lisp_Object ignored)
|
|
429 {
|
|
430 /* This function can GC */
|
|
431 Vcommand_loop = Qnil;
|
|
432 Fding (Qnil, Qnil, Qnil);
|
|
433
|
|
434 if (CONSP (datum) && EQ (XCAR (datum), Qquit))
|
|
435 /* Don't bother with the message */
|
|
436 return (Qt);
|
185
|
437
|
0
|
438 message ("Error in command-loop!!");
|
|
439 Fset (intern ("last-error"), datum); /* #### Better/different name? */
|
|
440 Fsit_for (make_int (2), Qnil);
|
|
441 cold_load_command_error (datum, Qnil);
|
|
442 return (Qt);
|
|
443 }
|
|
444
|
|
445 DOESNT_RETURN
|
|
446 initial_command_loop (Lisp_Object load_me)
|
|
447 {
|
|
448 /* This function can GC */
|
|
449 if (!NILP (load_me))
|
|
450 {
|
|
451 if (!NILP (condition_case_1 (Qt, load1, load_me,
|
|
452 initial_error_handler, Qnil)))
|
|
453 Fkill_emacs (make_int (-1));
|
|
454 }
|
|
455
|
|
456 for (;;)
|
|
457 {
|
|
458 command_loop_level = 0;
|
|
459 MARK_MODELINE_CHANGED;
|
|
460
|
|
461 condition_case_1 (Qt,
|
|
462 call_command_loop, Qtop_level,
|
|
463 initial_error_handler, Qnil);
|
|
464 }
|
|
465 }
|
|
466
|
|
467 #endif /* LISP_COMMAND_LOOP */
|
|
468
|
|
469
|
|
470 /**********************************************************************/
|
|
471 /* Guts of command loop */
|
|
472 /**********************************************************************/
|
|
473
|
|
474 static Lisp_Object
|
|
475 command_loop_1 (Lisp_Object dummy)
|
|
476 {
|
|
477 /* This function can GC */
|
|
478 /* #### not correct with Vselected_console */
|
|
479 XCONSOLE (Vselected_console)->prefix_arg = Qnil;
|
|
480 return (Fcommand_loop_1 ());
|
|
481 }
|
|
482
|
|
483 /* This is the actual command reading loop, sans error-handling
|
|
484 encapsulation. This is used for both the C and Lisp command
|
|
485 loops. Originally this function was written in Lisp when
|
|
486 the Lisp command loop was used, but it was too slow that way.
|
|
487
|
|
488 Under the C command loop, this function will never return
|
|
489 (although someone might throw past it). Under the Lisp
|
|
490 command loop, this will return only when the user specifies
|
|
491 a new command loop by changing the command-loop variable. */
|
|
492
|
20
|
493 DEFUN ("command-loop-1", Fcommand_loop_1, 0, 0, 0, /*
|
0
|
494 Invoke the internals of the canonical editor command loop.
|
|
495 Don't call this unless you know what you're doing.
|
20
|
496 */
|
|
497 ())
|
0
|
498 {
|
|
499 /* This function can GC */
|
|
500 Lisp_Object event = Fmake_event ();
|
|
501 Lisp_Object old_loop = Qnil;
|
|
502 struct gcpro gcpro1, gcpro2;
|
|
503 int was_locked = in_single_console_state ();
|
|
504 GCPRO2 (event, old_loop);
|
|
505
|
|
506 /* cancel_echoing (); */
|
|
507 /* This magically makes single character keyboard macros work just
|
|
508 like the real thing. This is slightly bogus, but it's in here for
|
|
509 compatibility with Emacs 18. It's not even clear what the "right
|
|
510 thing" is. */
|
|
511 if (!(((STRINGP (Vexecuting_macro) || VECTORP (Vexecuting_macro))
|
|
512 && XINT (Flength (Vexecuting_macro)) == 1)))
|
|
513 Vlast_command = Qt;
|
|
514
|
|
515 #ifndef LISP_COMMAND_LOOP
|
|
516 while (1)
|
|
517 #else
|
|
518 old_loop = Vcommand_loop;
|
|
519 while (EQ (Vcommand_loop, old_loop))
|
|
520 #endif /* LISP_COMMAND_LOOP */
|
|
521 {
|
|
522 /* Make sure the current window's buffer is selected. */
|
|
523 {
|
|
524 Lisp_Object selected_window = Fselected_window (Qnil);
|
|
525
|
|
526 if (!NILP (selected_window) &&
|
|
527 (XBUFFER (XWINDOW (selected_window)->buffer) != current_buffer))
|
|
528 {
|
|
529 set_buffer_internal (XBUFFER (XWINDOW (selected_window)->buffer));
|
|
530 }
|
|
531 }
|
|
532
|
|
533 /* If ^G was typed before we got here (that is, before emacs was
|
|
534 idle and waiting for input) then we treat that as an interrupt. */
|
|
535 QUIT;
|
|
536
|
|
537 /* If minibuffer on and echo area in use, wait 2 sec and redraw
|
|
538 minibuffer. Treat a ^G here as a command, not an interrupt.
|
|
539 */
|
|
540 if (minibuf_level > 0 && echo_area_active (selected_frame ()))
|
|
541 {
|
|
542 /* Bind dont_check_for_quit to 1 so that C-g gets read in
|
|
543 rather than quitting back to the minibuffer. */
|
|
544 int count = specpdl_depth ();
|
|
545 begin_dont_check_for_quit ();
|
|
546 Fsit_for (make_int (2), Qnil);
|
|
547 clear_echo_area (selected_frame (), Qnil, 0);
|
|
548 unbind_to (count, Qnil);
|
|
549 }
|
|
550
|
|
551 Fnext_event (event, Qnil);
|
|
552 /* If ^G was typed while emacs was reading input from the user, then
|
|
553 Fnext_event() will have read it as a normal event and
|
|
554 next_event_internal() will have set Vquit_flag. We reset this
|
|
555 so that the ^G is treated as just another key. This is strange,
|
|
556 but it is what emacs 18 did.
|
|
557
|
|
558 Do not call check_quit() here. */
|
|
559 Vquit_flag = Qnil;
|
|
560 Fdispatch_event (event);
|
|
561
|
|
562 if (!was_locked)
|
|
563 any_console_state ();
|
185
|
564 #if defined (__SUNPRO_C) || defined (__SUNPRO_CC) || (defined (DEC_ALPHA) && defined (OSF1))
|
0
|
565 if (0) return Qnil; /* Shut up compiler */
|
|
566 #endif
|
|
567 }
|
|
568 #ifdef LISP_COMMAND_LOOP
|
|
569 UNGCPRO;
|
|
570 return Qnil;
|
|
571 #endif
|
|
572 }
|
|
573
|
|
574
|
|
575 /**********************************************************************/
|
|
576 /* Initialization */
|
|
577 /**********************************************************************/
|
|
578
|
|
579 void
|
|
580 syms_of_cmdloop (void)
|
|
581 {
|
|
582 defsymbol (&Qcommand_error, "command-error");
|
|
583 defsymbol (&Qreally_early_error_handler, "really-early-error-handler");
|
|
584 defsymbol (&Qtop_level, "top-level");
|
|
585
|
|
586 #ifndef LISP_COMMAND_LOOP
|
20
|
587 DEFSUBR (Frecursive_edit);
|
0
|
588 #endif
|
20
|
589 DEFSUBR (Freally_early_error_handler);
|
|
590 DEFSUBR (Fcommand_loop_1);
|
0
|
591 }
|
|
592
|
|
593 void
|
|
594 vars_of_cmdloop (void)
|
|
595 {
|
|
596 DEFVAR_INT ("command-loop-level", &command_loop_level /*
|
|
597 Number of recursive edits in progress.
|
|
598 */ );
|
|
599 command_loop_level = 0;
|
|
600
|
|
601 DEFVAR_LISP ("disabled-command-hook", &Vdisabled_command_hook /*
|
|
602 Value is called instead of any command that is disabled,
|
|
603 i.e. has a non-nil `disabled' property.
|
|
604 */ );
|
|
605 Vdisabled_command_hook = intern ("disabled-command-hook");
|
|
606
|
|
607 DEFVAR_LISP ("leave-window-hook", &Vleave_window_hook /*
|
|
608 Not yet implemented.
|
|
609 */ );
|
|
610 Vleave_window_hook = Qnil;
|
|
611
|
|
612 DEFVAR_LISP ("enter-window-hook", &Venter_window_hook /*
|
|
613 Not yet implemented.
|
|
614 */ );
|
|
615 Venter_window_hook = Qnil;
|
|
616
|
|
617 #ifndef LISP_COMMAND_LOOP
|
|
618 DEFVAR_LISP ("top-level", &Vtop_level /*
|
|
619 Form to evaluate when Emacs starts up.
|
|
620 Useful to set before you dump a modified Emacs.
|
|
621 */ );
|
|
622 Vtop_level = Qnil;
|
|
623 #else
|
|
624 DEFVAR_LISP ("command-loop", &Vcommand_loop /*
|
|
625 Function or one argument to call to read and process keyboard commands.
|
|
626 The passed argument specifies whether or not to handle errors.
|
|
627 */ );
|
|
628 Vcommand_loop = Qnil;
|
|
629 #endif /* LISP_COMMAND_LOOP */
|
|
630 }
|