Mercurial > emacs
comparison src/keyboard.c @ 83533:02e39decdc84
Merged from emacs@sv.gnu.org
Patches applied:
* emacs@sv.gnu.org/emacs--devo--0--patch-351
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-352
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-353
Merge from gnus--rel--5.10
* emacs@sv.gnu.org/emacs--devo--0--patch-354
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-355
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-356
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-357
Merge from gnus--rel--5.10
* emacs@sv.gnu.org/emacs--devo--0--patch-358
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-359
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-360
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-361
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-362
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-363
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-364
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-365
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-366
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-367
Merge from gnus--rel--5.10
* emacs@sv.gnu.org/emacs--devo--0--patch-368
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-369
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-370
Update from CVS
* emacs@sv.gnu.org/gnus--rel--5.10--patch-115
Update from CVS
* emacs@sv.gnu.org/gnus--rel--5.10--patch-116
Update from CVS
* emacs@sv.gnu.org/gnus--rel--5.10--patch-117
Update from CVS
* emacs@sv.gnu.org/gnus--rel--5.10--patch-118
Merge from emacs--devo--0
* emacs@sv.gnu.org/gnus--rel--5.10--patch-119
Update from CVS
* emacs@sv.gnu.org/gnus--rel--5.10--patch-120
Update from CVS
git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-573
author | Karoly Lorentey <lorentey@elte.hu> |
---|---|
date | Sat, 29 Jul 2006 09:59:12 +0000 |
parents | b19aaf4ab0ee 3cc6bfe3a15d |
children | 4a2f192917db |
comparison
equal
deleted
inserted
replaced
83532:b19aaf4ab0ee | 83533:02e39decdc84 |
---|---|
236 static int inhibit_local_menu_bar_menus; | 236 static int inhibit_local_menu_bar_menus; |
237 | 237 |
238 /* Nonzero means C-g should cause immediate error-signal. */ | 238 /* Nonzero means C-g should cause immediate error-signal. */ |
239 int immediate_quit; | 239 int immediate_quit; |
240 | 240 |
241 /* The user's hook function for outputting an error message. */ | |
242 Lisp_Object Vcommand_error_function; | |
243 | |
241 /* The user's ERASE setting. */ | 244 /* The user's ERASE setting. */ |
242 Lisp_Object Vtty_erase_char; | 245 Lisp_Object Vtty_erase_char; |
243 | 246 |
244 /* Character to recognize as the help char. */ | 247 /* Character to recognize as the help char. */ |
245 Lisp_Object Vhelp_char; | 248 Lisp_Object Vhelp_char; |
680 static void handle_interrupt P_ ((void)); | 683 static void handle_interrupt P_ ((void)); |
681 static void timer_start_idle P_ ((void)); | 684 static void timer_start_idle P_ ((void)); |
682 static void timer_stop_idle P_ ((void)); | 685 static void timer_stop_idle P_ ((void)); |
683 static void timer_resume_idle P_ ((void)); | 686 static void timer_resume_idle P_ ((void)); |
684 | 687 |
685 Lisp_Object read_char P_ ((int, int, Lisp_Object *, Lisp_Object, int *)); | |
686 | |
687 /* Nonzero means don't try to suspend even if the operating system seems | 688 /* Nonzero means don't try to suspend even if the operating system seems |
688 to support it. */ | 689 to support it. */ |
689 static int cannot_suspend; | 690 static int cannot_suspend; |
690 | 691 |
691 extern Lisp_Object Qidentity, Qonly; | 692 extern Lisp_Object Qidentity, Qonly; |
988 if (EQ (val, Qt)) | 989 if (EQ (val, Qt)) |
989 Fsignal (Qquit, Qnil); | 990 Fsignal (Qquit, Qnil); |
990 /* Handle throw from read_minibuf when using minibuffer | 991 /* Handle throw from read_minibuf when using minibuffer |
991 while it's active but we're in another window. */ | 992 while it's active but we're in another window. */ |
992 if (STRINGP (val)) | 993 if (STRINGP (val)) |
993 Fsignal (Qerror, Fcons (val, Qnil)); | 994 xsignal1 (Qerror, val); |
994 | 995 |
995 return unbind_to (count, Qnil); | 996 return unbind_to (count, Qnil); |
996 } | 997 } |
997 | 998 |
998 /* When an auto-save happens, record the "time", and don't do again soon. */ | 999 /* When an auto-save happens, record the "time", and don't do again soon. */ |
1183 int was_locked = single_kboard; | 1184 int was_locked = single_kboard; |
1184 if (was_locked) | 1185 if (was_locked) |
1185 { | 1186 { |
1186 if (f != NULL && FRAME_KBOARD (f) != current_kboard) | 1187 if (f != NULL && FRAME_KBOARD (f) != current_kboard) |
1187 /* We can not switch keyboards while in single_kboard mode. | 1188 /* We can not switch keyboards while in single_kboard mode. |
1188 This can legally happen when Lisp code calls | 1189 In rare cases, Lisp code may call `recursive-edit' (or |
1189 `recursive-edit' (or `read-minibuffer' or `y-or-n-p') after | 1190 `read-minibuffer' or `y-or-n-p') after it switched to a |
1190 it switched to a locked frame. This kind of situation is | 1191 locked frame. For example, this is likely to happen |
1191 likely to happen when server.el connects to a new | 1192 when server.el connects to a new terminal while Emacs is in |
1192 terminal. */ | 1193 single_kboard mode. It is best to throw an error instead |
1194 of presenting the user with a frozen screen. */ | |
1193 error ("Terminal %d is locked, cannot read from it", | 1195 error ("Terminal %d is locked, cannot read from it", |
1194 FRAME_TERMINAL (f)->id); | 1196 FRAME_TERMINAL (f)->id); |
1195 else | 1197 else |
1196 /* This call is unnecessary, but helps | 1198 /* This call is unnecessary, but helps |
1197 `restore_kboard_configuration' discover if somebody changed | 1199 `restore_kboard_configuration' discover if somebody changed |
1302 void | 1304 void |
1303 cmd_error_internal (data, context) | 1305 cmd_error_internal (data, context) |
1304 Lisp_Object data; | 1306 Lisp_Object data; |
1305 char *context; | 1307 char *context; |
1306 { | 1308 { |
1307 Lisp_Object stream; | |
1308 int kill_emacs_p = 0; | |
1309 struct frame *sf = SELECTED_FRAME (); | 1309 struct frame *sf = SELECTED_FRAME (); |
1310 | |
1311 Vquit_flag = Qnil; | |
1312 Vinhibit_quit = Qt; | |
1313 clear_message (1, 0); | |
1314 | |
1315 /* If the window system or terminal frame hasn't been initialized | |
1316 yet, or we're not interactive, it's best to dump this message out | |
1317 to stderr and exit. */ | |
1318 if (!sf->glyphs_initialized_p | |
1319 || FRAME_INITIAL_P (sf) | |
1320 || noninteractive) | |
1321 { | |
1322 stream = Qexternal_debugging_output; | |
1323 kill_emacs_p = 1; | |
1324 } | |
1325 else | |
1326 { | |
1327 Fdiscard_input (); | |
1328 message_log_maybe_newline (); | |
1329 bitch_at_user (); | |
1330 stream = Qt; | |
1331 } | |
1332 | 1310 |
1333 /* The immediate context is not interesting for Quits, | 1311 /* The immediate context is not interesting for Quits, |
1334 since they are asyncronous. */ | 1312 since they are asyncronous. */ |
1335 if (EQ (XCAR (data), Qquit)) | 1313 if (EQ (XCAR (data), Qquit)) |
1336 Vsignaling_function = Qnil; | 1314 Vsignaling_function = Qnil; |
1337 | 1315 |
1338 print_error_message (data, stream, context, Vsignaling_function); | 1316 Vquit_flag = Qnil; |
1317 Vinhibit_quit = Qt; | |
1318 | |
1319 /* Use user's specified output function if any. */ | |
1320 if (!NILP (Vcommand_error_function)) | |
1321 call3 (Vcommand_error_function, data, | |
1322 build_string (context ? context : ""), | |
1323 Vsignaling_function); | |
1324 /* If the window system or terminal frame hasn't been initialized | |
1325 yet, or we're not interactive, write the message to stderr and exit. */ | |
1326 else if (!sf->glyphs_initialized_p | |
1327 || FRAME_INITIAL_P (sf) | |
1328 || noninteractive) | |
1329 { | |
1330 print_error_message (data, Qexternal_debugging_output, | |
1331 context, Vsignaling_function); | |
1332 Fterpri (Qexternal_debugging_output); | |
1333 Fkill_emacs (make_number (-1)); | |
1334 } | |
1335 else | |
1336 { | |
1337 clear_message (1, 0); | |
1338 Fdiscard_input (); | |
1339 message_log_maybe_newline (); | |
1340 bitch_at_user (); | |
1341 | |
1342 print_error_message (data, Qt, context, Vsignaling_function); | |
1343 } | |
1339 | 1344 |
1340 Vsignaling_function = Qnil; | 1345 Vsignaling_function = Qnil; |
1341 | |
1342 /* If the window system or terminal frame hasn't been initialized | |
1343 yet, or we're in -batch mode, this error should cause Emacs to exit. */ | |
1344 if (kill_emacs_p) | |
1345 { | |
1346 Fterpri (stream); | |
1347 Fkill_emacs (make_number (-1)); | |
1348 } | |
1349 } | 1346 } |
1350 | 1347 |
1351 Lisp_Object command_loop_1 (); | 1348 Lisp_Object command_loop_1 (); |
1352 Lisp_Object command_loop_2 (); | 1349 Lisp_Object command_loop_2 (); |
1353 Lisp_Object top_level_1 (); | 1350 Lisp_Object top_level_1 (); |
2468 USED_MOUSE_MENU is null, we don't dereference it. | 2465 USED_MOUSE_MENU is null, we don't dereference it. |
2469 | 2466 |
2470 Value is -2 when we find input on another keyboard. A second call | 2467 Value is -2 when we find input on another keyboard. A second call |
2471 to read_char will read it. | 2468 to read_char will read it. |
2472 | 2469 |
2470 If END_TIME is non-null, it is a pointer to an EMACS_TIME | |
2471 specifying the maximum time to wait until. If no input arrives by | |
2472 that time, stop waiting and return nil. | |
2473 | |
2473 Value is t if we showed a menu and the user rejected it. */ | 2474 Value is t if we showed a menu and the user rejected it. */ |
2474 | 2475 |
2475 Lisp_Object | 2476 Lisp_Object |
2476 read_char (commandflag, nmaps, maps, prev_event, used_mouse_menu) | 2477 read_char (commandflag, nmaps, maps, prev_event, used_mouse_menu, end_time) |
2477 int commandflag; | 2478 int commandflag; |
2478 int nmaps; | 2479 int nmaps; |
2479 Lisp_Object *maps; | 2480 Lisp_Object *maps; |
2480 Lisp_Object prev_event; | 2481 Lisp_Object prev_event; |
2481 int *used_mouse_menu; | 2482 int *used_mouse_menu; |
2483 EMACS_TIME *end_time; | |
2482 { | 2484 { |
2483 volatile Lisp_Object c; | 2485 volatile Lisp_Object c; |
2484 int count; | 2486 int count; |
2485 jmp_buf local_getcjmp; | 2487 jmp_buf local_getcjmp; |
2486 jmp_buf save_jump; | 2488 jmp_buf save_jump; |
2762 | 2764 |
2763 /* If in middle of key sequence and minibuffer not active, | 2765 /* If in middle of key sequence and minibuffer not active, |
2764 start echoing if enough time elapses. */ | 2766 start echoing if enough time elapses. */ |
2765 | 2767 |
2766 if (minibuf_level == 0 | 2768 if (minibuf_level == 0 |
2769 && !end_time | |
2767 && !current_kboard->immediate_echo | 2770 && !current_kboard->immediate_echo |
2768 && this_command_key_count > 0 | 2771 && this_command_key_count > 0 |
2769 && ! noninteractive | 2772 && ! noninteractive |
2770 && (FLOATP (Vecho_keystrokes) || INTEGERP (Vecho_keystrokes)) | 2773 && (FLOATP (Vecho_keystrokes) || INTEGERP (Vecho_keystrokes)) |
2771 && NILP (Fzerop (Vecho_keystrokes)) | 2774 && NILP (Fzerop (Vecho_keystrokes)) |
2957 | 2960 |
2958 if (NILP (c)) | 2961 if (NILP (c)) |
2959 { | 2962 { |
2960 KBOARD *kb; | 2963 KBOARD *kb; |
2961 | 2964 |
2965 if (end_time) | |
2966 { | |
2967 EMACS_TIME now; | |
2968 EMACS_GET_TIME (now); | |
2969 if (EMACS_TIME_GE (now, *end_time)) | |
2970 goto exit; | |
2971 } | |
2972 | |
2962 /* Actually read a character, waiting if necessary. */ | 2973 /* Actually read a character, waiting if necessary. */ |
2963 save_getcjmp (save_jump); | 2974 save_getcjmp (save_jump); |
2964 restore_getcjmp (local_getcjmp); | 2975 restore_getcjmp (local_getcjmp); |
2965 timer_start_idle (); | 2976 timer_start_idle (); |
2966 c = kbd_buffer_get_event (&kb, used_mouse_menu); | 2977 c = kbd_buffer_get_event (&kb, used_mouse_menu, end_time); |
2967 restore_getcjmp (save_jump); | 2978 restore_getcjmp (save_jump); |
2968 | 2979 |
2969 #ifdef MULTI_KBOARD | 2980 #ifdef MULTI_KBOARD |
2970 if (! NILP (c) && (kb != current_kboard)) | 2981 if (! NILP (c) && (kb != current_kboard)) |
2971 { | 2982 { |
3305 if (STRINGP (tem0)) | 3316 if (STRINGP (tem0)) |
3306 internal_with_output_to_temp_buffer ("*Help*", print_help, tem0); | 3317 internal_with_output_to_temp_buffer ("*Help*", print_help, tem0); |
3307 | 3318 |
3308 cancel_echoing (); | 3319 cancel_echoing (); |
3309 do | 3320 do |
3310 c = read_char (0, 0, 0, Qnil, 0); | 3321 c = read_char (0, 0, 0, Qnil, 0, NULL); |
3311 while (BUFFERP (c)); | 3322 while (BUFFERP (c)); |
3312 /* Remove the help from the frame */ | 3323 /* Remove the help from the frame */ |
3313 unbind_to (count, Qnil); | 3324 unbind_to (count, Qnil); |
3314 | 3325 |
3315 redisplay (); | 3326 redisplay (); |
3316 if (EQ (c, make_number (040))) | 3327 if (EQ (c, make_number (040))) |
3317 { | 3328 { |
3318 cancel_echoing (); | 3329 cancel_echoing (); |
3319 do | 3330 do |
3320 c = read_char (0, 0, 0, Qnil, 0); | 3331 c = read_char (0, 0, 0, Qnil, 0, NULL); |
3321 while (BUFFERP (c)); | 3332 while (BUFFERP (c)); |
3322 } | 3333 } |
3323 } | 3334 } |
3324 | 3335 |
3325 exit: | 3336 exit: |
3992 The value is nil for an event that should be ignored, | 4003 The value is nil for an event that should be ignored, |
3993 or that was handled here. | 4004 or that was handled here. |
3994 We always read and discard one event. */ | 4005 We always read and discard one event. */ |
3995 | 4006 |
3996 static Lisp_Object | 4007 static Lisp_Object |
3997 kbd_buffer_get_event (kbp, used_mouse_menu) | 4008 kbd_buffer_get_event (kbp, used_mouse_menu, end_time) |
3998 KBOARD **kbp; | 4009 KBOARD **kbp; |
3999 int *used_mouse_menu; | 4010 int *used_mouse_menu; |
4011 EMACS_TIME *end_time; | |
4000 { | 4012 { |
4001 register int c; | 4013 register int c; |
4002 Lisp_Object obj; | 4014 Lisp_Object obj; |
4003 | 4015 |
4004 if (noninteractive) | 4016 if (noninteractive) |
4038 break; | 4050 break; |
4039 #ifdef HAVE_MOUSE | 4051 #ifdef HAVE_MOUSE |
4040 if (!NILP (do_mouse_tracking) && some_mouse_moved ()) | 4052 if (!NILP (do_mouse_tracking) && some_mouse_moved ()) |
4041 break; | 4053 break; |
4042 #endif | 4054 #endif |
4043 { | 4055 if (end_time) |
4056 { | |
4057 EMACS_TIME duration; | |
4058 EMACS_GET_TIME (duration); | |
4059 EMACS_SUB_TIME (duration, *end_time, duration); | |
4060 if (EMACS_TIME_NEG_P (duration)) | |
4061 return Qnil; | |
4062 else | |
4063 wait_reading_process_output (EMACS_SECS (duration), | |
4064 EMACS_USECS (duration), | |
4065 -1, 1, Qnil, NULL, 0); | |
4066 } | |
4067 else | |
4044 wait_reading_process_output (0, 0, -1, 1, Qnil, NULL, 0); | 4068 wait_reading_process_output (0, 0, -1, 1, Qnil, NULL, 0); |
4045 | 4069 |
4046 if (!interrupt_input && kbd_fetch_ptr == kbd_store_ptr) | 4070 if (!interrupt_input && kbd_fetch_ptr == kbd_store_ptr) |
4047 /* Pass 1 for EXPECT since we just waited to have input. */ | 4071 /* Pass 1 for EXPECT since we just waited to have input. */ |
4048 read_avail_input (1); | 4072 read_avail_input (1); |
4049 } | |
4050 #endif /* not VMS */ | 4073 #endif /* not VMS */ |
4051 } | 4074 } |
4052 | 4075 |
4053 if (CONSP (Vunread_command_events)) | 4076 if (CONSP (Vunread_command_events)) |
4054 { | 4077 { |
8467 is not used on replay. | 8490 is not used on replay. |
8468 */ | 8491 */ |
8469 orig_defn_macro = current_kboard->defining_kbd_macro; | 8492 orig_defn_macro = current_kboard->defining_kbd_macro; |
8470 current_kboard->defining_kbd_macro = Qnil; | 8493 current_kboard->defining_kbd_macro = Qnil; |
8471 do | 8494 do |
8472 obj = read_char (commandflag, 0, 0, Qt, 0); | 8495 obj = read_char (commandflag, 0, 0, Qt, 0, NULL); |
8473 while (BUFFERP (obj)); | 8496 while (BUFFERP (obj)); |
8474 current_kboard->defining_kbd_macro = orig_defn_macro; | 8497 current_kboard->defining_kbd_macro = orig_defn_macro; |
8475 | 8498 |
8476 if (!INTEGERP (obj)) | 8499 if (!INTEGERP (obj)) |
8477 return obj; | 8500 return obj; |
8837 this work right. */ | 8860 this work right. */ |
8838 | 8861 |
8839 /* Read the first char of the sequence specially, before setting | 8862 /* Read the first char of the sequence specially, before setting |
8840 up any keymaps, in case a filter runs and switches buffers on us. */ | 8863 up any keymaps, in case a filter runs and switches buffers on us. */ |
8841 first_event = read_char (NILP (prompt), 0, submaps, last_nonmenu_event, | 8864 first_event = read_char (NILP (prompt), 0, submaps, last_nonmenu_event, |
8842 &junk); | 8865 &junk, NULL); |
8843 #endif /* GOBBLE_FIRST_EVENT */ | 8866 #endif /* GOBBLE_FIRST_EVENT */ |
8844 | 8867 |
8845 orig_local_map = get_local_map (PT, current_buffer, Qlocal_map); | 8868 orig_local_map = get_local_map (PT, current_buffer, Qlocal_map); |
8846 orig_keymap = get_local_map (PT, current_buffer, Qkeymap); | 8869 orig_keymap = get_local_map (PT, current_buffer, Qkeymap); |
8847 from_string = Qnil; | 8870 from_string = Qnil; |
9016 KBOARD *interrupted_kboard = current_kboard; | 9039 KBOARD *interrupted_kboard = current_kboard; |
9017 struct frame *interrupted_frame = SELECTED_FRAME (); | 9040 struct frame *interrupted_frame = SELECTED_FRAME (); |
9018 #endif | 9041 #endif |
9019 key = read_char (NILP (prompt), nmaps, | 9042 key = read_char (NILP (prompt), nmaps, |
9020 (Lisp_Object *) submaps, last_nonmenu_event, | 9043 (Lisp_Object *) submaps, last_nonmenu_event, |
9021 &used_mouse_menu); | 9044 &used_mouse_menu, NULL); |
9022 #ifdef MULTI_KBOARD | 9045 #ifdef MULTI_KBOARD |
9023 if (INTEGERP (key) && XINT (key) == -2) /* wrong_kboard_jmpbuf */ | 9046 if (INTEGERP (key) && XINT (key) == -2) /* wrong_kboard_jmpbuf */ |
9024 { | 9047 { |
9025 int found = 0; | 9048 int found = 0; |
9026 struct kboard *k; | 9049 struct kboard *k; |
11945 DEFVAR_LISP ("throw-on-input", &Vthrow_on_input, | 11968 DEFVAR_LISP ("throw-on-input", &Vthrow_on_input, |
11946 doc: /* If non-nil, any keyboard input throws to this symbol. | 11969 doc: /* If non-nil, any keyboard input throws to this symbol. |
11947 The value of that variable is passed to `quit-flag' and later causes a | 11970 The value of that variable is passed to `quit-flag' and later causes a |
11948 peculiar kind of quitting. */); | 11971 peculiar kind of quitting. */); |
11949 Vthrow_on_input = Qnil; | 11972 Vthrow_on_input = Qnil; |
11973 | |
11974 DEFVAR_LISP ("command-error-function", &Vcommand_error_function, | |
11975 doc: /* If non-nil, function to output error messages. | |
11976 The arguments are the error data, a list of the form | |
11977 (SIGNALED-CONDITIONS . SIGNAL-DATA) | |
11978 such as just as `condition-case' would bind its variable to, | |
11979 the context (a string which normally goes at the start of the message), | |
11980 and the Lisp function within which the error was signaled. */); | |
11981 Vcommand_error_function = Qnil; | |
11950 | 11982 |
11951 DEFVAR_LISP ("enable-disabled-menus-and-buttons", | 11983 DEFVAR_LISP ("enable-disabled-menus-and-buttons", |
11952 &Venable_disabled_menus_and_buttons, | 11984 &Venable_disabled_menus_and_buttons, |
11953 doc: /* If non-nil, don't ignore events produced by disabled menu items and tool-bar. | 11985 doc: /* If non-nil, don't ignore events produced by disabled menu items and tool-bar. |
11954 | 11986 |