Mercurial > emacs
comparison src/keyboard.c @ 90533:8a8e69664178
Merge from emacs--devo--0
Patches applied:
* emacs--devo--0 (patch 343-356)
- Update from CVS
- Update for ERC 5.1.3.
- Merge from gnus--rel--5.10
* gnus--rel--5.10 (patch 113-115)
- Merge from emacs--devo--0
- Update from CVS
Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-90
author | Miles Bader <miles@gnu.org> |
---|---|
date | Wed, 19 Jul 2006 00:42:56 +0000 |
parents | 146cd8369025 802436ff7a47 |
children | 858cb33ae39d |
comparison
equal
deleted
inserted
replaced
90532:e22cf6d2400c | 90533:8a8e69664178 |
---|---|
240 static int inhibit_local_menu_bar_menus; | 240 static int inhibit_local_menu_bar_menus; |
241 | 241 |
242 /* Nonzero means C-g should cause immediate error-signal. */ | 242 /* Nonzero means C-g should cause immediate error-signal. */ |
243 int immediate_quit; | 243 int immediate_quit; |
244 | 244 |
245 /* The user's hook function for outputting an error message. */ | |
246 Lisp_Object Vcommand_error_function; | |
247 | |
245 /* The user's ERASE setting. */ | 248 /* The user's ERASE setting. */ |
246 Lisp_Object Vtty_erase_char; | 249 Lisp_Object Vtty_erase_char; |
247 | 250 |
248 /* Character to recognize as the help char. */ | 251 /* Character to recognize as the help char. */ |
249 Lisp_Object Vhelp_char; | 252 Lisp_Object Vhelp_char; |
1001 if (EQ (val, Qt)) | 1004 if (EQ (val, Qt)) |
1002 Fsignal (Qquit, Qnil); | 1005 Fsignal (Qquit, Qnil); |
1003 /* Handle throw from read_minibuf when using minibuffer | 1006 /* Handle throw from read_minibuf when using minibuffer |
1004 while it's active but we're in another window. */ | 1007 while it's active but we're in another window. */ |
1005 if (STRINGP (val)) | 1008 if (STRINGP (val)) |
1006 Fsignal (Qerror, Fcons (val, Qnil)); | 1009 xsignal1 (Qerror, val); |
1007 | 1010 |
1008 return unbind_to (count, Qnil); | 1011 return unbind_to (count, Qnil); |
1009 } | 1012 } |
1010 | 1013 |
1011 /* When an auto-save happens, record the "time", and don't do again soon. */ | 1014 /* When an auto-save happens, record the "time", and don't do again soon. */ |
1228 void | 1231 void |
1229 cmd_error_internal (data, context) | 1232 cmd_error_internal (data, context) |
1230 Lisp_Object data; | 1233 Lisp_Object data; |
1231 char *context; | 1234 char *context; |
1232 { | 1235 { |
1233 Lisp_Object stream; | |
1234 int kill_emacs_p = 0; | |
1235 struct frame *sf = SELECTED_FRAME (); | 1236 struct frame *sf = SELECTED_FRAME (); |
1236 | |
1237 Vquit_flag = Qnil; | |
1238 Vinhibit_quit = Qt; | |
1239 clear_message (1, 0); | |
1240 | |
1241 /* If the window system or terminal frame hasn't been initialized | |
1242 yet, or we're not interactive, it's best to dump this message out | |
1243 to stderr and exit. */ | |
1244 if (!sf->glyphs_initialized_p | |
1245 /* This is the case of the frame dumped with Emacs, when we're | |
1246 running under a window system. */ | |
1247 || (!NILP (Vwindow_system) | |
1248 && !inhibit_window_system | |
1249 && FRAME_TERMCAP_P (sf)) | |
1250 || noninteractive) | |
1251 { | |
1252 stream = Qexternal_debugging_output; | |
1253 kill_emacs_p = 1; | |
1254 } | |
1255 else | |
1256 { | |
1257 Fdiscard_input (); | |
1258 message_log_maybe_newline (); | |
1259 bitch_at_user (); | |
1260 stream = Qt; | |
1261 } | |
1262 | 1237 |
1263 /* The immediate context is not interesting for Quits, | 1238 /* The immediate context is not interesting for Quits, |
1264 since they are asyncronous. */ | 1239 since they are asyncronous. */ |
1265 if (EQ (XCAR (data), Qquit)) | 1240 if (EQ (XCAR (data), Qquit)) |
1266 Vsignaling_function = Qnil; | 1241 Vsignaling_function = Qnil; |
1267 | 1242 |
1268 print_error_message (data, stream, context, Vsignaling_function); | 1243 Vquit_flag = Qnil; |
1244 Vinhibit_quit = Qt; | |
1245 | |
1246 /* Use user's specified output function if any. */ | |
1247 if (!NILP (Vcommand_error_function)) | |
1248 call3 (Vcommand_error_function, data, | |
1249 build_string (context ? context : ""), | |
1250 Vsignaling_function); | |
1251 /* If the window system or terminal frame hasn't been initialized | |
1252 yet, or we're not interactive, write the message to stderr and exit. */ | |
1253 else if (!sf->glyphs_initialized_p | |
1254 /* This is the case of the frame dumped with Emacs, when we're | |
1255 running under a window system. */ | |
1256 || (!NILP (Vwindow_system) | |
1257 && !inhibit_window_system | |
1258 && FRAME_TERMCAP_P (sf)) | |
1259 || noninteractive) | |
1260 { | |
1261 print_error_message (data, Qexternal_debugging_output, | |
1262 context, Vsignaling_function); | |
1263 Fterpri (Qexternal_debugging_output); | |
1264 Fkill_emacs (make_number (-1)); | |
1265 } | |
1266 else | |
1267 { | |
1268 clear_message (1, 0); | |
1269 Fdiscard_input (); | |
1270 message_log_maybe_newline (); | |
1271 bitch_at_user (); | |
1272 | |
1273 print_error_message (data, Qt, context, Vsignaling_function); | |
1274 } | |
1269 | 1275 |
1270 Vsignaling_function = Qnil; | 1276 Vsignaling_function = Qnil; |
1271 | |
1272 /* If the window system or terminal frame hasn't been initialized | |
1273 yet, or we're in -batch mode, this error should cause Emacs to exit. */ | |
1274 if (kill_emacs_p) | |
1275 { | |
1276 Fterpri (stream); | |
1277 Fkill_emacs (make_number (-1)); | |
1278 } | |
1279 } | 1277 } |
1280 | 1278 |
1281 Lisp_Object command_loop_1 (); | 1279 Lisp_Object command_loop_1 (); |
1282 Lisp_Object command_loop_2 (); | 1280 Lisp_Object command_loop_2 (); |
1283 Lisp_Object top_level_1 (); | 1281 Lisp_Object top_level_1 (); |
1488 /* Bind inhibit-quit to t so that C-g gets read in | 1486 /* Bind inhibit-quit to t so that C-g gets read in |
1489 rather than quitting back to the minibuffer. */ | 1487 rather than quitting back to the minibuffer. */ |
1490 int count = SPECPDL_INDEX (); | 1488 int count = SPECPDL_INDEX (); |
1491 specbind (Qinhibit_quit, Qt); | 1489 specbind (Qinhibit_quit, Qt); |
1492 | 1490 |
1493 Fsit_for (Vminibuffer_message_timeout, Qnil, Qnil); | 1491 sit_for (Vminibuffer_message_timeout, 0, 2); |
1492 | |
1494 /* Clear the echo area. */ | 1493 /* Clear the echo area. */ |
1495 message2 (0, 0, 0); | 1494 message2 (0, 0, 0); |
1496 safe_run_hooks (Qecho_area_clear_hook); | 1495 safe_run_hooks (Qecho_area_clear_hook); |
1497 | 1496 |
1498 unbind_to (count, Qnil); | 1497 unbind_to (count, Qnil); |
2687 /* Or already echoing from same kboard. */ | 2686 /* Or already echoing from same kboard. */ |
2688 || (echo_kboard && ok_to_echo_at_next_pause == echo_kboard) | 2687 || (echo_kboard && ok_to_echo_at_next_pause == echo_kboard) |
2689 /* Or not echoing before and echoing allowed. */ | 2688 /* Or not echoing before and echoing allowed. */ |
2690 || (!echo_kboard && ok_to_echo_at_next_pause))) | 2689 || (!echo_kboard && ok_to_echo_at_next_pause))) |
2691 { | 2690 { |
2692 Lisp_Object tem0; | |
2693 | |
2694 /* After a mouse event, start echoing right away. | 2691 /* After a mouse event, start echoing right away. |
2695 This is because we are probably about to display a menu, | 2692 This is because we are probably about to display a menu, |
2696 and we don't want to delay before doing so. */ | 2693 and we don't want to delay before doing so. */ |
2697 if (EVENT_HAS_PARAMETERS (prev_event)) | 2694 if (EVENT_HAS_PARAMETERS (prev_event)) |
2698 echo_now (); | 2695 echo_now (); |
2699 else | 2696 else |
2700 { | 2697 { |
2701 int sec, usec; | 2698 Lisp_Object tem0; |
2702 double duration = extract_float (Vecho_keystrokes); | 2699 |
2703 sec = (int) duration; | |
2704 usec = (duration - sec) * 1000000; | |
2705 save_getcjmp (save_jump); | 2700 save_getcjmp (save_jump); |
2706 restore_getcjmp (local_getcjmp); | 2701 restore_getcjmp (local_getcjmp); |
2707 tem0 = sit_for (sec, usec, 1, 1, 0); | 2702 tem0 = sit_for (Vecho_keystrokes, 1, 1); |
2708 restore_getcjmp (save_jump); | 2703 restore_getcjmp (save_jump); |
2709 if (EQ (tem0, Qt) | 2704 if (EQ (tem0, Qt) |
2710 && ! CONSP (Vunread_command_events)) | 2705 && ! CONSP (Vunread_command_events)) |
2711 echo_now (); | 2706 echo_now (); |
2712 } | 2707 } |
2769 && num_nonmacro_input_events > last_auto_save | 2764 && num_nonmacro_input_events > last_auto_save |
2770 && INTEGERP (Vauto_save_timeout) | 2765 && INTEGERP (Vauto_save_timeout) |
2771 && XINT (Vauto_save_timeout) > 0) | 2766 && XINT (Vauto_save_timeout) > 0) |
2772 { | 2767 { |
2773 Lisp_Object tem0; | 2768 Lisp_Object tem0; |
2769 int timeout = delay_level * XFASTINT (Vauto_save_timeout) / 4; | |
2774 | 2770 |
2775 save_getcjmp (save_jump); | 2771 save_getcjmp (save_jump); |
2776 restore_getcjmp (local_getcjmp); | 2772 restore_getcjmp (local_getcjmp); |
2777 tem0 = sit_for (delay_level * XFASTINT (Vauto_save_timeout) / 4, | 2773 tem0 = sit_for (make_number (timeout), 1, 1); |
2778 0, 1, 1, 0); | |
2779 restore_getcjmp (save_jump); | 2774 restore_getcjmp (save_jump); |
2780 | 2775 |
2781 if (EQ (tem0, Qt) | 2776 if (EQ (tem0, Qt) |
2782 && ! CONSP (Vunread_command_events)) | 2777 && ! CONSP (Vunread_command_events)) |
2783 { | 2778 { |
8385 do_autoload (XSYMBOL (next)->function, next); | 8380 do_autoload (XSYMBOL (next)->function, next); |
8386 | 8381 |
8387 /* Handle a symbol whose function definition is a keymap | 8382 /* Handle a symbol whose function definition is a keymap |
8388 or an array. */ | 8383 or an array. */ |
8389 if (SYMBOLP (next) && !NILP (Ffboundp (next)) | 8384 if (SYMBOLP (next) && !NILP (Ffboundp (next)) |
8390 && (!NILP (Farrayp (XSYMBOL (next)->function)) | 8385 && (ARRAYP (XSYMBOL (next)->function) |
8391 || KEYMAPP (XSYMBOL (next)->function))) | 8386 || KEYMAPP (XSYMBOL (next)->function))) |
8392 next = XSYMBOL (next)->function; | 8387 next = XSYMBOL (next)->function; |
8393 | 8388 |
8394 /* If the keymap gives a function, not an | 8389 /* If the keymap gives a function, not an |
8395 array, then call the function with one arg and use | 8390 array, then call the function with one arg and use |
9765 | 9760 |
9766 | 9761 |
9767 | 9762 |
9768 DEFUN ("execute-extended-command", Fexecute_extended_command, Sexecute_extended_command, | 9763 DEFUN ("execute-extended-command", Fexecute_extended_command, Sexecute_extended_command, |
9769 1, 1, "P", | 9764 1, 1, "P", |
9770 doc: /* Read function name, then read its arguments and call it. */) | 9765 doc: /* Read function name, then read its arguments and call it. |
9766 | |
9767 To pass a numeric argument to the command you are invoking with, specify | |
9768 the numeric argument to this command. | |
9769 | |
9770 Noninteractively, the argument PREFIXARG is the prefix argument to | |
9771 give to the command you invoke, if it asks for an argument. */) | |
9771 (prefixarg) | 9772 (prefixarg) |
9772 Lisp_Object prefixarg; | 9773 Lisp_Object prefixarg; |
9773 { | 9774 { |
9774 Lisp_Object function; | 9775 Lisp_Object function; |
9775 char buf[40]; | 9776 char buf[40]; |
9871 if (!NILP (bindings) | 9872 if (!NILP (bindings) |
9872 && ! (VECTORP (bindings) && EQ (Faref (bindings, make_number (0)), | 9873 && ! (VECTORP (bindings) && EQ (Faref (bindings, make_number (0)), |
9873 Qmouse_movement))) | 9874 Qmouse_movement))) |
9874 { | 9875 { |
9875 /* But first wait, and skip the message if there is input. */ | 9876 /* But first wait, and skip the message if there is input. */ |
9876 int delay_time; | 9877 Lisp_Object waited; |
9877 if (!NILP (echo_area_buffer[0])) | 9878 |
9878 /* This command displayed something in the echo area; | 9879 /* If this command displayed something in the echo area; |
9879 so wait a few seconds, then display our suggestion message. */ | 9880 wait a few seconds, then display our suggestion message. */ |
9880 delay_time = (NUMBERP (Vsuggest_key_bindings) | 9881 if (NILP (echo_area_buffer[0])) |
9881 ? XINT (Vsuggest_key_bindings) : 2); | 9882 waited = sit_for (make_number (0), 0, 2); |
9883 else if (NUMBERP (Vsuggest_key_bindings)) | |
9884 waited = sit_for (Vminibuffer_message_timeout, 0, 2); | |
9882 else | 9885 else |
9883 /* This command left the echo area empty, | 9886 waited = sit_for (make_number (2), 0, 2); |
9884 so display our message immediately. */ | 9887 |
9885 delay_time = 0; | 9888 if (!NILP (waited) && ! CONSP (Vunread_command_events)) |
9886 | |
9887 if (!NILP (Fsit_for (make_number (delay_time), Qnil, Qnil)) | |
9888 && ! CONSP (Vunread_command_events)) | |
9889 { | 9889 { |
9890 Lisp_Object binding; | 9890 Lisp_Object binding; |
9891 char *newmessage; | 9891 char *newmessage; |
9892 int message_p = push_message (); | 9892 int message_p = push_message (); |
9893 int count = SPECPDL_INDEX (); | 9893 int count = SPECPDL_INDEX (); |
9903 SDATA (SYMBOL_NAME (function)), | 9903 SDATA (SYMBOL_NAME (function)), |
9904 SDATA (binding)); | 9904 SDATA (binding)); |
9905 message2_nolog (newmessage, | 9905 message2_nolog (newmessage, |
9906 strlen (newmessage), | 9906 strlen (newmessage), |
9907 STRING_MULTIBYTE (binding)); | 9907 STRING_MULTIBYTE (binding)); |
9908 if (!NILP (Fsit_for ((NUMBERP (Vsuggest_key_bindings) | 9908 if (NUMBERP (Vsuggest_key_bindings)) |
9909 ? Vsuggest_key_bindings : make_number (2)), | 9909 waited = sit_for (Vsuggest_key_bindings, 0, 2); |
9910 Qnil, Qnil)) | 9910 else |
9911 && message_p) | 9911 waited = sit_for (make_number (2), 0, 2); |
9912 | |
9913 if (!NILP (waited) && message_p) | |
9912 restore_message (); | 9914 restore_message (); |
9913 | 9915 |
9914 unbind_to (count, Qnil); | 9916 unbind_to (count, Qnil); |
9915 } | 9917 } |
9916 } | 9918 } |
11476 DEFVAR_LISP ("throw-on-input", &Vthrow_on_input, | 11478 DEFVAR_LISP ("throw-on-input", &Vthrow_on_input, |
11477 doc: /* If non-nil, any keyboard input throws to this symbol. | 11479 doc: /* If non-nil, any keyboard input throws to this symbol. |
11478 The value of that variable is passed to `quit-flag' and later causes a | 11480 The value of that variable is passed to `quit-flag' and later causes a |
11479 peculiar kind of quitting. */); | 11481 peculiar kind of quitting. */); |
11480 Vthrow_on_input = Qnil; | 11482 Vthrow_on_input = Qnil; |
11483 | |
11484 DEFVAR_LISP ("command-error-function", &Vcommand_error_function, | |
11485 doc: /* If non-nil, function to output error messages. | |
11486 The arguments are the error data, a list of the form | |
11487 (SIGNALED-CONDITIONS . SIGNAL-DATA) | |
11488 such as just as `condition-case' would bind its variable to, | |
11489 the context (a string which normally goes at the start of the message), | |
11490 and the Lisp function within which the error was signaled. */); | |
11491 Vcommand_error_function = Qnil; | |
11481 | 11492 |
11482 DEFVAR_LISP ("enable-disabled-menus-and-buttons", | 11493 DEFVAR_LISP ("enable-disabled-menus-and-buttons", |
11483 &Venable_disabled_menus_and_buttons, | 11494 &Venable_disabled_menus_and_buttons, |
11484 doc: /* If non-nil, don't ignore events produced by disabled menu items and tool-bar. | 11495 doc: /* If non-nil, don't ignore events produced by disabled menu items and tool-bar. |
11485 | 11496 |