diff options
Diffstat (limited to 'src/keyboard.c')
| -rw-r--r-- | src/keyboard.c | 1129 |
1 files changed, 375 insertions, 754 deletions
diff --git a/src/keyboard.c b/src/keyboard.c index 951d4ad79dc..5b2eb8c7cd2 100644 --- a/src/keyboard.c +++ b/src/keyboard.c | |||
| @@ -1,6 +1,7 @@ | |||
| 1 | /* Keyboard and mouse input; editor command loop. | 1 | /* Keyboard and mouse input; editor command loop. |
| 2 | 2 | ||
| 3 | Copyright (C) 1985-1989, 1993-1997, 1999-2012 Free Software Foundation, Inc. | 3 | Copyright (C) 1985-1989, 1993-1997, 1999-2013 Free Software Foundation, |
| 4 | Inc. | ||
| 4 | 5 | ||
| 5 | This file is part of GNU Emacs. | 6 | This file is part of GNU Emacs. |
| 6 | 7 | ||
| @@ -306,21 +307,25 @@ static Lisp_Object Qmake_frame_visible; | |||
| 306 | static Lisp_Object Qselect_window; | 307 | static Lisp_Object Qselect_window; |
| 307 | Lisp_Object Qhelp_echo; | 308 | Lisp_Object Qhelp_echo; |
| 308 | 309 | ||
| 309 | #if defined (HAVE_MOUSE) || defined (HAVE_GPM) | ||
| 310 | static Lisp_Object Qmouse_fixup_help_message; | 310 | static Lisp_Object Qmouse_fixup_help_message; |
| 311 | #endif | ||
| 312 | 311 | ||
| 313 | /* Symbols to denote kinds of events. */ | 312 | /* Symbols to denote kinds of events. */ |
| 314 | static Lisp_Object Qfunction_key; | 313 | static Lisp_Object Qfunction_key; |
| 315 | Lisp_Object Qmouse_click; | 314 | Lisp_Object Qmouse_click; |
| 316 | #ifdef HAVE_NTGUI | 315 | #ifdef HAVE_NTGUI |
| 317 | Lisp_Object Qlanguage_change; | 316 | Lisp_Object Qlanguage_change; |
| 317 | #ifdef WINDOWSNT | ||
| 318 | Lisp_Object Qfile_w32notify; | ||
| 319 | #endif | ||
| 318 | #endif | 320 | #endif |
| 319 | static Lisp_Object Qdrag_n_drop; | 321 | static Lisp_Object Qdrag_n_drop; |
| 320 | static Lisp_Object Qsave_session; | 322 | static Lisp_Object Qsave_session; |
| 321 | #ifdef HAVE_DBUS | 323 | #ifdef HAVE_DBUS |
| 322 | static Lisp_Object Qdbus_event; | 324 | static Lisp_Object Qdbus_event; |
| 323 | #endif | 325 | #endif |
| 326 | #ifdef HAVE_INOTIFY | ||
| 327 | static Lisp_Object Qfile_inotify; | ||
| 328 | #endif /* HAVE_INOTIFY */ | ||
| 324 | static Lisp_Object Qconfig_changed_event; | 329 | static Lisp_Object Qconfig_changed_event; |
| 325 | 330 | ||
| 326 | /* Lisp_Object Qmouse_movement; - also an event header */ | 331 | /* Lisp_Object Qmouse_movement; - also an event header */ |
| @@ -362,7 +367,7 @@ Lisp_Object Qmenu_bar; | |||
| 362 | 367 | ||
| 363 | static Lisp_Object recursive_edit_unwind (Lisp_Object buffer); | 368 | static Lisp_Object recursive_edit_unwind (Lisp_Object buffer); |
| 364 | static Lisp_Object command_loop (void); | 369 | static Lisp_Object command_loop (void); |
| 365 | static Lisp_Object Qextended_command_history; | 370 | static Lisp_Object Qcommand_execute; |
| 366 | EMACS_TIME timer_check (void); | 371 | EMACS_TIME timer_check (void); |
| 367 | 372 | ||
| 368 | static void echo_now (void); | 373 | static void echo_now (void); |
| @@ -412,17 +417,14 @@ static void (*keyboard_init_hook) (void); | |||
| 412 | 417 | ||
| 413 | static bool get_input_pending (int); | 418 | static bool get_input_pending (int); |
| 414 | static bool readable_events (int); | 419 | static bool readable_events (int); |
| 415 | static Lisp_Object read_char_x_menu_prompt (ptrdiff_t, Lisp_Object *, | 420 | static Lisp_Object read_char_x_menu_prompt (Lisp_Object, |
| 416 | Lisp_Object, bool *); | 421 | Lisp_Object, bool *); |
| 417 | static Lisp_Object read_char_minibuf_menu_prompt (int, ptrdiff_t, | 422 | static Lisp_Object read_char_minibuf_menu_prompt (int, Lisp_Object); |
| 418 | Lisp_Object *); | ||
| 419 | static Lisp_Object make_lispy_event (struct input_event *); | 423 | static Lisp_Object make_lispy_event (struct input_event *); |
| 420 | #if defined (HAVE_MOUSE) || defined (HAVE_GPM) | ||
| 421 | static Lisp_Object make_lispy_movement (struct frame *, Lisp_Object, | 424 | static Lisp_Object make_lispy_movement (struct frame *, Lisp_Object, |
| 422 | enum scroll_bar_part, | 425 | enum scroll_bar_part, |
| 423 | Lisp_Object, Lisp_Object, | 426 | Lisp_Object, Lisp_Object, |
| 424 | Time); | 427 | Time); |
| 425 | #endif | ||
| 426 | static Lisp_Object modify_event_symbol (ptrdiff_t, int, Lisp_Object, | 428 | static Lisp_Object modify_event_symbol (ptrdiff_t, int, Lisp_Object, |
| 427 | Lisp_Object, const char *const *, | 429 | Lisp_Object, const char *const *, |
| 428 | Lisp_Object *, ptrdiff_t); | 430 | Lisp_Object *, ptrdiff_t); |
| @@ -494,97 +496,103 @@ kset_system_key_syms (struct kboard *kb, Lisp_Object val) | |||
| 494 | } | 496 | } |
| 495 | 497 | ||
| 496 | 498 | ||
| 497 | /* Add C to the echo string, if echoing is going on. | 499 | /* Add C to the echo string, without echoing it immediately. C can be |
| 498 | C can be a character, which is printed prettily ("M-C-x" and all that | 500 | a character, which is pretty-printed, or a symbol, whose name is |
| 499 | jazz), or a symbol, whose name is printed. */ | 501 | printed. */ |
| 500 | 502 | ||
| 501 | static void | 503 | static void |
| 502 | echo_char (Lisp_Object c) | 504 | echo_add_key (Lisp_Object c) |
| 503 | { | 505 | { |
| 504 | if (current_kboard->immediate_echo) | 506 | int size = KEY_DESCRIPTION_SIZE + 100; |
| 505 | { | 507 | char *buffer = alloca (size); |
| 506 | int size = KEY_DESCRIPTION_SIZE + 100; | 508 | char *ptr = buffer; |
| 507 | char *buffer = alloca (size); | 509 | Lisp_Object echo_string; |
| 508 | char *ptr = buffer; | ||
| 509 | Lisp_Object echo_string; | ||
| 510 | 510 | ||
| 511 | echo_string = KVAR (current_kboard, echo_string); | 511 | echo_string = KVAR (current_kboard, echo_string); |
| 512 | 512 | ||
| 513 | /* If someone has passed us a composite event, use its head symbol. */ | 513 | /* If someone has passed us a composite event, use its head symbol. */ |
| 514 | c = EVENT_HEAD (c); | 514 | c = EVENT_HEAD (c); |
| 515 | 515 | ||
| 516 | if (INTEGERP (c)) | 516 | if (INTEGERP (c)) |
| 517 | ptr = push_key_description (XINT (c), ptr); | ||
| 518 | else if (SYMBOLP (c)) | ||
| 519 | { | ||
| 520 | Lisp_Object name = SYMBOL_NAME (c); | ||
| 521 | int nbytes = SBYTES (name); | ||
| 522 | |||
| 523 | if (size - (ptr - buffer) < nbytes) | ||
| 517 | { | 524 | { |
| 518 | ptr = push_key_description (XINT (c), ptr); | 525 | int offset = ptr - buffer; |
| 526 | size = max (2 * size, size + nbytes); | ||
| 527 | buffer = alloca (size); | ||
| 528 | ptr = buffer + offset; | ||
| 519 | } | 529 | } |
| 520 | else if (SYMBOLP (c)) | ||
| 521 | { | ||
| 522 | Lisp_Object name = SYMBOL_NAME (c); | ||
| 523 | int nbytes = SBYTES (name); | ||
| 524 | 530 | ||
| 525 | if (size - (ptr - buffer) < nbytes) | 531 | ptr += copy_text (SDATA (name), (unsigned char *) ptr, nbytes, |
| 526 | { | 532 | STRING_MULTIBYTE (name), 1); |
| 527 | int offset = ptr - buffer; | 533 | } |
| 528 | size = max (2 * size, size + nbytes); | ||
| 529 | buffer = alloca (size); | ||
| 530 | ptr = buffer + offset; | ||
| 531 | } | ||
| 532 | 534 | ||
| 533 | ptr += copy_text (SDATA (name), (unsigned char *) ptr, nbytes, | 535 | if ((NILP (echo_string) || SCHARS (echo_string) == 0) |
| 534 | STRING_MULTIBYTE (name), 1); | 536 | && help_char_p (c)) |
| 535 | } | 537 | { |
| 538 | const char *text = " (Type ? for further options)"; | ||
| 539 | int len = strlen (text); | ||
| 536 | 540 | ||
| 537 | if ((NILP (echo_string) || SCHARS (echo_string) == 0) | 541 | if (size - (ptr - buffer) < len) |
| 538 | && help_char_p (c)) | ||
| 539 | { | 542 | { |
| 540 | const char *text = " (Type ? for further options)"; | 543 | int offset = ptr - buffer; |
| 541 | int len = strlen (text); | 544 | size += len; |
| 542 | 545 | buffer = alloca (size); | |
| 543 | if (size - (ptr - buffer) < len) | 546 | ptr = buffer + offset; |
| 544 | { | ||
| 545 | int offset = ptr - buffer; | ||
| 546 | size += len; | ||
| 547 | buffer = alloca (size); | ||
| 548 | ptr = buffer + offset; | ||
| 549 | } | ||
| 550 | |||
| 551 | memcpy (ptr, text, len); | ||
| 552 | ptr += len; | ||
| 553 | } | 547 | } |
| 554 | 548 | ||
| 555 | /* Replace a dash from echo_dash with a space, otherwise | 549 | memcpy (ptr, text, len); |
| 556 | add a space at the end as a separator between keys. */ | 550 | ptr += len; |
| 557 | if (STRINGP (echo_string) | 551 | } |
| 558 | && SCHARS (echo_string) > 1) | ||
| 559 | { | ||
| 560 | Lisp_Object last_char, prev_char, idx; | ||
| 561 | 552 | ||
| 562 | idx = make_number (SCHARS (echo_string) - 2); | 553 | /* Replace a dash from echo_dash with a space, otherwise add a space |
| 563 | prev_char = Faref (echo_string, idx); | 554 | at the end as a separator between keys. */ |
| 555 | if (STRINGP (echo_string) && SCHARS (echo_string) > 1) | ||
| 556 | { | ||
| 557 | Lisp_Object last_char, prev_char, idx; | ||
| 564 | 558 | ||
| 565 | idx = make_number (SCHARS (echo_string) - 1); | 559 | idx = make_number (SCHARS (echo_string) - 2); |
| 566 | last_char = Faref (echo_string, idx); | 560 | prev_char = Faref (echo_string, idx); |
| 567 | 561 | ||
| 568 | /* We test PREV_CHAR to make sure this isn't the echoing | 562 | idx = make_number (SCHARS (echo_string) - 1); |
| 569 | of a minus-sign. */ | 563 | last_char = Faref (echo_string, idx); |
| 570 | if (XINT (last_char) == '-' && XINT (prev_char) != ' ') | 564 | |
| 571 | Faset (echo_string, idx, make_number (' ')); | 565 | /* We test PREV_CHAR to make sure this isn't the echoing of a |
| 572 | else | 566 | minus-sign. */ |
| 573 | echo_string = concat2 (echo_string, build_string (" ")); | 567 | if (XINT (last_char) == '-' && XINT (prev_char) != ' ') |
| 574 | } | 568 | Faset (echo_string, idx, make_number (' ')); |
| 575 | else if (STRINGP (echo_string)) | 569 | else |
| 576 | echo_string = concat2 (echo_string, build_string (" ")); | 570 | echo_string = concat2 (echo_string, build_string (" ")); |
| 571 | } | ||
| 572 | else if (STRINGP (echo_string) && SCHARS (echo_string) > 0) | ||
| 573 | echo_string = concat2 (echo_string, build_string (" ")); | ||
| 577 | 574 | ||
| 578 | kset_echo_string | 575 | kset_echo_string |
| 579 | (current_kboard, | 576 | (current_kboard, |
| 580 | concat2 (echo_string, make_string (buffer, ptr - buffer))); | 577 | concat2 (echo_string, make_string (buffer, ptr - buffer))); |
| 578 | } | ||
| 581 | 579 | ||
| 580 | /* Add C to the echo string, if echoing is going on. C can be a | ||
| 581 | character or a symbol. */ | ||
| 582 | |||
| 583 | static void | ||
| 584 | echo_char (Lisp_Object c) | ||
| 585 | { | ||
| 586 | if (current_kboard->immediate_echo) | ||
| 587 | { | ||
| 588 | echo_add_key (c); | ||
| 582 | echo_now (); | 589 | echo_now (); |
| 583 | } | 590 | } |
| 584 | } | 591 | } |
| 585 | 592 | ||
| 586 | /* Temporarily add a dash to the end of the echo string if it's not | 593 | /* Temporarily add a dash to the end of the echo string if it's not |
| 587 | empty, so that it serves as a mini-prompt for the very next character. */ | 594 | empty, so that it serves as a mini-prompt for the very next |
| 595 | character. */ | ||
| 588 | 596 | ||
| 589 | static void | 597 | static void |
| 590 | echo_dash (void) | 598 | echo_dash (void) |
| @@ -666,9 +674,8 @@ echo_now (void) | |||
| 666 | } | 674 | } |
| 667 | 675 | ||
| 668 | echoing = 1; | 676 | echoing = 1; |
| 669 | message3_nolog (KVAR (current_kboard, echo_string), | 677 | /* FIXME: Use call (Qmessage) so it can be advised (e.g. emacspeak). */ |
| 670 | SBYTES (KVAR (current_kboard, echo_string)), | 678 | message3_nolog (KVAR (current_kboard, echo_string)); |
| 671 | STRING_MULTIBYTE (KVAR (current_kboard, echo_string))); | ||
| 672 | echoing = 0; | 679 | echoing = 0; |
| 673 | 680 | ||
| 674 | /* Record in what buffer we echoed, and from which kboard. */ | 681 | /* Record in what buffer we echoed, and from which kboard. */ |
| @@ -826,7 +833,7 @@ This function is called by the editor initialization to begin editing. */) | |||
| 826 | update_mode_lines = 1; | 833 | update_mode_lines = 1; |
| 827 | 834 | ||
| 828 | if (command_loop_level | 835 | if (command_loop_level |
| 829 | && current_buffer != XBUFFER (XWINDOW (selected_window)->buffer)) | 836 | && current_buffer != XBUFFER (XWINDOW (selected_window)->contents)) |
| 830 | buffer = Fcurrent_buffer (); | 837 | buffer = Fcurrent_buffer (); |
| 831 | else | 838 | else |
| 832 | buffer = Qnil; | 839 | buffer = Qnil; |
| @@ -1120,8 +1127,7 @@ cmd_error_internal (Lisp_Object data, const char *context) | |||
| 1120 | 1127 | ||
| 1121 | Vsignaling_function = Qnil; | 1128 | Vsignaling_function = Qnil; |
| 1122 | } | 1129 | } |
| 1123 | 1130 | ||
| 1124 | Lisp_Object command_loop_1 (void); | ||
| 1125 | static Lisp_Object command_loop_2 (Lisp_Object); | 1131 | static Lisp_Object command_loop_2 (Lisp_Object); |
| 1126 | static Lisp_Object top_level_1 (Lisp_Object); | 1132 | static Lisp_Object top_level_1 (Lisp_Object); |
| 1127 | 1133 | ||
| @@ -1158,7 +1164,7 @@ command_loop (void) | |||
| 1158 | value to us. A value of nil means that command_loop_1 itself | 1164 | value to us. A value of nil means that command_loop_1 itself |
| 1159 | returned due to end of file (or end of kbd macro). */ | 1165 | returned due to end of file (or end of kbd macro). */ |
| 1160 | 1166 | ||
| 1161 | Lisp_Object | 1167 | static Lisp_Object |
| 1162 | command_loop_2 (Lisp_Object ignore) | 1168 | command_loop_2 (Lisp_Object ignore) |
| 1163 | { | 1169 | { |
| 1164 | register Lisp_Object val; | 1170 | register Lisp_Object val; |
| @@ -1176,16 +1182,16 @@ top_level_2 (void) | |||
| 1176 | return Feval (Vtop_level, Qnil); | 1182 | return Feval (Vtop_level, Qnil); |
| 1177 | } | 1183 | } |
| 1178 | 1184 | ||
| 1179 | Lisp_Object | 1185 | static Lisp_Object |
| 1180 | top_level_1 (Lisp_Object ignore) | 1186 | top_level_1 (Lisp_Object ignore) |
| 1181 | { | 1187 | { |
| 1182 | /* On entry to the outer level, run the startup file */ | 1188 | /* On entry to the outer level, run the startup file. */ |
| 1183 | if (!NILP (Vtop_level)) | 1189 | if (!NILP (Vtop_level)) |
| 1184 | internal_condition_case (top_level_2, Qerror, cmd_error); | 1190 | internal_condition_case (top_level_2, Qerror, cmd_error); |
| 1185 | else if (!NILP (Vpurify_flag)) | 1191 | else if (!NILP (Vpurify_flag)) |
| 1186 | message ("Bare impure Emacs (standard Lisp code not loaded)"); | 1192 | message1 ("Bare impure Emacs (standard Lisp code not loaded)"); |
| 1187 | else | 1193 | else |
| 1188 | message ("Bare Emacs (standard Lisp code not loaded)"); | 1194 | message1 ("Bare Emacs (standard Lisp code not loaded)"); |
| 1189 | return Qnil; | 1195 | return Qnil; |
| 1190 | } | 1196 | } |
| 1191 | 1197 | ||
| @@ -1234,8 +1240,6 @@ DEFUN ("abort-recursive-edit", Fabort_recursive_edit, Sabort_recursive_edit, 0, | |||
| 1234 | user_error ("No recursive edit is in progress"); | 1240 | user_error ("No recursive edit is in progress"); |
| 1235 | } | 1241 | } |
| 1236 | 1242 | ||
| 1237 | #if defined (HAVE_MOUSE) || defined (HAVE_GPM) | ||
| 1238 | |||
| 1239 | /* Restore mouse tracking enablement. See Ftrack_mouse for the only use | 1243 | /* Restore mouse tracking enablement. See Ftrack_mouse for the only use |
| 1240 | of this function. */ | 1244 | of this function. */ |
| 1241 | 1245 | ||
| @@ -1310,7 +1314,6 @@ some_mouse_moved (void) | |||
| 1310 | return 0; | 1314 | return 0; |
| 1311 | } | 1315 | } |
| 1312 | 1316 | ||
| 1313 | #endif /* HAVE_MOUSE || HAVE_GPM */ | ||
| 1314 | 1317 | ||
| 1315 | /* This is the actual command reading loop, | 1318 | /* This is the actual command reading loop, |
| 1316 | sans error-handling encapsulation. */ | 1319 | sans error-handling encapsulation. */ |
| @@ -1392,7 +1395,7 @@ command_loop_1 (void) | |||
| 1392 | Fkill_emacs (Qnil); | 1395 | Fkill_emacs (Qnil); |
| 1393 | 1396 | ||
| 1394 | /* Make sure the current window's buffer is selected. */ | 1397 | /* Make sure the current window's buffer is selected. */ |
| 1395 | set_buffer_internal (XBUFFER (XWINDOW (selected_window)->buffer)); | 1398 | set_buffer_internal (XBUFFER (XWINDOW (selected_window)->contents)); |
| 1396 | 1399 | ||
| 1397 | /* Display any malloc warning that just came out. Use while because | 1400 | /* Display any malloc warning that just came out. Use while because |
| 1398 | displaying one warning can cause another. */ | 1401 | displaying one warning can cause another. */ |
| @@ -1402,14 +1405,11 @@ command_loop_1 (void) | |||
| 1402 | 1405 | ||
| 1403 | Vdeactivate_mark = Qnil; | 1406 | Vdeactivate_mark = Qnil; |
| 1404 | 1407 | ||
| 1405 | #if defined (HAVE_MOUSE) || defined (HAVE_GPM) | ||
| 1406 | |||
| 1407 | /* Don't ignore mouse movements for more than a single command | 1408 | /* Don't ignore mouse movements for more than a single command |
| 1408 | loop. (This flag is set in xdisp.c whenever the tool bar is | 1409 | loop. (This flag is set in xdisp.c whenever the tool bar is |
| 1409 | resized, because the resize moves text up or down, and would | 1410 | resized, because the resize moves text up or down, and would |
| 1410 | generate false mouse drag events if we don't ignore them.) */ | 1411 | generate false mouse drag events if we don't ignore them.) */ |
| 1411 | ignore_mouse_drag_p = 0; | 1412 | ignore_mouse_drag_p = 0; |
| 1412 | #endif | ||
| 1413 | 1413 | ||
| 1414 | /* If minibuffer on and echo area in use, | 1414 | /* If minibuffer on and echo area in use, |
| 1415 | wait a short time and redraw minibuffer. */ | 1415 | wait a short time and redraw minibuffer. */ |
| @@ -1427,7 +1427,7 @@ command_loop_1 (void) | |||
| 1427 | sit_for (Vminibuffer_message_timeout, 0, 2); | 1427 | sit_for (Vminibuffer_message_timeout, 0, 2); |
| 1428 | 1428 | ||
| 1429 | /* Clear the echo area. */ | 1429 | /* Clear the echo area. */ |
| 1430 | message2 (0, 0, 0); | 1430 | message1 (0); |
| 1431 | safe_run_hooks (Qecho_area_clear_hook); | 1431 | safe_run_hooks (Qecho_area_clear_hook); |
| 1432 | 1432 | ||
| 1433 | unbind_to (count, Qnil); | 1433 | unbind_to (count, Qnil); |
| @@ -1461,7 +1461,7 @@ command_loop_1 (void) | |||
| 1461 | /* A filter may have run while we were reading the input. */ | 1461 | /* A filter may have run while we were reading the input. */ |
| 1462 | if (! FRAME_LIVE_P (XFRAME (selected_frame))) | 1462 | if (! FRAME_LIVE_P (XFRAME (selected_frame))) |
| 1463 | Fkill_emacs (Qnil); | 1463 | Fkill_emacs (Qnil); |
| 1464 | set_buffer_internal (XBUFFER (XWINDOW (selected_window)->buffer)); | 1464 | set_buffer_internal (XBUFFER (XWINDOW (selected_window)->contents)); |
| 1465 | 1465 | ||
| 1466 | ++num_input_keys; | 1466 | ++num_input_keys; |
| 1467 | 1467 | ||
| @@ -1492,7 +1492,7 @@ command_loop_1 (void) | |||
| 1492 | { | 1492 | { |
| 1493 | struct buffer *b; | 1493 | struct buffer *b; |
| 1494 | XWINDOW (selected_window)->force_start = 0; | 1494 | XWINDOW (selected_window)->force_start = 0; |
| 1495 | b = XBUFFER (XWINDOW (selected_window)->buffer); | 1495 | b = XBUFFER (XWINDOW (selected_window)->contents); |
| 1496 | BUF_BEG_UNCHANGED (b) = BUF_END_UNCHANGED (b) = 0; | 1496 | BUF_BEG_UNCHANGED (b) = BUF_END_UNCHANGED (b) = 0; |
| 1497 | } | 1497 | } |
| 1498 | 1498 | ||
| @@ -1583,11 +1583,11 @@ command_loop_1 (void) | |||
| 1583 | = (EQ (undo, BVAR (current_buffer, undo_list)) | 1583 | = (EQ (undo, BVAR (current_buffer, undo_list)) |
| 1584 | ? Qnil : BVAR (current_buffer, undo_list)); | 1584 | ? Qnil : BVAR (current_buffer, undo_list)); |
| 1585 | } | 1585 | } |
| 1586 | Fcommand_execute (Vthis_command, Qnil, Qnil, Qnil); | 1586 | call1 (Qcommand_execute, Vthis_command); |
| 1587 | 1587 | ||
| 1588 | #ifdef HAVE_WINDOW_SYSTEM | 1588 | #ifdef HAVE_WINDOW_SYSTEM |
| 1589 | /* Do not check display_hourglass_p here, because | 1589 | /* Do not check display_hourglass_p here, because |
| 1590 | Fcommand_execute could change it, but we should cancel | 1590 | `command-execute' could change it, but we should cancel |
| 1591 | hourglass cursor anyway. | 1591 | hourglass cursor anyway. |
| 1592 | But don't cancel the hourglass within a macro | 1592 | But don't cancel the hourglass within a macro |
| 1593 | just because a command in the macro finishes. */ | 1593 | just because a command in the macro finishes. */ |
| @@ -2182,7 +2182,6 @@ show_help_echo (Lisp_Object help, Lisp_Object window, Lisp_Object object, | |||
| 2182 | return; | 2182 | return; |
| 2183 | } | 2183 | } |
| 2184 | 2184 | ||
| 2185 | #if defined (HAVE_MOUSE) || defined (HAVE_GPM) | ||
| 2186 | if (!noninteractive && STRINGP (help)) | 2185 | if (!noninteractive && STRINGP (help)) |
| 2187 | { | 2186 | { |
| 2188 | /* The mouse-fixup-help-message Lisp function can call | 2187 | /* The mouse-fixup-help-message Lisp function can call |
| @@ -2195,7 +2194,6 @@ show_help_echo (Lisp_Object help, Lisp_Object window, Lisp_Object object, | |||
| 2195 | if (f) | 2194 | if (f) |
| 2196 | f->mouse_moved = 1; | 2195 | f->mouse_moved = 1; |
| 2197 | } | 2196 | } |
| 2198 | #endif | ||
| 2199 | 2197 | ||
| 2200 | if (STRINGP (help) || NILP (help)) | 2198 | if (STRINGP (help) || NILP (help)) |
| 2201 | { | 2199 | { |
| @@ -2232,13 +2230,12 @@ do { if (! polling_stopped_here) stop_polling (); \ | |||
| 2232 | do { if (polling_stopped_here) start_polling (); \ | 2230 | do { if (polling_stopped_here) start_polling (); \ |
| 2233 | polling_stopped_here = 0; } while (0) | 2231 | polling_stopped_here = 0; } while (0) |
| 2234 | 2232 | ||
| 2235 | /* read a character from the keyboard; call the redisplay if needed */ | 2233 | /* Read a character from the keyboard; call the redisplay if needed. */ |
| 2236 | /* commandflag 0 means do not autosave, but do redisplay. | 2234 | /* commandflag 0 means do not autosave, but do redisplay. |
| 2237 | -1 means do not redisplay, but do autosave. | 2235 | -1 means do not redisplay, but do autosave. |
| 2238 | 1 means do both. */ | 2236 | 1 means do both. */ |
| 2239 | 2237 | ||
| 2240 | /* The arguments MAPS and NMAPS are for menu prompting. | 2238 | /* The arguments MAP is for menu prompting. MAP is a keymap. |
| 2241 | MAPS is an array of keymaps; NMAPS is the length of MAPS. | ||
| 2242 | 2239 | ||
| 2243 | PREV_EVENT is the previous input event, or nil if we are reading | 2240 | PREV_EVENT is the previous input event, or nil if we are reading |
| 2244 | the first event of a key sequence (or not reading a key sequence). | 2241 | the first event of a key sequence (or not reading a key sequence). |
| @@ -2260,7 +2257,7 @@ do { if (polling_stopped_here) start_polling (); \ | |||
| 2260 | Value is t if we showed a menu and the user rejected it. */ | 2257 | Value is t if we showed a menu and the user rejected it. */ |
| 2261 | 2258 | ||
| 2262 | Lisp_Object | 2259 | Lisp_Object |
| 2263 | read_char (int commandflag, ptrdiff_t nmaps, Lisp_Object *maps, | 2260 | read_char (int commandflag, Lisp_Object map, |
| 2264 | Lisp_Object prev_event, | 2261 | Lisp_Object prev_event, |
| 2265 | bool *used_mouse_menu, EMACS_TIME *end_time) | 2262 | bool *used_mouse_menu, EMACS_TIME *end_time) |
| 2266 | { | 2263 | { |
| @@ -2408,7 +2405,7 @@ read_char (int commandflag, ptrdiff_t nmaps, Lisp_Object *maps, | |||
| 2408 | goto reread_first; | 2405 | goto reread_first; |
| 2409 | } | 2406 | } |
| 2410 | 2407 | ||
| 2411 | /* if redisplay was requested */ | 2408 | /* If redisplay was requested. */ |
| 2412 | if (commandflag >= 0) | 2409 | if (commandflag >= 0) |
| 2413 | { | 2410 | { |
| 2414 | bool echo_current = EQ (echo_message_buffer, echo_area_buffer[0]); | 2411 | bool echo_current = EQ (echo_message_buffer, echo_area_buffer[0]); |
| @@ -2417,7 +2414,7 @@ read_char (int commandflag, ptrdiff_t nmaps, Lisp_Object *maps, | |||
| 2417 | user-visible, such as X selection_request events. */ | 2414 | user-visible, such as X selection_request events. */ |
| 2418 | if (input_pending | 2415 | if (input_pending |
| 2419 | || detect_input_pending_run_timers (0)) | 2416 | || detect_input_pending_run_timers (0)) |
| 2420 | swallow_events (0); /* may clear input_pending */ | 2417 | swallow_events (0); /* May clear input_pending. */ |
| 2421 | 2418 | ||
| 2422 | /* Redisplay if no pending input. */ | 2419 | /* Redisplay if no pending input. */ |
| 2423 | while (!input_pending) | 2420 | while (!input_pending) |
| @@ -2487,13 +2484,13 @@ read_char (int commandflag, ptrdiff_t nmaps, Lisp_Object *maps, | |||
| 2487 | menu prompting. If EVENT_HAS_PARAMETERS then we are reading | 2484 | menu prompting. If EVENT_HAS_PARAMETERS then we are reading |
| 2488 | after a mouse event so don't try a minibuf menu. */ | 2485 | after a mouse event so don't try a minibuf menu. */ |
| 2489 | c = Qnil; | 2486 | c = Qnil; |
| 2490 | if (nmaps > 0 && INTERACTIVE | 2487 | if (KEYMAPP (map) && INTERACTIVE |
| 2491 | && !NILP (prev_event) && ! EVENT_HAS_PARAMETERS (prev_event) | 2488 | && !NILP (prev_event) && ! EVENT_HAS_PARAMETERS (prev_event) |
| 2492 | /* Don't bring up a menu if we already have another event. */ | 2489 | /* Don't bring up a menu if we already have another event. */ |
| 2493 | && NILP (Vunread_command_events) | 2490 | && NILP (Vunread_command_events) |
| 2494 | && !detect_input_pending_run_timers (0)) | 2491 | && !detect_input_pending_run_timers (0)) |
| 2495 | { | 2492 | { |
| 2496 | c = read_char_minibuf_menu_prompt (commandflag, nmaps, maps); | 2493 | c = read_char_minibuf_menu_prompt (commandflag, map); |
| 2497 | 2494 | ||
| 2498 | if (INTEGERP (c) && XINT (c) == -2) | 2495 | if (INTEGERP (c) && XINT (c) == -2) |
| 2499 | return c; /* wrong_kboard_jmpbuf */ | 2496 | return c; /* wrong_kboard_jmpbuf */ |
| @@ -2617,7 +2614,7 @@ read_char (int commandflag, ptrdiff_t nmaps, Lisp_Object *maps, | |||
| 2617 | because the recursive call of read_char in read_char_minibuf_menu_prompt | 2614 | because the recursive call of read_char in read_char_minibuf_menu_prompt |
| 2618 | does not pass on any keymaps. */ | 2615 | does not pass on any keymaps. */ |
| 2619 | 2616 | ||
| 2620 | if (nmaps > 0 && INTERACTIVE | 2617 | if (KEYMAPP (map) && INTERACTIVE |
| 2621 | && !NILP (prev_event) | 2618 | && !NILP (prev_event) |
| 2622 | && EVENT_HAS_PARAMETERS (prev_event) | 2619 | && EVENT_HAS_PARAMETERS (prev_event) |
| 2623 | && !EQ (XCAR (prev_event), Qmenu_bar) | 2620 | && !EQ (XCAR (prev_event), Qmenu_bar) |
| @@ -2625,7 +2622,7 @@ read_char (int commandflag, ptrdiff_t nmaps, Lisp_Object *maps, | |||
| 2625 | /* Don't bring up a menu if we already have another event. */ | 2622 | /* Don't bring up a menu if we already have another event. */ |
| 2626 | && NILP (Vunread_command_events)) | 2623 | && NILP (Vunread_command_events)) |
| 2627 | { | 2624 | { |
| 2628 | c = read_char_x_menu_prompt (nmaps, maps, prev_event, used_mouse_menu); | 2625 | c = read_char_x_menu_prompt (map, prev_event, used_mouse_menu); |
| 2629 | 2626 | ||
| 2630 | /* Now that we have read an event, Emacs is not idle. */ | 2627 | /* Now that we have read an event, Emacs is not idle. */ |
| 2631 | if (!end_time) | 2628 | if (!end_time) |
| @@ -2660,9 +2657,10 @@ read_char (int commandflag, ptrdiff_t nmaps, Lisp_Object *maps, | |||
| 2660 | && XINT (Vauto_save_timeout) > 0) | 2657 | && XINT (Vauto_save_timeout) > 0) |
| 2661 | { | 2658 | { |
| 2662 | Lisp_Object tem0; | 2659 | Lisp_Object tem0; |
| 2663 | EMACS_INT timeout = (delay_level | 2660 | EMACS_INT timeout = XFASTINT (Vauto_save_timeout); |
| 2664 | * min (XFASTINT (Vauto_save_timeout) / 4, | 2661 | |
| 2665 | MOST_POSITIVE_FIXNUM / delay_level)); | 2662 | timeout = min (timeout, MOST_POSITIVE_FIXNUM / delay_level * 4); |
| 2663 | timeout = delay_level * timeout / 4; | ||
| 2666 | save_getcjmp (save_jump); | 2664 | save_getcjmp (save_jump); |
| 2667 | restore_getcjmp (local_getcjmp); | 2665 | restore_getcjmp (local_getcjmp); |
| 2668 | tem0 = sit_for (make_number (timeout), 1, 1); | 2666 | tem0 = sit_for (make_number (timeout), 1, 1); |
| @@ -2844,7 +2842,7 @@ read_char (int commandflag, ptrdiff_t nmaps, Lisp_Object *maps, | |||
| 2844 | { | 2842 | { |
| 2845 | struct buffer *prev_buffer = current_buffer; | 2843 | struct buffer *prev_buffer = current_buffer; |
| 2846 | last_input_event = c; | 2844 | last_input_event = c; |
| 2847 | Fcommand_execute (tem, Qnil, Fvector (1, &last_input_event), Qt); | 2845 | call4 (Qcommand_execute, tem, Qnil, Fvector (1, &last_input_event), Qt); |
| 2848 | 2846 | ||
| 2849 | if (CONSP (c) && EQ (XCAR (c), Qselect_window) && !end_time) | 2847 | if (CONSP (c) && EQ (XCAR (c), Qselect_window) && !end_time) |
| 2850 | /* We stopped being idle for this event; undo that. This | 2848 | /* We stopped being idle for this event; undo that. This |
| @@ -3003,7 +3001,7 @@ read_char (int commandflag, ptrdiff_t nmaps, Lisp_Object *maps, | |||
| 3003 | 3001 | ||
| 3004 | /* If we are not reading a key sequence, | 3002 | /* If we are not reading a key sequence, |
| 3005 | never use the echo area. */ | 3003 | never use the echo area. */ |
| 3006 | if (maps == 0) | 3004 | if (!KEYMAPP (map)) |
| 3007 | { | 3005 | { |
| 3008 | specbind (Qinput_method_use_echo_area, Qt); | 3006 | specbind (Qinput_method_use_echo_area, Qt); |
| 3009 | } | 3007 | } |
| @@ -3096,7 +3094,7 @@ read_char (int commandflag, ptrdiff_t nmaps, Lisp_Object *maps, | |||
| 3096 | last_input_event = c; | 3094 | last_input_event = c; |
| 3097 | num_input_events++; | 3095 | num_input_events++; |
| 3098 | 3096 | ||
| 3099 | /* Process the help character specially if enabled */ | 3097 | /* Process the help character specially if enabled. */ |
| 3100 | if (!NILP (Vhelp_form) && help_char_p (c)) | 3098 | if (!NILP (Vhelp_form) && help_char_p (c)) |
| 3101 | { | 3099 | { |
| 3102 | ptrdiff_t count = SPECPDL_INDEX (); | 3100 | ptrdiff_t count = SPECPDL_INDEX (); |
| @@ -3110,13 +3108,13 @@ read_char (int commandflag, ptrdiff_t nmaps, Lisp_Object *maps, | |||
| 3110 | cancel_echoing (); | 3108 | cancel_echoing (); |
| 3111 | do | 3109 | do |
| 3112 | { | 3110 | { |
| 3113 | c = read_char (0, 0, 0, Qnil, 0, NULL); | 3111 | c = read_char (0, Qnil, Qnil, 0, NULL); |
| 3114 | if (EVENT_HAS_PARAMETERS (c) | 3112 | if (EVENT_HAS_PARAMETERS (c) |
| 3115 | && EQ (EVENT_HEAD_KIND (EVENT_HEAD (c)), Qmouse_click)) | 3113 | && EQ (EVENT_HEAD_KIND (EVENT_HEAD (c)), Qmouse_click)) |
| 3116 | XSETCAR (help_form_saved_window_configs, Qnil); | 3114 | XSETCAR (help_form_saved_window_configs, Qnil); |
| 3117 | } | 3115 | } |
| 3118 | while (BUFFERP (c)); | 3116 | while (BUFFERP (c)); |
| 3119 | /* Remove the help from the frame */ | 3117 | /* Remove the help from the frame. */ |
| 3120 | unbind_to (count, Qnil); | 3118 | unbind_to (count, Qnil); |
| 3121 | 3119 | ||
| 3122 | redisplay (); | 3120 | redisplay (); |
| @@ -3124,7 +3122,7 @@ read_char (int commandflag, ptrdiff_t nmaps, Lisp_Object *maps, | |||
| 3124 | { | 3122 | { |
| 3125 | cancel_echoing (); | 3123 | cancel_echoing (); |
| 3126 | do | 3124 | do |
| 3127 | c = read_char (0, 0, 0, Qnil, 0, NULL); | 3125 | c = read_char (0, Qnil, Qnil, 0, NULL); |
| 3128 | while (BUFFERP (c)); | 3126 | while (BUFFERP (c)); |
| 3129 | } | 3127 | } |
| 3130 | } | 3128 | } |
| @@ -3390,11 +3388,9 @@ readable_events (int flags) | |||
| 3390 | return 1; | 3388 | return 1; |
| 3391 | } | 3389 | } |
| 3392 | 3390 | ||
| 3393 | #if defined (HAVE_MOUSE) || defined (HAVE_GPM) | ||
| 3394 | if (!(flags & READABLE_EVENTS_IGNORE_SQUEEZABLES) | 3391 | if (!(flags & READABLE_EVENTS_IGNORE_SQUEEZABLES) |
| 3395 | && !NILP (do_mouse_tracking) && some_mouse_moved ()) | 3392 | && !NILP (do_mouse_tracking) && some_mouse_moved ()) |
| 3396 | return 1; | 3393 | return 1; |
| 3397 | #endif | ||
| 3398 | if (single_kboard) | 3394 | if (single_kboard) |
| 3399 | { | 3395 | { |
| 3400 | if (current_kboard->kbd_queue_has_data) | 3396 | if (current_kboard->kbd_queue_has_data) |
| @@ -3762,10 +3758,8 @@ kbd_buffer_get_event (KBOARD **kbp, | |||
| 3762 | 3758 | ||
| 3763 | if (kbd_fetch_ptr != kbd_store_ptr) | 3759 | if (kbd_fetch_ptr != kbd_store_ptr) |
| 3764 | break; | 3760 | break; |
| 3765 | #if defined (HAVE_MOUSE) || defined (HAVE_GPM) | ||
| 3766 | if (!NILP (do_mouse_tracking) && some_mouse_moved ()) | 3761 | if (!NILP (do_mouse_tracking) && some_mouse_moved ()) |
| 3767 | break; | 3762 | break; |
| 3768 | #endif | ||
| 3769 | 3763 | ||
| 3770 | /* If the quit flag is set, then read_char will return | 3764 | /* If the quit flag is set, then read_char will return |
| 3771 | quit_char, so that counts as "available input." */ | 3765 | quit_char, so that counts as "available input." */ |
| @@ -3780,10 +3774,8 @@ kbd_buffer_get_event (KBOARD **kbp, | |||
| 3780 | #endif | 3774 | #endif |
| 3781 | if (kbd_fetch_ptr != kbd_store_ptr) | 3775 | if (kbd_fetch_ptr != kbd_store_ptr) |
| 3782 | break; | 3776 | break; |
| 3783 | #if defined (HAVE_MOUSE) || defined (HAVE_GPM) | ||
| 3784 | if (!NILP (do_mouse_tracking) && some_mouse_moved ()) | 3777 | if (!NILP (do_mouse_tracking) && some_mouse_moved ()) |
| 3785 | break; | 3778 | break; |
| 3786 | #endif | ||
| 3787 | if (end_time) | 3779 | if (end_time) |
| 3788 | { | 3780 | { |
| 3789 | EMACS_TIME now = current_emacs_time (); | 3781 | EMACS_TIME now = current_emacs_time (); |
| @@ -3923,6 +3915,18 @@ kbd_buffer_get_event (KBOARD **kbp, | |||
| 3923 | kbd_fetch_ptr = event + 1; | 3915 | kbd_fetch_ptr = event + 1; |
| 3924 | } | 3916 | } |
| 3925 | #endif | 3917 | #endif |
| 3918 | #ifdef WINDOWSNT | ||
| 3919 | else if (event->kind == FILE_NOTIFY_EVENT) | ||
| 3920 | { | ||
| 3921 | /* Make an event (file-notify (DESCRIPTOR ACTION FILE) CALLBACK). */ | ||
| 3922 | obj = Fcons (Qfile_w32notify, | ||
| 3923 | list2 (list3 (make_number (event->code), | ||
| 3924 | XCAR (event->arg), | ||
| 3925 | XCDR (event->arg)), | ||
| 3926 | event->frame_or_window)); | ||
| 3927 | kbd_fetch_ptr = event + 1; | ||
| 3928 | } | ||
| 3929 | #endif | ||
| 3926 | else if (event->kind == SAVE_SESSION_EVENT) | 3930 | else if (event->kind == SAVE_SESSION_EVENT) |
| 3927 | { | 3931 | { |
| 3928 | obj = Fcons (Qsave_session, Fcons (event->arg, Qnil)); | 3932 | obj = Fcons (Qsave_session, Fcons (event->arg, Qnil)); |
| @@ -3980,6 +3984,13 @@ kbd_buffer_get_event (KBOARD **kbp, | |||
| 3980 | kbd_fetch_ptr = event + 1; | 3984 | kbd_fetch_ptr = event + 1; |
| 3981 | } | 3985 | } |
| 3982 | #endif | 3986 | #endif |
| 3987 | #ifdef HAVE_INOTIFY | ||
| 3988 | else if (event->kind == FILE_NOTIFY_EVENT) | ||
| 3989 | { | ||
| 3990 | obj = make_lispy_event (event); | ||
| 3991 | kbd_fetch_ptr = event + 1; | ||
| 3992 | } | ||
| 3993 | #endif | ||
| 3983 | else if (event->kind == CONFIG_CHANGED_EVENT) | 3994 | else if (event->kind == CONFIG_CHANGED_EVENT) |
| 3984 | { | 3995 | { |
| 3985 | obj = make_lispy_event (event); | 3996 | obj = make_lispy_event (event); |
| @@ -4040,7 +4051,6 @@ kbd_buffer_get_event (KBOARD **kbp, | |||
| 4040 | } | 4051 | } |
| 4041 | } | 4052 | } |
| 4042 | } | 4053 | } |
| 4043 | #if defined (HAVE_MOUSE) || defined (HAVE_GPM) | ||
| 4044 | /* Try generating a mouse motion event. */ | 4054 | /* Try generating a mouse motion event. */ |
| 4045 | else if (!NILP (do_mouse_tracking) && some_mouse_moved ()) | 4055 | else if (!NILP (do_mouse_tracking) && some_mouse_moved ()) |
| 4046 | { | 4056 | { |
| @@ -4085,7 +4095,6 @@ kbd_buffer_get_event (KBOARD **kbp, | |||
| 4085 | if (!NILP (x) && NILP (obj)) | 4095 | if (!NILP (x) && NILP (obj)) |
| 4086 | obj = make_lispy_movement (f, bar_window, part, x, y, t); | 4096 | obj = make_lispy_movement (f, bar_window, part, x, y, t); |
| 4087 | } | 4097 | } |
| 4088 | #endif /* HAVE_MOUSE || HAVE GPM */ | ||
| 4089 | else | 4098 | else |
| 4090 | /* We were promised by the above while loop that there was | 4099 | /* We were promised by the above while loop that there was |
| 4091 | something for us to read! */ | 4100 | something for us to read! */ |
| @@ -5133,8 +5142,8 @@ make_lispy_position (struct frame *f, Lisp_Object x, Lisp_Object y, | |||
| 5133 | if (STRINGP (string)) | 5142 | if (STRINGP (string)) |
| 5134 | string_info = Fcons (string, make_number (charpos)); | 5143 | string_info = Fcons (string, make_number (charpos)); |
| 5135 | textpos = (w == XWINDOW (selected_window) | 5144 | textpos = (w == XWINDOW (selected_window) |
| 5136 | && current_buffer == XBUFFER (w->buffer)) | 5145 | && current_buffer == XBUFFER (w->contents)) |
| 5137 | ? PT : XMARKER (w->pointm)->charpos; | 5146 | ? PT : marker_position (w->pointm); |
| 5138 | 5147 | ||
| 5139 | xret = wx; | 5148 | xret = wx; |
| 5140 | yret = wy; | 5149 | yret = wy; |
| @@ -5397,7 +5406,6 @@ make_lispy_event (struct input_event *event) | |||
| 5397 | return Qnil; | 5406 | return Qnil; |
| 5398 | #endif | 5407 | #endif |
| 5399 | 5408 | ||
| 5400 | #ifdef HAVE_MOUSE | ||
| 5401 | /* A mouse click. Figure out where it is, decide whether it's | 5409 | /* A mouse click. Figure out where it is, decide whether it's |
| 5402 | a press, click or drag, and build the appropriate structure. */ | 5410 | a press, click or drag, and build the appropriate structure. */ |
| 5403 | case MOUSE_CLICK_EVENT: | 5411 | case MOUSE_CLICK_EVENT: |
| @@ -5849,7 +5857,6 @@ make_lispy_event (struct input_event *event) | |||
| 5849 | Fcons (files, | 5857 | Fcons (files, |
| 5850 | Qnil))); | 5858 | Qnil))); |
| 5851 | } | 5859 | } |
| 5852 | #endif /* HAVE_MOUSE */ | ||
| 5853 | 5860 | ||
| 5854 | #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) \ | 5861 | #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) \ |
| 5855 | || defined (HAVE_NS) || defined (USE_GTK) | 5862 | || defined (HAVE_NS) || defined (USE_GTK) |
| @@ -5897,6 +5904,13 @@ make_lispy_event (struct input_event *event) | |||
| 5897 | } | 5904 | } |
| 5898 | #endif /* HAVE_DBUS */ | 5905 | #endif /* HAVE_DBUS */ |
| 5899 | 5906 | ||
| 5907 | #ifdef HAVE_INOTIFY | ||
| 5908 | case FILE_NOTIFY_EVENT: | ||
| 5909 | { | ||
| 5910 | return Fcons (Qfile_inotify, event->arg); | ||
| 5911 | } | ||
| 5912 | #endif /* HAVE_INOTIFY */ | ||
| 5913 | |||
| 5900 | case CONFIG_CHANGED_EVENT: | 5914 | case CONFIG_CHANGED_EVENT: |
| 5901 | return Fcons (Qconfig_changed_event, | 5915 | return Fcons (Qconfig_changed_event, |
| 5902 | Fcons (event->arg, | 5916 | Fcons (event->arg, |
| @@ -5968,8 +5982,6 @@ make_lispy_event (struct input_event *event) | |||
| 5968 | } | 5982 | } |
| 5969 | } | 5983 | } |
| 5970 | 5984 | ||
| 5971 | #if defined (HAVE_MOUSE) || defined (HAVE_GPM) | ||
| 5972 | |||
| 5973 | static Lisp_Object | 5985 | static Lisp_Object |
| 5974 | make_lispy_movement (FRAME_PTR frame, Lisp_Object bar_window, enum scroll_bar_part part, | 5986 | make_lispy_movement (FRAME_PTR frame, Lisp_Object bar_window, enum scroll_bar_part part, |
| 5975 | Lisp_Object x, Lisp_Object y, Time t) | 5987 | Lisp_Object x, Lisp_Object y, Time t) |
| @@ -5997,8 +6009,6 @@ make_lispy_movement (FRAME_PTR frame, Lisp_Object bar_window, enum scroll_bar_pa | |||
| 5997 | } | 6009 | } |
| 5998 | } | 6010 | } |
| 5999 | 6011 | ||
| 6000 | #endif /* HAVE_MOUSE || HAVE GPM */ | ||
| 6001 | |||
| 6002 | /* Construct a switch frame event. */ | 6012 | /* Construct a switch frame event. */ |
| 6003 | static Lisp_Object | 6013 | static Lisp_Object |
| 6004 | make_lispy_switch_frame (Lisp_Object frame) | 6014 | make_lispy_switch_frame (Lisp_Object frame) |
| @@ -6215,9 +6225,7 @@ parse_modifiers (Lisp_Object symbol) | |||
| 6215 | Lisp_Object elements; | 6225 | Lisp_Object elements; |
| 6216 | 6226 | ||
| 6217 | if (INTEGERP (symbol)) | 6227 | if (INTEGERP (symbol)) |
| 6218 | return (Fcons (make_number (KEY_TO_CHAR (symbol)), | 6228 | return list2i (KEY_TO_CHAR (symbol), XINT (symbol) & CHAR_MODIFIER_MASK); |
| 6219 | Fcons (make_number (XINT (symbol) & CHAR_MODIFIER_MASK), | ||
| 6220 | Qnil))); | ||
| 6221 | else if (!SYMBOLP (symbol)) | 6229 | else if (!SYMBOLP (symbol)) |
| 6222 | return Qnil; | 6230 | return Qnil; |
| 6223 | 6231 | ||
| @@ -6544,10 +6552,7 @@ has the same base event type and all the specified modifiers. */) | |||
| 6544 | else if (SYMBOLP (base)) | 6552 | else if (SYMBOLP (base)) |
| 6545 | return apply_modifiers (modifiers, base); | 6553 | return apply_modifiers (modifiers, base); |
| 6546 | else | 6554 | else |
| 6547 | { | 6555 | error ("Invalid base event"); |
| 6548 | error ("Invalid base event"); | ||
| 6549 | return Qnil; | ||
| 6550 | } | ||
| 6551 | } | 6556 | } |
| 6552 | 6557 | ||
| 6553 | /* Try to recognize SYMBOL as a modifier name. | 6558 | /* Try to recognize SYMBOL as a modifier name. |
| @@ -6695,37 +6700,35 @@ get_input_pending (int flags) | |||
| 6695 | void | 6700 | void |
| 6696 | record_asynch_buffer_change (void) | 6701 | record_asynch_buffer_change (void) |
| 6697 | { | 6702 | { |
| 6698 | struct input_event event; | ||
| 6699 | Lisp_Object tem; | ||
| 6700 | EVENT_INIT (event); | ||
| 6701 | |||
| 6702 | event.kind = BUFFER_SWITCH_EVENT; | ||
| 6703 | event.frame_or_window = Qnil; | ||
| 6704 | event.arg = Qnil; | ||
| 6705 | |||
| 6706 | /* We don't need a buffer-switch event unless Emacs is waiting for input. | 6703 | /* We don't need a buffer-switch event unless Emacs is waiting for input. |
| 6707 | The purpose of the event is to make read_key_sequence look up the | 6704 | The purpose of the event is to make read_key_sequence look up the |
| 6708 | keymaps again. If we aren't in read_key_sequence, we don't need one, | 6705 | keymaps again. If we aren't in read_key_sequence, we don't need one, |
| 6709 | and the event could cause trouble by messing up (input-pending-p). | 6706 | and the event could cause trouble by messing up (input-pending-p). |
| 6710 | Note: Fwaiting_for_user_input_p always returns nil when async | 6707 | Note: Fwaiting_for_user_input_p always returns nil when async |
| 6711 | subprocesses aren't supported. */ | 6708 | subprocesses aren't supported. */ |
| 6712 | tem = Fwaiting_for_user_input_p (); | 6709 | if (!NILP (Fwaiting_for_user_input_p ())) |
| 6713 | if (NILP (tem)) | 6710 | { |
| 6714 | return; | 6711 | struct input_event event; |
| 6715 | 6712 | ||
| 6716 | /* Make sure no interrupt happens while storing the event. */ | 6713 | EVENT_INIT (event); |
| 6714 | event.kind = BUFFER_SWITCH_EVENT; | ||
| 6715 | event.frame_or_window = Qnil; | ||
| 6716 | event.arg = Qnil; | ||
| 6717 | |||
| 6718 | /* Make sure no interrupt happens while storing the event. */ | ||
| 6717 | #ifdef USABLE_SIGIO | 6719 | #ifdef USABLE_SIGIO |
| 6718 | if (interrupt_input) | 6720 | if (interrupt_input) |
| 6719 | kbd_buffer_store_event (&event); | 6721 | kbd_buffer_store_event (&event); |
| 6720 | else | 6722 | else |
| 6721 | #endif | 6723 | #endif |
| 6722 | { | 6724 | { |
| 6723 | stop_polling (); | 6725 | stop_polling (); |
| 6724 | kbd_buffer_store_event (&event); | 6726 | kbd_buffer_store_event (&event); |
| 6725 | start_polling (); | 6727 | start_polling (); |
| 6728 | } | ||
| 6726 | } | 6729 | } |
| 6727 | } | 6730 | } |
| 6728 | 6731 | ||
| 6729 | /* Read any terminal input already buffered up by the system | 6732 | /* Read any terminal input already buffered up by the system |
| 6730 | into the kbd_buffer, but do not wait. | 6733 | into the kbd_buffer, but do not wait. |
| 6731 | 6734 | ||
| @@ -6763,7 +6766,7 @@ gobble_input (void) | |||
| 6763 | hold_quit.kind = NO_EVENT; | 6766 | hold_quit.kind = NO_EVENT; |
| 6764 | 6767 | ||
| 6765 | /* No need for FIONREAD or fcntl; just say don't wait. */ | 6768 | /* No need for FIONREAD or fcntl; just say don't wait. */ |
| 6766 | while (0 < (nr = (*t->read_socket_hook) (t, &hold_quit))) | 6769 | while ((nr = (*t->read_socket_hook) (t, &hold_quit)) > 0) |
| 6767 | nread += nr; | 6770 | nread += nr; |
| 6768 | 6771 | ||
| 6769 | if (nr == -1) /* Not OK to read input now. */ | 6772 | if (nr == -1) /* Not OK to read input now. */ |
| @@ -6809,48 +6812,6 @@ gobble_input (void) | |||
| 6809 | return nread; | 6812 | return nread; |
| 6810 | } | 6813 | } |
| 6811 | 6814 | ||
| 6812 | static void | ||
| 6813 | decode_keyboard_code (struct tty_display_info *tty, | ||
| 6814 | struct coding_system *coding, | ||
| 6815 | unsigned char *buf, int nbytes) | ||
| 6816 | { | ||
| 6817 | unsigned char *src = buf; | ||
| 6818 | const unsigned char *p; | ||
| 6819 | int i; | ||
| 6820 | |||
| 6821 | if (nbytes == 0) | ||
| 6822 | return; | ||
| 6823 | if (tty->meta_key != 2) | ||
| 6824 | for (i = 0; i < nbytes; i++) | ||
| 6825 | buf[i] &= ~0x80; | ||
| 6826 | if (coding->carryover_bytes > 0) | ||
| 6827 | { | ||
| 6828 | src = alloca (coding->carryover_bytes + nbytes); | ||
| 6829 | memcpy (src, coding->carryover, coding->carryover_bytes); | ||
| 6830 | memcpy (src + coding->carryover_bytes, buf, nbytes); | ||
| 6831 | nbytes += coding->carryover_bytes; | ||
| 6832 | } | ||
| 6833 | coding->destination = alloca (nbytes * 4); | ||
| 6834 | coding->dst_bytes = nbytes * 4; | ||
| 6835 | decode_coding_c_string (coding, src, nbytes, Qnil); | ||
| 6836 | if (coding->produced_char == 0) | ||
| 6837 | return; | ||
| 6838 | for (i = 0, p = coding->destination; i < coding->produced_char; i++) | ||
| 6839 | { | ||
| 6840 | struct input_event event_buf; | ||
| 6841 | |||
| 6842 | EVENT_INIT (event_buf); | ||
| 6843 | event_buf.code = STRING_CHAR_ADVANCE (p); | ||
| 6844 | event_buf.kind = | ||
| 6845 | (ASCII_CHAR_P (event_buf.code) | ||
| 6846 | ? ASCII_KEYSTROKE_EVENT : MULTIBYTE_CHAR_KEYSTROKE_EVENT); | ||
| 6847 | /* See the comment in tty_read_avail_input. */ | ||
| 6848 | event_buf.frame_or_window = tty->top_frame; | ||
| 6849 | event_buf.arg = Qnil; | ||
| 6850 | kbd_buffer_store_event (&event_buf); | ||
| 6851 | } | ||
| 6852 | } | ||
| 6853 | |||
| 6854 | /* This is the tty way of reading available input. | 6815 | /* This is the tty way of reading available input. |
| 6855 | 6816 | ||
| 6856 | Note that each terminal device has its own `struct terminal' object, | 6817 | Note that each terminal device has its own `struct terminal' object, |
| @@ -6986,10 +6947,7 @@ tty_read_avail_input (struct terminal *terminal, | |||
| 6986 | an EAGAIN error. Does anybody know of a situation | 6947 | an EAGAIN error. Does anybody know of a situation |
| 6987 | where a retry is actually needed? */ | 6948 | where a retry is actually needed? */ |
| 6988 | #if 0 | 6949 | #if 0 |
| 6989 | nread < 0 && (errno == EAGAIN | 6950 | nread < 0 && (errno == EAGAIN || errno == EFAULT |
| 6990 | #ifdef EFAULT | ||
| 6991 | || errno == EFAULT | ||
| 6992 | #endif | ||
| 6993 | #ifdef EBADSLT | 6951 | #ifdef EBADSLT |
| 6994 | || errno == EBADSLT | 6952 | || errno == EBADSLT |
| 6995 | #endif | 6953 | #endif |
| @@ -7011,36 +6969,6 @@ tty_read_avail_input (struct terminal *terminal, | |||
| 7011 | #endif /* not MSDOS */ | 6969 | #endif /* not MSDOS */ |
| 7012 | #endif /* not WINDOWSNT */ | 6970 | #endif /* not WINDOWSNT */ |
| 7013 | 6971 | ||
| 7014 | if (TERMINAL_KEYBOARD_CODING (terminal)->common_flags | ||
| 7015 | & CODING_REQUIRE_DECODING_MASK) | ||
| 7016 | { | ||
| 7017 | struct coding_system *coding = TERMINAL_KEYBOARD_CODING (terminal); | ||
| 7018 | int from; | ||
| 7019 | |||
| 7020 | /* Decode the key sequence except for those with meta | ||
| 7021 | modifiers. */ | ||
| 7022 | for (i = from = 0; ; i++) | ||
| 7023 | if (i == nread || (tty->meta_key == 1 && (cbuf[i] & 0x80))) | ||
| 7024 | { | ||
| 7025 | struct input_event buf; | ||
| 7026 | |||
| 7027 | decode_keyboard_code (tty, coding, cbuf + from, i - from); | ||
| 7028 | if (i == nread) | ||
| 7029 | break; | ||
| 7030 | |||
| 7031 | EVENT_INIT (buf); | ||
| 7032 | buf.kind = ASCII_KEYSTROKE_EVENT; | ||
| 7033 | buf.modifiers = meta_modifier; | ||
| 7034 | buf.code = cbuf[i] & ~0x80; | ||
| 7035 | /* See the comment below. */ | ||
| 7036 | buf.frame_or_window = tty->top_frame; | ||
| 7037 | buf.arg = Qnil; | ||
| 7038 | kbd_buffer_store_event (&buf); | ||
| 7039 | from = i + 1; | ||
| 7040 | } | ||
| 7041 | return nread; | ||
| 7042 | } | ||
| 7043 | |||
| 7044 | for (i = 0; i < nread; i++) | 6972 | for (i = 0; i < nread; i++) |
| 7045 | { | 6973 | { |
| 7046 | struct input_event buf; | 6974 | struct input_event buf; |
| @@ -8307,14 +8235,13 @@ init_tool_bar_items (Lisp_Object reuse) | |||
| 8307 | static void | 8235 | static void |
| 8308 | append_tool_bar_item (void) | 8236 | append_tool_bar_item (void) |
| 8309 | { | 8237 | { |
| 8310 | ptrdiff_t incr = | 8238 | ptrdiff_t incr |
| 8311 | (ntool_bar_items | 8239 | = (ntool_bar_items |
| 8312 | - (ASIZE (tool_bar_items_vector) - TOOL_BAR_ITEM_NSLOTS)); | 8240 | - (ASIZE (tool_bar_items_vector) - TOOL_BAR_ITEM_NSLOTS)); |
| 8313 | 8241 | ||
| 8314 | /* Enlarge tool_bar_items_vector if necessary. */ | 8242 | /* Enlarge tool_bar_items_vector if necessary. */ |
| 8315 | if (0 < incr) | 8243 | if (incr > 0) |
| 8316 | tool_bar_items_vector | 8244 | tool_bar_items_vector = larger_vector (tool_bar_items_vector, incr, -1); |
| 8317 | = larger_vector (tool_bar_items_vector, incr, -1); | ||
| 8318 | 8245 | ||
| 8319 | /* Append entries from tool_bar_item_properties to the end of | 8246 | /* Append entries from tool_bar_item_properties to the end of |
| 8320 | tool_bar_items_vector. */ | 8247 | tool_bar_items_vector. */ |
| @@ -8327,8 +8254,8 @@ append_tool_bar_item (void) | |||
| 8327 | 8254 | ||
| 8328 | 8255 | ||
| 8329 | 8256 | ||
| 8330 | /* Read a character using menus based on maps in the array MAPS. | 8257 | /* Read a character using menus based on the keymap MAP. |
| 8331 | NMAPS is the length of MAPS. Return nil if there are no menus in the maps. | 8258 | Return nil if there are no menus in the maps. |
| 8332 | Return t if we displayed a menu but the user rejected it. | 8259 | Return t if we displayed a menu but the user rejected it. |
| 8333 | 8260 | ||
| 8334 | PREV_EVENT is the previous input event, or nil if we are reading | 8261 | PREV_EVENT is the previous input event, or nil if we are reading |
| @@ -8348,28 +8275,17 @@ append_tool_bar_item (void) | |||
| 8348 | and do auto-saving in the inner call of read_char. */ | 8275 | and do auto-saving in the inner call of read_char. */ |
| 8349 | 8276 | ||
| 8350 | static Lisp_Object | 8277 | static Lisp_Object |
| 8351 | read_char_x_menu_prompt (ptrdiff_t nmaps, Lisp_Object *maps, | 8278 | read_char_x_menu_prompt (Lisp_Object map, |
| 8352 | Lisp_Object prev_event, bool *used_mouse_menu) | 8279 | Lisp_Object prev_event, bool *used_mouse_menu) |
| 8353 | { | 8280 | { |
| 8354 | #ifdef HAVE_MENUS | ||
| 8355 | ptrdiff_t mapno; | ||
| 8356 | #endif | ||
| 8357 | |||
| 8358 | if (used_mouse_menu) | 8281 | if (used_mouse_menu) |
| 8359 | *used_mouse_menu = 0; | 8282 | *used_mouse_menu = 0; |
| 8360 | 8283 | ||
| 8361 | /* Use local over global Menu maps */ | 8284 | /* Use local over global Menu maps. */ |
| 8362 | 8285 | ||
| 8363 | if (! menu_prompting) | 8286 | if (! menu_prompting) |
| 8364 | return Qnil; | 8287 | return Qnil; |
| 8365 | 8288 | ||
| 8366 | /* Optionally disregard all but the global map. */ | ||
| 8367 | if (inhibit_local_menu_bar_menus) | ||
| 8368 | { | ||
| 8369 | maps += (nmaps - 1); | ||
| 8370 | nmaps = 1; | ||
| 8371 | } | ||
| 8372 | |||
| 8373 | #ifdef HAVE_MENUS | 8289 | #ifdef HAVE_MENUS |
| 8374 | /* If we got to this point via a mouse click, | 8290 | /* If we got to this point via a mouse click, |
| 8375 | use a real menu for mouse selection. */ | 8291 | use a real menu for mouse selection. */ |
| @@ -8378,16 +8294,9 @@ read_char_x_menu_prompt (ptrdiff_t nmaps, Lisp_Object *maps, | |||
| 8378 | && !EQ (XCAR (prev_event), Qtool_bar)) | 8294 | && !EQ (XCAR (prev_event), Qtool_bar)) |
| 8379 | { | 8295 | { |
| 8380 | /* Display the menu and get the selection. */ | 8296 | /* Display the menu and get the selection. */ |
| 8381 | Lisp_Object *realmaps = alloca (nmaps * sizeof *realmaps); | ||
| 8382 | Lisp_Object value; | 8297 | Lisp_Object value; |
| 8383 | ptrdiff_t nmaps1 = 0; | ||
| 8384 | |||
| 8385 | /* Use the maps that are not nil. */ | ||
| 8386 | for (mapno = 0; mapno < nmaps; mapno++) | ||
| 8387 | if (!NILP (maps[mapno])) | ||
| 8388 | realmaps[nmaps1++] = maps[mapno]; | ||
| 8389 | 8298 | ||
| 8390 | value = Fx_popup_menu (prev_event, Flist (nmaps1, realmaps)); | 8299 | value = Fx_popup_menu (prev_event, get_keymap (map, 0, 1)); |
| 8391 | if (CONSP (value)) | 8300 | if (CONSP (value)) |
| 8392 | { | 8301 | { |
| 8393 | Lisp_Object tem; | 8302 | Lisp_Object tem; |
| @@ -8427,17 +8336,10 @@ read_char_x_menu_prompt (ptrdiff_t nmaps, Lisp_Object *maps, | |||
| 8427 | return Qnil ; | 8336 | return Qnil ; |
| 8428 | } | 8337 | } |
| 8429 | 8338 | ||
| 8430 | /* Buffer in use so far for the minibuf prompts for menu keymaps. | ||
| 8431 | We make this bigger when necessary, and never free it. */ | ||
| 8432 | static char *read_char_minibuf_menu_text; | ||
| 8433 | /* Size of that buffer. */ | ||
| 8434 | static ptrdiff_t read_char_minibuf_menu_width; | ||
| 8435 | |||
| 8436 | static Lisp_Object | 8339 | static Lisp_Object |
| 8437 | read_char_minibuf_menu_prompt (int commandflag, | 8340 | read_char_minibuf_menu_prompt (int commandflag, |
| 8438 | ptrdiff_t nmaps, Lisp_Object *maps) | 8341 | Lisp_Object map) |
| 8439 | { | 8342 | { |
| 8440 | ptrdiff_t mapno; | ||
| 8441 | register Lisp_Object name; | 8343 | register Lisp_Object name; |
| 8442 | ptrdiff_t nlength; | 8344 | ptrdiff_t nlength; |
| 8443 | /* FIXME: Use the minibuffer's frame width. */ | 8345 | /* FIXME: Use the minibuffer's frame width. */ |
| @@ -8445,53 +8347,35 @@ read_char_minibuf_menu_prompt (int commandflag, | |||
| 8445 | ptrdiff_t idx = -1; | 8347 | ptrdiff_t idx = -1; |
| 8446 | bool nobindings = 1; | 8348 | bool nobindings = 1; |
| 8447 | Lisp_Object rest, vector; | 8349 | Lisp_Object rest, vector; |
| 8448 | char *menu; | 8350 | Lisp_Object prompt_strings = Qnil; |
| 8449 | 8351 | ||
| 8450 | vector = Qnil; | 8352 | vector = Qnil; |
| 8451 | name = Qnil; | ||
| 8452 | 8353 | ||
| 8453 | if (! menu_prompting) | 8354 | if (! menu_prompting) |
| 8454 | return Qnil; | 8355 | return Qnil; |
| 8455 | 8356 | ||
| 8456 | /* Get the menu name from the first map that has one (a prompt string). */ | 8357 | map = get_keymap (map, 0, 1); |
| 8457 | for (mapno = 0; mapno < nmaps; mapno++) | 8358 | name = Fkeymap_prompt (map); |
| 8458 | { | ||
| 8459 | name = Fkeymap_prompt (maps[mapno]); | ||
| 8460 | if (!NILP (name)) | ||
| 8461 | break; | ||
| 8462 | } | ||
| 8463 | 8359 | ||
| 8464 | /* If we don't have any menus, just read a character normally. */ | 8360 | /* If we don't have any menus, just read a character normally. */ |
| 8465 | if (!STRINGP (name)) | 8361 | if (!STRINGP (name)) |
| 8466 | return Qnil; | 8362 | return Qnil; |
| 8467 | 8363 | ||
| 8468 | /* Make sure we have a big enough buffer for the menu text. */ | 8364 | #define PUSH_C_STR(str, listvar) \ |
| 8469 | width = max (width, SBYTES (name)); | 8365 | listvar = Fcons (make_unibyte_string (str, strlen (str)), listvar) |
| 8470 | if (STRING_BYTES_BOUND - 4 < width) | ||
| 8471 | memory_full (SIZE_MAX); | ||
| 8472 | if (width + 4 > read_char_minibuf_menu_width) | ||
| 8473 | { | ||
| 8474 | read_char_minibuf_menu_text | ||
| 8475 | = xrealloc (read_char_minibuf_menu_text, width + 4); | ||
| 8476 | read_char_minibuf_menu_width = width + 4; | ||
| 8477 | } | ||
| 8478 | menu = read_char_minibuf_menu_text; | ||
| 8479 | 8366 | ||
| 8480 | /* Prompt string always starts with map's prompt, and a space. */ | 8367 | /* Prompt string always starts with map's prompt, and a space. */ |
| 8481 | strcpy (menu, SSDATA (name)); | 8368 | prompt_strings = Fcons (name, prompt_strings); |
| 8482 | nlength = SBYTES (name); | 8369 | PUSH_C_STR (": ", prompt_strings); |
| 8483 | menu[nlength++] = ':'; | 8370 | nlength = SCHARS (name) + 2; |
| 8484 | menu[nlength++] = ' '; | ||
| 8485 | menu[nlength] = 0; | ||
| 8486 | 8371 | ||
| 8487 | /* Start prompting at start of first map. */ | 8372 | rest = map; |
| 8488 | mapno = 0; | ||
| 8489 | rest = maps[mapno]; | ||
| 8490 | 8373 | ||
| 8491 | /* Present the documented bindings, a line at a time. */ | 8374 | /* Present the documented bindings, a line at a time. */ |
| 8492 | while (1) | 8375 | while (1) |
| 8493 | { | 8376 | { |
| 8494 | bool notfirst = 0; | 8377 | bool notfirst = 0; |
| 8378 | Lisp_Object menu_strings = prompt_strings; | ||
| 8495 | ptrdiff_t i = nlength; | 8379 | ptrdiff_t i = nlength; |
| 8496 | Lisp_Object obj; | 8380 | Lisp_Object obj; |
| 8497 | Lisp_Object orig_defn_macro; | 8381 | Lisp_Object orig_defn_macro; |
| @@ -8501,18 +8385,16 @@ read_char_minibuf_menu_prompt (int commandflag, | |||
| 8501 | { | 8385 | { |
| 8502 | Lisp_Object elt; | 8386 | Lisp_Object elt; |
| 8503 | 8387 | ||
| 8504 | /* If reached end of map, start at beginning of next map. */ | 8388 | /* FIXME: Use map_keymap to handle new keymap formats. */ |
| 8389 | |||
| 8390 | /* At end of map, wrap around if just starting, | ||
| 8391 | or end this line if already have something on it. */ | ||
| 8505 | if (NILP (rest)) | 8392 | if (NILP (rest)) |
| 8506 | { | 8393 | { |
| 8507 | mapno++; | 8394 | if (notfirst || nobindings) |
| 8508 | /* At end of last map, wrap around to first map if just starting, | 8395 | break; |
| 8509 | or end this line if already have something on it. */ | 8396 | else |
| 8510 | if (mapno == nmaps) | 8397 | rest = map; |
| 8511 | { | ||
| 8512 | mapno = 0; | ||
| 8513 | if (notfirst || nobindings) break; | ||
| 8514 | } | ||
| 8515 | rest = maps[mapno]; | ||
| 8516 | } | 8398 | } |
| 8517 | 8399 | ||
| 8518 | /* Look at the next element of the map. */ | 8400 | /* Look at the next element of the map. */ |
| @@ -8596,7 +8478,7 @@ read_char_minibuf_menu_prompt (int commandflag, | |||
| 8596 | /* Punctuate between strings. */ | 8478 | /* Punctuate between strings. */ |
| 8597 | if (notfirst) | 8479 | if (notfirst) |
| 8598 | { | 8480 | { |
| 8599 | strcpy (menu + i, ", "); | 8481 | PUSH_C_STR (", ", menu_strings); |
| 8600 | i += 2; | 8482 | i += 2; |
| 8601 | } | 8483 | } |
| 8602 | notfirst = 1; | 8484 | notfirst = 1; |
| @@ -8608,23 +8490,28 @@ read_char_minibuf_menu_prompt (int commandflag, | |||
| 8608 | { | 8490 | { |
| 8609 | /* Add as much of string as fits. */ | 8491 | /* Add as much of string as fits. */ |
| 8610 | thiswidth = min (SCHARS (desc), width - i); | 8492 | thiswidth = min (SCHARS (desc), width - i); |
| 8611 | memcpy (menu + i, SDATA (desc), thiswidth); | 8493 | menu_strings |
| 8494 | = Fcons (Fsubstring (desc, make_number (0), | ||
| 8495 | make_number (thiswidth)), | ||
| 8496 | menu_strings); | ||
| 8612 | i += thiswidth; | 8497 | i += thiswidth; |
| 8613 | strcpy (menu + i, " = "); | 8498 | PUSH_C_STR (" = ", menu_strings); |
| 8614 | i += 3; | 8499 | i += 3; |
| 8615 | } | 8500 | } |
| 8616 | 8501 | ||
| 8617 | /* Add as much of string as fits. */ | 8502 | /* Add as much of string as fits. */ |
| 8618 | thiswidth = min (SCHARS (s), width - i); | 8503 | thiswidth = min (SCHARS (s), width - i); |
| 8619 | memcpy (menu + i, SDATA (s), thiswidth); | 8504 | menu_strings |
| 8505 | = Fcons (Fsubstring (s, make_number (0), | ||
| 8506 | make_number (thiswidth)), | ||
| 8507 | menu_strings); | ||
| 8620 | i += thiswidth; | 8508 | i += thiswidth; |
| 8621 | menu[i] = 0; | ||
| 8622 | } | 8509 | } |
| 8623 | else | 8510 | else |
| 8624 | { | 8511 | { |
| 8625 | /* If this element does not fit, end the line now, | 8512 | /* If this element does not fit, end the line now, |
| 8626 | and save the element for the next line. */ | 8513 | and save the element for the next line. */ |
| 8627 | strcpy (menu + i, "..."); | 8514 | PUSH_C_STR ("...", menu_strings); |
| 8628 | break; | 8515 | break; |
| 8629 | } | 8516 | } |
| 8630 | } | 8517 | } |
| @@ -8641,23 +8528,19 @@ read_char_minibuf_menu_prompt (int commandflag, | |||
| 8641 | } | 8528 | } |
| 8642 | 8529 | ||
| 8643 | /* Prompt with that and read response. */ | 8530 | /* Prompt with that and read response. */ |
| 8644 | message2_nolog (menu, strlen (menu), | 8531 | message3_nolog (apply1 (intern ("concat"), Fnreverse (menu_strings))); |
| 8645 | ! NILP (BVAR (current_buffer, enable_multibyte_characters))); | ||
| 8646 | 8532 | ||
| 8647 | /* Make believe its not a keyboard macro in case the help char | 8533 | /* Make believe it's not a keyboard macro in case the help char |
| 8648 | is pressed. Help characters are not recorded because menu prompting | 8534 | is pressed. Help characters are not recorded because menu prompting |
| 8649 | is not used on replay. | 8535 | is not used on replay. */ |
| 8650 | */ | ||
| 8651 | orig_defn_macro = KVAR (current_kboard, defining_kbd_macro); | 8536 | orig_defn_macro = KVAR (current_kboard, defining_kbd_macro); |
| 8652 | kset_defining_kbd_macro (current_kboard, Qnil); | 8537 | kset_defining_kbd_macro (current_kboard, Qnil); |
| 8653 | do | 8538 | do |
| 8654 | obj = read_char (commandflag, 0, 0, Qt, 0, NULL); | 8539 | obj = read_char (commandflag, Qnil, Qt, 0, NULL); |
| 8655 | while (BUFFERP (obj)); | 8540 | while (BUFFERP (obj)); |
| 8656 | kset_defining_kbd_macro (current_kboard, orig_defn_macro); | 8541 | kset_defining_kbd_macro (current_kboard, orig_defn_macro); |
| 8657 | 8542 | ||
| 8658 | if (!INTEGERP (obj)) | 8543 | if (!INTEGERP (obj) || XINT (obj) == -2) |
| 8659 | return obj; | ||
| 8660 | else if (XINT (obj) == -2) | ||
| 8661 | return obj; | 8544 | return obj; |
| 8662 | 8545 | ||
| 8663 | if (! EQ (obj, menu_prompt_more_char) | 8546 | if (! EQ (obj, menu_prompt_more_char) |
| @@ -8668,52 +8551,25 @@ read_char_minibuf_menu_prompt (int commandflag, | |||
| 8668 | store_kbd_macro_char (obj); | 8551 | store_kbd_macro_char (obj); |
| 8669 | return obj; | 8552 | return obj; |
| 8670 | } | 8553 | } |
| 8671 | /* Help char - go round again */ | 8554 | /* Help char - go round again. */ |
| 8672 | } | 8555 | } |
| 8673 | } | 8556 | } |
| 8674 | 8557 | ||
| 8675 | /* Reading key sequences. */ | 8558 | /* Reading key sequences. */ |
| 8676 | 8559 | ||
| 8677 | /* Follow KEY in the maps in CURRENT[0..NMAPS-1], placing its bindings | 8560 | static Lisp_Object |
| 8678 | in DEFS[0..NMAPS-1]. Set NEXT[i] to DEFS[i] if DEFS[i] is a | 8561 | follow_key (Lisp_Object keymap, Lisp_Object key) |
| 8679 | keymap, or nil otherwise. Return the index of the first keymap in | ||
| 8680 | which KEY has any binding, or NMAPS if no map has a binding. | ||
| 8681 | |||
| 8682 | If KEY is a meta ASCII character, treat it like meta-prefix-char | ||
| 8683 | followed by the corresponding non-meta character. Keymaps in | ||
| 8684 | CURRENT with non-prefix bindings for meta-prefix-char become nil in | ||
| 8685 | NEXT. | ||
| 8686 | |||
| 8687 | If KEY has no bindings in any of the CURRENT maps, NEXT is left | ||
| 8688 | unmodified. | ||
| 8689 | |||
| 8690 | NEXT may be the same array as CURRENT. */ | ||
| 8691 | |||
| 8692 | static int | ||
| 8693 | follow_key (Lisp_Object key, ptrdiff_t nmaps, Lisp_Object *current, | ||
| 8694 | Lisp_Object *defs, Lisp_Object *next) | ||
| 8695 | { | 8562 | { |
| 8696 | ptrdiff_t i, first_binding; | 8563 | return access_keymap (get_keymap (keymap, 0, 1), |
| 8697 | 8564 | key, 1, 0, 1); | |
| 8698 | first_binding = nmaps; | 8565 | } |
| 8699 | for (i = nmaps - 1; i >= 0; i--) | ||
| 8700 | { | ||
| 8701 | if (! NILP (current[i])) | ||
| 8702 | { | ||
| 8703 | defs[i] = access_keymap (current[i], key, 1, 0, 1); | ||
| 8704 | if (! NILP (defs[i])) | ||
| 8705 | first_binding = i; | ||
| 8706 | } | ||
| 8707 | else | ||
| 8708 | defs[i] = Qnil; | ||
| 8709 | } | ||
| 8710 | |||
| 8711 | /* Given the set of bindings we've found, produce the next set of maps. */ | ||
| 8712 | if (first_binding < nmaps) | ||
| 8713 | for (i = 0; i < nmaps; i++) | ||
| 8714 | next[i] = NILP (defs[i]) ? Qnil : get_keymap (defs[i], 0, 1); | ||
| 8715 | 8566 | ||
| 8716 | return first_binding; | 8567 | static Lisp_Object |
| 8568 | active_maps (Lisp_Object first_event) | ||
| 8569 | { | ||
| 8570 | Lisp_Object position | ||
| 8571 | = CONSP (first_event) ? CAR_SAFE (XCDR (first_event)) : Qnil; | ||
| 8572 | return Fcons (Qkeymap, Fcurrent_active_maps (Qt, position)); | ||
| 8717 | } | 8573 | } |
| 8718 | 8574 | ||
| 8719 | /* Structure used to keep track of partial application of key remapping | 8575 | /* Structure used to keep track of partial application of key remapping |
| @@ -8767,7 +8623,7 @@ access_keymap_keyremap (Lisp_Object map, Lisp_Object key, Lisp_Object prompt, | |||
| 8767 | barf--don't ignore it. | 8623 | barf--don't ignore it. |
| 8768 | (To ignore it safely, we would need to gcpro a bunch of | 8624 | (To ignore it safely, we would need to gcpro a bunch of |
| 8769 | other variables.) */ | 8625 | other variables.) */ |
| 8770 | if (! (VECTORP (next) || STRINGP (next))) | 8626 | if (! (NILP (next) || VECTORP (next) || STRINGP (next))) |
| 8771 | error ("Function %s returns invalid key sequence", | 8627 | error ("Function %s returns invalid key sequence", |
| 8772 | SSDATA (SYMBOL_NAME (tem))); | 8628 | SSDATA (SYMBOL_NAME (tem))); |
| 8773 | } | 8629 | } |
| @@ -8845,11 +8701,77 @@ keyremap_step (Lisp_Object *keybuf, int bufsize, volatile keyremap *fkey, | |||
| 8845 | static bool | 8701 | static bool |
| 8846 | test_undefined (Lisp_Object binding) | 8702 | test_undefined (Lisp_Object binding) |
| 8847 | { | 8703 | { |
| 8848 | return (EQ (binding, Qundefined) | 8704 | return (NILP (binding) |
| 8849 | || (!NILP (binding) && SYMBOLP (binding) | 8705 | || EQ (binding, Qundefined) |
| 8706 | || (SYMBOLP (binding) | ||
| 8850 | && EQ (Fcommand_remapping (binding, Qnil, Qnil), Qundefined))); | 8707 | && EQ (Fcommand_remapping (binding, Qnil, Qnil), Qundefined))); |
| 8851 | } | 8708 | } |
| 8852 | 8709 | ||
| 8710 | /* Like `read_char' but applies keyboard-coding-system to tty input. */ | ||
| 8711 | static Lisp_Object | ||
| 8712 | read_decoded_char (int commandflag, Lisp_Object map, | ||
| 8713 | Lisp_Object prev_event, bool *used_mouse_menu) | ||
| 8714 | { | ||
| 8715 | #define MAX_ENCODED_BYTES 16 | ||
| 8716 | Lisp_Object events[MAX_ENCODED_BYTES]; | ||
| 8717 | int n = 0; | ||
| 8718 | while (true) | ||
| 8719 | { | ||
| 8720 | Lisp_Object nextevt | ||
| 8721 | = read_char (commandflag, map, prev_event, used_mouse_menu, NULL); | ||
| 8722 | struct frame *frame = XFRAME (selected_frame); | ||
| 8723 | struct terminal *terminal = frame->terminal; | ||
| 8724 | if (!((FRAME_TERMCAP_P (frame) || FRAME_MSDOS_P (frame)) | ||
| 8725 | && (TERMINAL_KEYBOARD_CODING (terminal)->common_flags | ||
| 8726 | & CODING_REQUIRE_DECODING_MASK))) | ||
| 8727 | return nextevt; /* No decoding needed. */ | ||
| 8728 | else | ||
| 8729 | { | ||
| 8730 | int meta_key = terminal->display_info.tty->meta_key; | ||
| 8731 | eassert (n < MAX_ENCODED_BYTES); | ||
| 8732 | events[n++] = nextevt; | ||
| 8733 | if (NATNUMP (nextevt) | ||
| 8734 | && XINT (nextevt) < (meta_key == 1 ? 0x80 : 0x100)) | ||
| 8735 | { /* An encoded byte sequence, let's try to decode it. */ | ||
| 8736 | struct coding_system *coding | ||
| 8737 | = TERMINAL_KEYBOARD_CODING (terminal); | ||
| 8738 | unsigned char *src = alloca (n); | ||
| 8739 | int i; | ||
| 8740 | for (i = 0; i < n; i++) | ||
| 8741 | src[i] = XINT (events[i]); | ||
| 8742 | if (meta_key != 2) | ||
| 8743 | for (i = 0; i < n; i++) | ||
| 8744 | src[i] &= ~0x80; | ||
| 8745 | coding->destination = alloca (n * 4); | ||
| 8746 | coding->dst_bytes = n * 4; | ||
| 8747 | decode_coding_c_string (coding, src, n, Qnil); | ||
| 8748 | eassert (coding->produced_char <= n); | ||
| 8749 | if (coding->produced_char == 0) | ||
| 8750 | { /* The encoded sequence is incomplete. */ | ||
| 8751 | if (n < MAX_ENCODED_BYTES) /* Avoid buffer overflow. */ | ||
| 8752 | continue; /* Read on! */ | ||
| 8753 | } | ||
| 8754 | else | ||
| 8755 | { | ||
| 8756 | const unsigned char *p = coding->destination; | ||
| 8757 | eassert (coding->carryover_bytes == 0); | ||
| 8758 | n = 0; | ||
| 8759 | while (n < coding->produced_char) | ||
| 8760 | events[n++] = make_number (STRING_CHAR_ADVANCE (p)); | ||
| 8761 | } | ||
| 8762 | } | ||
| 8763 | /* Now `events' should hold decoded events. | ||
| 8764 | Normally, n should be equal to 1, but better not rely on it. | ||
| 8765 | We can only return one event here, so return the first we | ||
| 8766 | had and keep the others (if any) for later. */ | ||
| 8767 | while (n > 1) | ||
| 8768 | Vunread_command_events | ||
| 8769 | = Fcons (events[--n], Vunread_command_events); | ||
| 8770 | return events[0]; | ||
| 8771 | } | ||
| 8772 | } | ||
| 8773 | } | ||
| 8774 | |||
| 8853 | /* Read a sequence of keys that ends with a non prefix character, | 8775 | /* Read a sequence of keys that ends with a non prefix character, |
| 8854 | storing it in KEYBUF, a buffer of size BUFSIZE. | 8776 | storing it in KEYBUF, a buffer of size BUFSIZE. |
| 8855 | Prompt with PROMPT. | 8777 | Prompt with PROMPT. |
| @@ -8892,7 +8814,6 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt, | |||
| 8892 | bool dont_downcase_last, bool can_return_switch_frame, | 8814 | bool dont_downcase_last, bool can_return_switch_frame, |
| 8893 | bool fix_current_buffer) | 8815 | bool fix_current_buffer) |
| 8894 | { | 8816 | { |
| 8895 | Lisp_Object from_string; | ||
| 8896 | ptrdiff_t count = SPECPDL_INDEX (); | 8817 | ptrdiff_t count = SPECPDL_INDEX (); |
| 8897 | 8818 | ||
| 8898 | /* How many keys there are in the current key sequence. */ | 8819 | /* How many keys there are in the current key sequence. */ |
| @@ -8903,34 +8824,9 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt, | |||
| 8903 | ptrdiff_t echo_start IF_LINT (= 0); | 8824 | ptrdiff_t echo_start IF_LINT (= 0); |
| 8904 | ptrdiff_t keys_start; | 8825 | ptrdiff_t keys_start; |
| 8905 | 8826 | ||
| 8906 | /* The number of keymaps we're scanning right now, and the number of | 8827 | Lisp_Object current_binding = Qnil; |
| 8907 | keymaps we have allocated space for. */ | 8828 | Lisp_Object first_event = Qnil; |
| 8908 | ptrdiff_t nmaps; | ||
| 8909 | ptrdiff_t nmaps_allocated = 0; | ||
| 8910 | |||
| 8911 | /* defs[0..nmaps-1] are the definitions of KEYBUF[0..t-1] in | ||
| 8912 | the current keymaps. */ | ||
| 8913 | Lisp_Object *defs = NULL; | ||
| 8914 | |||
| 8915 | /* submaps[0..nmaps-1] are the prefix definitions of KEYBUF[0..t-1] | ||
| 8916 | in the current keymaps, or nil where it is not a prefix. */ | ||
| 8917 | Lisp_Object *submaps = NULL; | ||
| 8918 | |||
| 8919 | /* The local map to start out with at start of key sequence. */ | ||
| 8920 | Lisp_Object orig_local_map; | ||
| 8921 | 8829 | ||
| 8922 | /* The map from the `keymap' property to start out with at start of | ||
| 8923 | key sequence. */ | ||
| 8924 | Lisp_Object orig_keymap; | ||
| 8925 | |||
| 8926 | /* Positive if we have already considered switching to the local-map property | ||
| 8927 | of the place where a mouse click occurred. */ | ||
| 8928 | int localized_local_map = 0; | ||
| 8929 | |||
| 8930 | /* The index in submaps[] of the first keymap that has a binding for | ||
| 8931 | this key sequence. In other words, the lowest i such that | ||
| 8932 | submaps[i] is non-nil. */ | ||
| 8933 | ptrdiff_t first_binding; | ||
| 8934 | /* Index of the first key that has no binding. | 8830 | /* Index of the first key that has no binding. |
| 8935 | It is useless to try fkey.start larger than that. */ | 8831 | It is useless to try fkey.start larger than that. */ |
| 8936 | int first_unbound; | 8832 | int first_unbound; |
| @@ -8973,11 +8869,6 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt, | |||
| 8973 | While we're reading, we keep the event here. */ | 8869 | While we're reading, we keep the event here. */ |
| 8974 | Lisp_Object delayed_switch_frame; | 8870 | Lisp_Object delayed_switch_frame; |
| 8975 | 8871 | ||
| 8976 | /* See the comment below... */ | ||
| 8977 | #if defined (GOBBLE_FIRST_EVENT) | ||
| 8978 | Lisp_Object first_event; | ||
| 8979 | #endif | ||
| 8980 | |||
| 8981 | Lisp_Object original_uppercase IF_LINT (= Qnil); | 8872 | Lisp_Object original_uppercase IF_LINT (= Qnil); |
| 8982 | int original_uppercase_position = -1; | 8873 | int original_uppercase_position = -1; |
| 8983 | 8874 | ||
| @@ -8989,10 +8880,6 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt, | |||
| 8989 | /* List of events for which a fake prefix key has been generated. */ | 8880 | /* List of events for which a fake prefix key has been generated. */ |
| 8990 | Lisp_Object fake_prefixed_keys = Qnil; | 8881 | Lisp_Object fake_prefixed_keys = Qnil; |
| 8991 | 8882 | ||
| 8992 | #if defined (GOBBLE_FIRST_EVENT) | ||
| 8993 | int junk; | ||
| 8994 | #endif | ||
| 8995 | |||
| 8996 | struct gcpro gcpro1; | 8883 | struct gcpro gcpro1; |
| 8997 | 8884 | ||
| 8998 | GCPRO1 (fake_prefixed_keys); | 8885 | GCPRO1 (fake_prefixed_keys); |
| @@ -9028,21 +8915,6 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt, | |||
| 9028 | keys_start = this_command_key_count; | 8915 | keys_start = this_command_key_count; |
| 9029 | this_single_command_key_start = keys_start; | 8916 | this_single_command_key_start = keys_start; |
| 9030 | 8917 | ||
| 9031 | #if defined (GOBBLE_FIRST_EVENT) | ||
| 9032 | /* This doesn't quite work, because some of the things that read_char | ||
| 9033 | does cannot safely be bypassed. It seems too risky to try to make | ||
| 9034 | this work right. */ | ||
| 9035 | |||
| 9036 | /* Read the first char of the sequence specially, before setting | ||
| 9037 | up any keymaps, in case a filter runs and switches buffers on us. */ | ||
| 9038 | first_event = read_char (NILP (prompt), 0, submaps, last_nonmenu_event, | ||
| 9039 | &junk, NULL); | ||
| 9040 | #endif /* GOBBLE_FIRST_EVENT */ | ||
| 9041 | |||
| 9042 | orig_local_map = get_local_map (PT, current_buffer, Qlocal_map); | ||
| 9043 | orig_keymap = get_local_map (PT, current_buffer, Qkeymap); | ||
| 9044 | from_string = Qnil; | ||
| 9045 | |||
| 9046 | /* We jump here when we need to reinitialize fkey and keytran; this | 8918 | /* We jump here when we need to reinitialize fkey and keytran; this |
| 9047 | happens if we switch keyboards between rescans. */ | 8919 | happens if we switch keyboards between rescans. */ |
| 9048 | replay_entire_sequence: | 8920 | replay_entire_sequence: |
| @@ -9067,59 +8939,7 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt, | |||
| 9067 | keybuf with its symbol, or if the sequence starts with a mouse | 8939 | keybuf with its symbol, or if the sequence starts with a mouse |
| 9068 | click and we need to switch buffers, we jump back here to rebuild | 8940 | click and we need to switch buffers, we jump back here to rebuild |
| 9069 | the initial keymaps from the current buffer. */ | 8941 | the initial keymaps from the current buffer. */ |
| 9070 | nmaps = 0; | 8942 | current_binding = active_maps (first_event); |
| 9071 | |||
| 9072 | if (!NILP (KVAR (current_kboard, Voverriding_terminal_local_map))) | ||
| 9073 | { | ||
| 9074 | if (2 > nmaps_allocated) | ||
| 9075 | { | ||
| 9076 | submaps = alloca (2 * sizeof *submaps); | ||
| 9077 | defs = alloca (2 * sizeof *defs); | ||
| 9078 | nmaps_allocated = 2; | ||
| 9079 | } | ||
| 9080 | submaps[nmaps++] = KVAR (current_kboard, Voverriding_terminal_local_map); | ||
| 9081 | } | ||
| 9082 | else if (!NILP (Voverriding_local_map)) | ||
| 9083 | { | ||
| 9084 | if (2 > nmaps_allocated) | ||
| 9085 | { | ||
| 9086 | submaps = alloca (2 * sizeof *submaps); | ||
| 9087 | defs = alloca (2 * sizeof *defs); | ||
| 9088 | nmaps_allocated = 2; | ||
| 9089 | } | ||
| 9090 | submaps[nmaps++] = Voverriding_local_map; | ||
| 9091 | } | ||
| 9092 | else | ||
| 9093 | { | ||
| 9094 | ptrdiff_t nminor; | ||
| 9095 | ptrdiff_t total; | ||
| 9096 | Lisp_Object *maps; | ||
| 9097 | |||
| 9098 | nminor = current_minor_maps (0, &maps); | ||
| 9099 | total = nminor + (!NILP (orig_keymap) ? 3 : 2); | ||
| 9100 | |||
| 9101 | if (total > nmaps_allocated) | ||
| 9102 | { | ||
| 9103 | submaps = alloca (total * sizeof *submaps); | ||
| 9104 | defs = alloca (total * sizeof *defs); | ||
| 9105 | nmaps_allocated = total; | ||
| 9106 | } | ||
| 9107 | |||
| 9108 | if (!NILP (orig_keymap)) | ||
| 9109 | submaps[nmaps++] = orig_keymap; | ||
| 9110 | |||
| 9111 | memcpy (submaps + nmaps, maps, nminor * sizeof (submaps[0])); | ||
| 9112 | |||
| 9113 | nmaps += nminor; | ||
| 9114 | |||
| 9115 | submaps[nmaps++] = orig_local_map; | ||
| 9116 | } | ||
| 9117 | submaps[nmaps++] = current_global_map; | ||
| 9118 | |||
| 9119 | /* Find an accurate initial value for first_binding. */ | ||
| 9120 | for (first_binding = 0; first_binding < nmaps; first_binding++) | ||
| 9121 | if (! NILP (submaps[first_binding])) | ||
| 9122 | break; | ||
| 9123 | 8943 | ||
| 9124 | /* Start from the beginning in keybuf. */ | 8944 | /* Start from the beginning in keybuf. */ |
| 9125 | t = 0; | 8945 | t = 0; |
| @@ -9133,9 +8953,9 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt, | |||
| 9133 | /* If the best binding for the current key sequence is a keymap, or | 8953 | /* If the best binding for the current key sequence is a keymap, or |
| 9134 | we may be looking at a function key's escape sequence, keep on | 8954 | we may be looking at a function key's escape sequence, keep on |
| 9135 | reading. */ | 8955 | reading. */ |
| 9136 | while (first_binding < nmaps | 8956 | while (!NILP (current_binding) |
| 9137 | /* Keep reading as long as there's a prefix binding. */ | 8957 | /* Keep reading as long as there's a prefix binding. */ |
| 9138 | ? !NILP (submaps[first_binding]) | 8958 | ? KEYMAPP (current_binding) |
| 9139 | /* Don't return in the middle of a possible function key sequence, | 8959 | /* Don't return in the middle of a possible function key sequence, |
| 9140 | if the only bindings we found were via case conversion. | 8960 | if the only bindings we found were via case conversion. |
| 9141 | Thus, if ESC O a has a function-key-map translation | 8961 | Thus, if ESC O a has a function-key-map translation |
| @@ -9159,7 +8979,7 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt, | |||
| 9159 | just one key. */ | 8979 | just one key. */ |
| 9160 | ptrdiff_t echo_local_start IF_LINT (= 0); | 8980 | ptrdiff_t echo_local_start IF_LINT (= 0); |
| 9161 | int keys_local_start; | 8981 | int keys_local_start; |
| 9162 | ptrdiff_t local_first_binding; | 8982 | Lisp_Object new_binding; |
| 9163 | 8983 | ||
| 9164 | eassert (indec.end == t || (indec.end > t && indec.end <= mock_input)); | 8984 | eassert (indec.end == t || (indec.end > t && indec.end <= mock_input)); |
| 9165 | eassert (indec.start <= indec.end); | 8985 | eassert (indec.start <= indec.end); |
| @@ -9196,7 +9016,6 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt, | |||
| 9196 | if (INTERACTIVE) | 9016 | if (INTERACTIVE) |
| 9197 | echo_local_start = echo_length (); | 9017 | echo_local_start = echo_length (); |
| 9198 | keys_local_start = this_command_key_count; | 9018 | keys_local_start = this_command_key_count; |
| 9199 | local_first_binding = first_binding; | ||
| 9200 | 9019 | ||
| 9201 | replay_key: | 9020 | replay_key: |
| 9202 | /* These are no-ops, unless we throw away a keystroke below and | 9021 | /* These are no-ops, unless we throw away a keystroke below and |
| @@ -9206,7 +9025,6 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt, | |||
| 9206 | if (INTERACTIVE && t < mock_input) | 9025 | if (INTERACTIVE && t < mock_input) |
| 9207 | echo_truncate (echo_local_start); | 9026 | echo_truncate (echo_local_start); |
| 9208 | this_command_key_count = keys_local_start; | 9027 | this_command_key_count = keys_local_start; |
| 9209 | first_binding = local_first_binding; | ||
| 9210 | 9028 | ||
| 9211 | /* By default, assume each event is "real". */ | 9029 | /* By default, assume each event is "real". */ |
| 9212 | last_real_key_start = t; | 9030 | last_real_key_start = t; |
| @@ -9217,8 +9035,12 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt, | |||
| 9217 | key = keybuf[t]; | 9035 | key = keybuf[t]; |
| 9218 | add_command_key (key); | 9036 | add_command_key (key); |
| 9219 | if ((FLOATP (Vecho_keystrokes) || INTEGERP (Vecho_keystrokes)) | 9037 | if ((FLOATP (Vecho_keystrokes) || INTEGERP (Vecho_keystrokes)) |
| 9220 | && NILP (Fzerop (Vecho_keystrokes))) | 9038 | && NILP (Fzerop (Vecho_keystrokes)) |
| 9221 | echo_char (key); | 9039 | && current_kboard->immediate_echo) |
| 9040 | { | ||
| 9041 | echo_add_key (key); | ||
| 9042 | echo_dash (); | ||
| 9043 | } | ||
| 9222 | } | 9044 | } |
| 9223 | 9045 | ||
| 9224 | /* If not, we should actually read a character. */ | 9046 | /* If not, we should actually read a character. */ |
| @@ -9227,9 +9049,9 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt, | |||
| 9227 | { | 9049 | { |
| 9228 | KBOARD *interrupted_kboard = current_kboard; | 9050 | KBOARD *interrupted_kboard = current_kboard; |
| 9229 | struct frame *interrupted_frame = SELECTED_FRAME (); | 9051 | struct frame *interrupted_frame = SELECTED_FRAME (); |
| 9230 | key = read_char (NILP (prompt), nmaps, | 9052 | key = read_decoded_char (NILP (prompt), |
| 9231 | (Lisp_Object *) submaps, last_nonmenu_event, | 9053 | current_binding, last_nonmenu_event, |
| 9232 | &used_mouse_menu, NULL); | 9054 | &used_mouse_menu); |
| 9233 | if ((INTEGERP (key) && XINT (key) == -2) /* wrong_kboard_jmpbuf */ | 9055 | if ((INTEGERP (key) && XINT (key) == -2) /* wrong_kboard_jmpbuf */ |
| 9234 | /* When switching to a new tty (with a new keyboard), | 9056 | /* When switching to a new tty (with a new keyboard), |
| 9235 | read_char returns the new buffer, rather than -2 | 9057 | read_char returns the new buffer, rather than -2 |
| @@ -9283,8 +9105,6 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt, | |||
| 9283 | KVAR (interrupted_kboard, kbd_queue))); | 9105 | KVAR (interrupted_kboard, kbd_queue))); |
| 9284 | } | 9106 | } |
| 9285 | mock_input = 0; | 9107 | mock_input = 0; |
| 9286 | orig_local_map = get_local_map (PT, current_buffer, Qlocal_map); | ||
| 9287 | orig_keymap = get_local_map (PT, current_buffer, Qkeymap); | ||
| 9288 | goto replay_entire_sequence; | 9108 | goto replay_entire_sequence; |
| 9289 | } | 9109 | } |
| 9290 | } | 9110 | } |
| @@ -9325,12 +9145,11 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt, | |||
| 9325 | { | 9145 | { |
| 9326 | if (! FRAME_LIVE_P (XFRAME (selected_frame))) | 9146 | if (! FRAME_LIVE_P (XFRAME (selected_frame))) |
| 9327 | Fkill_emacs (Qnil); | 9147 | Fkill_emacs (Qnil); |
| 9328 | if (XBUFFER (XWINDOW (selected_window)->buffer) != current_buffer) | 9148 | if (XBUFFER (XWINDOW (selected_window)->contents) |
| 9329 | Fset_buffer (XWINDOW (selected_window)->buffer); | 9149 | != current_buffer) |
| 9150 | Fset_buffer (XWINDOW (selected_window)->contents); | ||
| 9330 | } | 9151 | } |
| 9331 | 9152 | ||
| 9332 | orig_local_map = get_local_map (PT, current_buffer, Qlocal_map); | ||
| 9333 | orig_keymap = get_local_map (PT, current_buffer, Qkeymap); | ||
| 9334 | goto replay_sequence; | 9153 | goto replay_sequence; |
| 9335 | } | 9154 | } |
| 9336 | 9155 | ||
| @@ -9347,8 +9166,6 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt, | |||
| 9347 | keybuf[t++] = key; | 9166 | keybuf[t++] = key; |
| 9348 | mock_input = t; | 9167 | mock_input = t; |
| 9349 | Vquit_flag = Qnil; | 9168 | Vquit_flag = Qnil; |
| 9350 | orig_local_map = get_local_map (PT, current_buffer, Qlocal_map); | ||
| 9351 | orig_keymap = get_local_map (PT, current_buffer, Qkeymap); | ||
| 9352 | goto replay_sequence; | 9169 | goto replay_sequence; |
| 9353 | } | 9170 | } |
| 9354 | 9171 | ||
| @@ -9368,6 +9185,22 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt, | |||
| 9368 | } | 9185 | } |
| 9369 | } | 9186 | } |
| 9370 | 9187 | ||
| 9188 | if (NILP (first_event)) | ||
| 9189 | { | ||
| 9190 | first_event = key; | ||
| 9191 | /* Even if first_event does not specify a particular | ||
| 9192 | window/position, it's important to recompute the maps here | ||
| 9193 | since a long time might have passed since we entered | ||
| 9194 | read_key_sequence, and a timer (or process-filter or | ||
| 9195 | special-event-map, ...) might have switched the current buffer | ||
| 9196 | or the selected window from under us in the mean time. */ | ||
| 9197 | if (fix_current_buffer | ||
| 9198 | && (XBUFFER (XWINDOW (selected_window)->contents) | ||
| 9199 | != current_buffer)) | ||
| 9200 | Fset_buffer (XWINDOW (selected_window)->contents); | ||
| 9201 | current_binding = active_maps (first_event); | ||
| 9202 | } | ||
| 9203 | |||
| 9371 | GROW_RAW_KEYBUF; | 9204 | GROW_RAW_KEYBUF; |
| 9372 | ASET (raw_keybuf, raw_keybuf_count, key); | 9205 | ASET (raw_keybuf, raw_keybuf_count, key); |
| 9373 | raw_keybuf_count++; | 9206 | raw_keybuf_count++; |
| @@ -9389,16 +9222,11 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt, | |||
| 9389 | or when user programs play with this-command-keys. */ | 9222 | or when user programs play with this-command-keys. */ |
| 9390 | if (EVENT_HAS_PARAMETERS (key)) | 9223 | if (EVENT_HAS_PARAMETERS (key)) |
| 9391 | { | 9224 | { |
| 9392 | Lisp_Object kind; | 9225 | Lisp_Object kind = EVENT_HEAD_KIND (EVENT_HEAD (key)); |
| 9393 | Lisp_Object string; | ||
| 9394 | |||
| 9395 | kind = EVENT_HEAD_KIND (EVENT_HEAD (key)); | ||
| 9396 | if (EQ (kind, Qmouse_click)) | 9226 | if (EQ (kind, Qmouse_click)) |
| 9397 | { | 9227 | { |
| 9398 | Lisp_Object window, posn; | 9228 | Lisp_Object window = POSN_WINDOW (EVENT_START (key)); |
| 9399 | 9229 | Lisp_Object posn = POSN_POSN (EVENT_START (key)); | |
| 9400 | window = POSN_WINDOW (EVENT_START (key)); | ||
| 9401 | posn = POSN_POSN (EVENT_START (key)); | ||
| 9402 | 9230 | ||
| 9403 | if (CONSP (posn) | 9231 | if (CONSP (posn) |
| 9404 | || (!NILP (fake_prefixed_keys) | 9232 | || (!NILP (fake_prefixed_keys) |
| @@ -9418,8 +9246,8 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt, | |||
| 9418 | not the current buffer. If we're at the | 9246 | not the current buffer. If we're at the |
| 9419 | beginning of a key sequence, switch buffers. */ | 9247 | beginning of a key sequence, switch buffers. */ |
| 9420 | if (WINDOWP (window) | 9248 | if (WINDOWP (window) |
| 9421 | && BUFFERP (XWINDOW (window)->buffer) | 9249 | && BUFFERP (XWINDOW (window)->contents) |
| 9422 | && XBUFFER (XWINDOW (window)->buffer) != current_buffer) | 9250 | && XBUFFER (XWINDOW (window)->contents) != current_buffer) |
| 9423 | { | 9251 | { |
| 9424 | ASET (raw_keybuf, raw_keybuf_count, key); | 9252 | ASET (raw_keybuf, raw_keybuf_count, key); |
| 9425 | raw_keybuf_count++; | 9253 | raw_keybuf_count++; |
| @@ -9440,59 +9268,9 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt, | |||
| 9440 | 9268 | ||
| 9441 | if (! FRAME_LIVE_P (XFRAME (selected_frame))) | 9269 | if (! FRAME_LIVE_P (XFRAME (selected_frame))) |
| 9442 | Fkill_emacs (Qnil); | 9270 | Fkill_emacs (Qnil); |
| 9443 | set_buffer_internal (XBUFFER (XWINDOW (window)->buffer)); | 9271 | set_buffer_internal (XBUFFER (XWINDOW (window)->contents)); |
| 9444 | orig_local_map = get_local_map (PT, current_buffer, | ||
| 9445 | Qlocal_map); | ||
| 9446 | orig_keymap = get_local_map (PT, current_buffer, | ||
| 9447 | Qkeymap); | ||
| 9448 | goto replay_sequence; | 9272 | goto replay_sequence; |
| 9449 | } | 9273 | } |
| 9450 | |||
| 9451 | /* For a mouse click, get the local text-property keymap | ||
| 9452 | of the place clicked on, rather than point. */ | ||
| 9453 | if (CONSP (XCDR (key)) | ||
| 9454 | && ! localized_local_map) | ||
| 9455 | { | ||
| 9456 | Lisp_Object map_here, start, pos; | ||
| 9457 | |||
| 9458 | localized_local_map = 1; | ||
| 9459 | start = EVENT_START (key); | ||
| 9460 | |||
| 9461 | if (CONSP (start) && POSN_INBUFFER_P (start)) | ||
| 9462 | { | ||
| 9463 | pos = POSN_BUFFER_POSN (start); | ||
| 9464 | if (INTEGERP (pos) | ||
| 9465 | && XINT (pos) >= BEGV | ||
| 9466 | && XINT (pos) <= ZV) | ||
| 9467 | { | ||
| 9468 | map_here = get_local_map (XINT (pos), | ||
| 9469 | current_buffer, | ||
| 9470 | Qlocal_map); | ||
| 9471 | if (!EQ (map_here, orig_local_map)) | ||
| 9472 | { | ||
| 9473 | orig_local_map = map_here; | ||
| 9474 | ++localized_local_map; | ||
| 9475 | } | ||
| 9476 | |||
| 9477 | map_here = get_local_map (XINT (pos), | ||
| 9478 | current_buffer, | ||
| 9479 | Qkeymap); | ||
| 9480 | if (!EQ (map_here, orig_keymap)) | ||
| 9481 | { | ||
| 9482 | orig_keymap = map_here; | ||
| 9483 | ++localized_local_map; | ||
| 9484 | } | ||
| 9485 | |||
| 9486 | if (localized_local_map > 1) | ||
| 9487 | { | ||
| 9488 | keybuf[t] = key; | ||
| 9489 | mock_input = t + 1; | ||
| 9490 | |||
| 9491 | goto replay_sequence; | ||
| 9492 | } | ||
| 9493 | } | ||
| 9494 | } | ||
| 9495 | } | ||
| 9496 | } | 9274 | } |
| 9497 | 9275 | ||
| 9498 | /* Expand mode-line and scroll-bar events into two events: | 9276 | /* Expand mode-line and scroll-bar events into two events: |
| @@ -9513,63 +9291,8 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt, | |||
| 9513 | prevent proper action when the event is pushed | 9291 | prevent proper action when the event is pushed |
| 9514 | back into unread-command-events. */ | 9292 | back into unread-command-events. */ |
| 9515 | fake_prefixed_keys = Fcons (key, fake_prefixed_keys); | 9293 | fake_prefixed_keys = Fcons (key, fake_prefixed_keys); |
| 9516 | |||
| 9517 | /* If on a mode line string with a local keymap, | ||
| 9518 | reconsider the key sequence with that keymap. */ | ||
| 9519 | if (string = POSN_STRING (EVENT_START (key)), | ||
| 9520 | (CONSP (string) && STRINGP (XCAR (string)))) | ||
| 9521 | { | ||
| 9522 | Lisp_Object pos, map, map2; | ||
| 9523 | |||
| 9524 | pos = XCDR (string); | ||
| 9525 | string = XCAR (string); | ||
| 9526 | if (XINT (pos) >= 0 | ||
| 9527 | && XINT (pos) < SCHARS (string)) | ||
| 9528 | { | ||
| 9529 | map = Fget_text_property (pos, Qlocal_map, string); | ||
| 9530 | if (!NILP (map)) | ||
| 9531 | orig_local_map = map; | ||
| 9532 | map2 = Fget_text_property (pos, Qkeymap, string); | ||
| 9533 | if (!NILP (map2)) | ||
| 9534 | orig_keymap = map2; | ||
| 9535 | if (!NILP (map) || !NILP (map2)) | ||
| 9536 | goto replay_sequence; | ||
| 9537 | } | ||
| 9538 | } | ||
| 9539 | |||
| 9540 | goto replay_key; | 9294 | goto replay_key; |
| 9541 | } | 9295 | } |
| 9542 | else if (NILP (from_string) | ||
| 9543 | && (string = POSN_STRING (EVENT_START (key)), | ||
| 9544 | (CONSP (string) && STRINGP (XCAR (string))))) | ||
| 9545 | { | ||
| 9546 | /* For a click on a string, i.e. overlay string or a | ||
| 9547 | string displayed via the `display' property, | ||
| 9548 | consider `local-map' and `keymap' properties of | ||
| 9549 | that string. */ | ||
| 9550 | Lisp_Object pos, map, map2; | ||
| 9551 | |||
| 9552 | pos = XCDR (string); | ||
| 9553 | string = XCAR (string); | ||
| 9554 | if (XINT (pos) >= 0 | ||
| 9555 | && XINT (pos) < SCHARS (string)) | ||
| 9556 | { | ||
| 9557 | map = Fget_text_property (pos, Qlocal_map, string); | ||
| 9558 | if (!NILP (map)) | ||
| 9559 | orig_local_map = map; | ||
| 9560 | map2 = Fget_text_property (pos, Qkeymap, string); | ||
| 9561 | if (!NILP (map2)) | ||
| 9562 | orig_keymap = map2; | ||
| 9563 | |||
| 9564 | if (!NILP (map) || !NILP (map2)) | ||
| 9565 | { | ||
| 9566 | from_string = string; | ||
| 9567 | keybuf[t++] = key; | ||
| 9568 | mock_input = t; | ||
| 9569 | goto replay_sequence; | ||
| 9570 | } | ||
| 9571 | } | ||
| 9572 | } | ||
| 9573 | } | 9296 | } |
| 9574 | else if (CONSP (XCDR (key)) | 9297 | else if (CONSP (XCDR (key)) |
| 9575 | && CONSP (EVENT_START (key)) | 9298 | && CONSP (EVENT_START (key)) |
| @@ -9585,7 +9308,7 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt, | |||
| 9585 | if (bufsize - t <= 1) | 9308 | if (bufsize - t <= 1) |
| 9586 | error ("Key sequence too long"); | 9309 | error ("Key sequence too long"); |
| 9587 | keybuf[t] = posn; | 9310 | keybuf[t] = posn; |
| 9588 | keybuf[t+1] = key; | 9311 | keybuf[t + 1] = key; |
| 9589 | 9312 | ||
| 9590 | /* Zap the position in key, so we know that we've | 9313 | /* Zap the position in key, so we know that we've |
| 9591 | expanded it, and don't try to do so again. */ | 9314 | expanded it, and don't try to do so again. */ |
| @@ -9608,15 +9331,10 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt, | |||
| 9608 | 9331 | ||
| 9609 | /* We have finally decided that KEY is something we might want | 9332 | /* We have finally decided that KEY is something we might want |
| 9610 | to look up. */ | 9333 | to look up. */ |
| 9611 | first_binding = (follow_key (key, | 9334 | new_binding = follow_key (current_binding, key); |
| 9612 | nmaps - first_binding, | ||
| 9613 | submaps + first_binding, | ||
| 9614 | defs + first_binding, | ||
| 9615 | submaps + first_binding) | ||
| 9616 | + first_binding); | ||
| 9617 | 9335 | ||
| 9618 | /* If KEY wasn't bound, we'll try some fallbacks. */ | 9336 | /* If KEY wasn't bound, we'll try some fallbacks. */ |
| 9619 | if (first_binding < nmaps) | 9337 | if (!NILP (new_binding)) |
| 9620 | /* This is needed for the following scenario: | 9338 | /* This is needed for the following scenario: |
| 9621 | event 0: a down-event that gets dropped by calling replay_key. | 9339 | event 0: a down-event that gets dropped by calling replay_key. |
| 9622 | event 1: some normal prefix like C-h. | 9340 | event 1: some normal prefix like C-h. |
| @@ -9753,20 +9471,13 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt, | |||
| 9753 | new_click | 9471 | new_click |
| 9754 | = Fcons (new_head, Fcons (EVENT_START (key), Qnil)); | 9472 | = Fcons (new_head, Fcons (EVENT_START (key), Qnil)); |
| 9755 | 9473 | ||
| 9756 | /* Look for a binding for this new key. follow_key | 9474 | /* Look for a binding for this new key. */ |
| 9757 | promises that it didn't munge submaps the | 9475 | new_binding = follow_key (current_binding, new_click); |
| 9758 | last time we called it, since key was unbound. */ | ||
| 9759 | first_binding | ||
| 9760 | = (follow_key (new_click, | ||
| 9761 | nmaps - local_first_binding, | ||
| 9762 | submaps + local_first_binding, | ||
| 9763 | defs + local_first_binding, | ||
| 9764 | submaps + local_first_binding) | ||
| 9765 | + local_first_binding); | ||
| 9766 | 9476 | ||
| 9767 | /* If that click is bound, go for it. */ | 9477 | /* If that click is bound, go for it. */ |
| 9768 | if (first_binding < nmaps) | 9478 | if (!NILP (new_binding)) |
| 9769 | { | 9479 | { |
| 9480 | current_binding = new_binding; | ||
| 9770 | key = new_click; | 9481 | key = new_click; |
| 9771 | break; | 9482 | break; |
| 9772 | } | 9483 | } |
| @@ -9775,6 +9486,7 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt, | |||
| 9775 | } | 9486 | } |
| 9776 | } | 9487 | } |
| 9777 | } | 9488 | } |
| 9489 | current_binding = new_binding; | ||
| 9778 | 9490 | ||
| 9779 | keybuf[t++] = key; | 9491 | keybuf[t++] = key; |
| 9780 | /* Normally, last_nonmenu_event gets the previous key we read. | 9492 | /* Normally, last_nonmenu_event gets the previous key we read. |
| @@ -9806,9 +9518,8 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt, | |||
| 9806 | } | 9518 | } |
| 9807 | } | 9519 | } |
| 9808 | 9520 | ||
| 9809 | if (first_binding < nmaps | 9521 | if (!KEYMAPP (current_binding) |
| 9810 | && NILP (submaps[first_binding]) | 9522 | && !test_undefined (current_binding) |
| 9811 | && !test_undefined (defs[first_binding]) | ||
| 9812 | && indec.start >= t) | 9523 | && indec.start >= t) |
| 9813 | /* There is a binding and it's not a prefix. | 9524 | /* There is a binding and it's not a prefix. |
| 9814 | (and it doesn't have any input-decode-map translation pending). | 9525 | (and it doesn't have any input-decode-map translation pending). |
| @@ -9837,8 +9548,7 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt, | |||
| 9837 | first_binding >= nmaps) we don't want | 9548 | first_binding >= nmaps) we don't want |
| 9838 | to apply this function-key-mapping. */ | 9549 | to apply this function-key-mapping. */ |
| 9839 | fkey.end + 1 == t | 9550 | fkey.end + 1 == t |
| 9840 | && (first_binding >= nmaps | 9551 | && (test_undefined (current_binding)), |
| 9841 | || test_undefined (defs[first_binding])), | ||
| 9842 | &diff, prompt); | 9552 | &diff, prompt); |
| 9843 | UNGCPRO; | 9553 | UNGCPRO; |
| 9844 | if (done) | 9554 | if (done) |
| @@ -9881,7 +9591,7 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt, | |||
| 9881 | and cannot be part of a function key or translation, | 9591 | and cannot be part of a function key or translation, |
| 9882 | and is an upper case letter | 9592 | and is an upper case letter |
| 9883 | use the corresponding lower-case letter instead. */ | 9593 | use the corresponding lower-case letter instead. */ |
| 9884 | if (first_binding >= nmaps | 9594 | if (NILP (current_binding) |
| 9885 | && /* indec.start >= t && fkey.start >= t && */ keytran.start >= t | 9595 | && /* indec.start >= t && fkey.start >= t && */ keytran.start >= t |
| 9886 | && INTEGERP (key) | 9596 | && INTEGERP (key) |
| 9887 | && ((CHARACTERP (make_number (XINT (key) & ~CHAR_MODIFIER_MASK)) | 9597 | && ((CHARACTERP (make_number (XINT (key) & ~CHAR_MODIFIER_MASK)) |
| @@ -9912,7 +9622,7 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt, | |||
| 9912 | and cannot be part of a function key or translation, | 9622 | and cannot be part of a function key or translation, |
| 9913 | and is a shifted function key, | 9623 | and is a shifted function key, |
| 9914 | use the corresponding unshifted function key instead. */ | 9624 | use the corresponding unshifted function key instead. */ |
| 9915 | if (first_binding >= nmaps | 9625 | if (NILP (current_binding) |
| 9916 | && /* indec.start >= t && fkey.start >= t && */ keytran.start >= t) | 9626 | && /* indec.start >= t && fkey.start >= t && */ keytran.start >= t) |
| 9917 | { | 9627 | { |
| 9918 | Lisp_Object breakdown = parse_modifiers (key); | 9628 | Lisp_Object breakdown = parse_modifiers (key); |
| @@ -9953,9 +9663,7 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt, | |||
| 9953 | } | 9663 | } |
| 9954 | } | 9664 | } |
| 9955 | if (!dummyflag) | 9665 | if (!dummyflag) |
| 9956 | read_key_sequence_cmd = (first_binding < nmaps | 9666 | read_key_sequence_cmd = current_binding; |
| 9957 | ? defs[first_binding] | ||
| 9958 | : Qnil); | ||
| 9959 | read_key_sequence_remapped | 9667 | read_key_sequence_remapped |
| 9960 | /* Remap command through active keymaps. | 9668 | /* Remap command through active keymaps. |
| 9961 | Do the remapping here, before the unbind_to so it uses the keymaps | 9669 | Do the remapping here, before the unbind_to so it uses the keymaps |
| @@ -9969,7 +9677,7 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt, | |||
| 9969 | 9677 | ||
| 9970 | /* Don't downcase the last character if the caller says don't. | 9678 | /* Don't downcase the last character if the caller says don't. |
| 9971 | Don't downcase it if the result is undefined, either. */ | 9679 | Don't downcase it if the result is undefined, either. */ |
| 9972 | if ((dont_downcase_last || first_binding >= nmaps) | 9680 | if ((dont_downcase_last || NILP (current_binding)) |
| 9973 | && t > 0 | 9681 | && t > 0 |
| 9974 | && t - 1 == original_uppercase_position) | 9682 | && t - 1 == original_uppercase_position) |
| 9975 | { | 9683 | { |
| @@ -10066,7 +9774,7 @@ will read just one key sequence. */) | |||
| 10066 | 9774 | ||
| 10067 | memset (keybuf, 0, sizeof keybuf); | 9775 | memset (keybuf, 0, sizeof keybuf); |
| 10068 | GCPRO1 (keybuf[0]); | 9776 | GCPRO1 (keybuf[0]); |
| 10069 | gcpro1.nvars = (sizeof keybuf/sizeof (keybuf[0])); | 9777 | gcpro1.nvars = (sizeof keybuf / sizeof (keybuf[0])); |
| 10070 | 9778 | ||
| 10071 | if (NILP (continue_echo)) | 9779 | if (NILP (continue_echo)) |
| 10072 | { | 9780 | { |
| @@ -10080,7 +9788,7 @@ will read just one key sequence. */) | |||
| 10080 | cancel_hourglass (); | 9788 | cancel_hourglass (); |
| 10081 | #endif | 9789 | #endif |
| 10082 | 9790 | ||
| 10083 | i = read_key_sequence (keybuf, (sizeof keybuf/sizeof (keybuf[0])), | 9791 | i = read_key_sequence (keybuf, (sizeof keybuf / sizeof (keybuf[0])), |
| 10084 | prompt, ! NILP (dont_downcase_last), | 9792 | prompt, ! NILP (dont_downcase_last), |
| 10085 | ! NILP (can_return_switch_frame), 0); | 9793 | ! NILP (can_return_switch_frame), 0); |
| 10086 | 9794 | ||
| @@ -10155,95 +9863,6 @@ DEFUN ("read-key-sequence-vector", Fread_key_sequence_vector, | |||
| 10155 | return unbind_to (count, Fvector (i, keybuf)); | 9863 | return unbind_to (count, Fvector (i, keybuf)); |
| 10156 | } | 9864 | } |
| 10157 | 9865 | ||
| 10158 | DEFUN ("command-execute", Fcommand_execute, Scommand_execute, 1, 4, 0, | ||
| 10159 | doc: /* Execute CMD as an editor command. | ||
| 10160 | CMD must be a symbol that satisfies the `commandp' predicate. | ||
| 10161 | Optional second arg RECORD-FLAG non-nil | ||
| 10162 | means unconditionally put this command in `command-history'. | ||
| 10163 | Otherwise, that is done only if an arg is read using the minibuffer. | ||
| 10164 | The argument KEYS specifies the value to use instead of (this-command-keys) | ||
| 10165 | when reading the arguments; if it is nil, (this-command-keys) is used. | ||
| 10166 | The argument SPECIAL, if non-nil, means that this command is executing | ||
| 10167 | a special event, so ignore the prefix argument and don't clear it. */) | ||
| 10168 | (Lisp_Object cmd, Lisp_Object record_flag, Lisp_Object keys, Lisp_Object special) | ||
| 10169 | { | ||
| 10170 | register Lisp_Object final; | ||
| 10171 | register Lisp_Object tem; | ||
| 10172 | Lisp_Object prefixarg; | ||
| 10173 | |||
| 10174 | debug_on_next_call = 0; | ||
| 10175 | |||
| 10176 | if (NILP (special)) | ||
| 10177 | { | ||
| 10178 | prefixarg = KVAR (current_kboard, Vprefix_arg); | ||
| 10179 | Vcurrent_prefix_arg = prefixarg; | ||
| 10180 | kset_prefix_arg (current_kboard, Qnil); | ||
| 10181 | } | ||
| 10182 | else | ||
| 10183 | prefixarg = Qnil; | ||
| 10184 | |||
| 10185 | if (SYMBOLP (cmd)) | ||
| 10186 | { | ||
| 10187 | tem = Fget (cmd, Qdisabled); | ||
| 10188 | if (!NILP (tem)) | ||
| 10189 | { | ||
| 10190 | tem = Fsymbol_value (Qdisabled_command_function); | ||
| 10191 | if (!NILP (tem)) | ||
| 10192 | return Frun_hooks (1, &Qdisabled_command_function); | ||
| 10193 | } | ||
| 10194 | } | ||
| 10195 | |||
| 10196 | while (1) | ||
| 10197 | { | ||
| 10198 | final = Findirect_function (cmd, Qnil); | ||
| 10199 | |||
| 10200 | if (CONSP (final) && (tem = Fcar (final), EQ (tem, Qautoload))) | ||
| 10201 | { | ||
| 10202 | struct gcpro gcpro1, gcpro2; | ||
| 10203 | |||
| 10204 | GCPRO2 (cmd, prefixarg); | ||
| 10205 | Fautoload_do_load (final, cmd, Qnil); | ||
| 10206 | UNGCPRO; | ||
| 10207 | } | ||
| 10208 | else | ||
| 10209 | break; | ||
| 10210 | } | ||
| 10211 | |||
| 10212 | if (STRINGP (final) || VECTORP (final)) | ||
| 10213 | { | ||
| 10214 | /* If requested, place the macro in the command history. For | ||
| 10215 | other sorts of commands, call-interactively takes care of | ||
| 10216 | this. */ | ||
| 10217 | if (!NILP (record_flag)) | ||
| 10218 | { | ||
| 10219 | Vcommand_history | ||
| 10220 | = Fcons (Fcons (Qexecute_kbd_macro, | ||
| 10221 | Fcons (final, Fcons (prefixarg, Qnil))), | ||
| 10222 | Vcommand_history); | ||
| 10223 | |||
| 10224 | /* Don't keep command history around forever. */ | ||
| 10225 | if (NUMBERP (Vhistory_length) && XINT (Vhistory_length) > 0) | ||
| 10226 | { | ||
| 10227 | tem = Fnthcdr (Vhistory_length, Vcommand_history); | ||
| 10228 | if (CONSP (tem)) | ||
| 10229 | XSETCDR (tem, Qnil); | ||
| 10230 | } | ||
| 10231 | } | ||
| 10232 | |||
| 10233 | return Fexecute_kbd_macro (final, prefixarg, Qnil); | ||
| 10234 | } | ||
| 10235 | |||
| 10236 | if (CONSP (final) || SUBRP (final) || COMPILEDP (final)) | ||
| 10237 | /* Don't call Fcall_interactively directly because we want to make | ||
| 10238 | sure the backtrace has an entry for `call-interactively'. | ||
| 10239 | For the same reason, pass `cmd' rather than `final'. */ | ||
| 10240 | return call3 (Qcall_interactively, cmd, record_flag, keys); | ||
| 10241 | |||
| 10242 | return Qnil; | ||
| 10243 | } | ||
| 10244 | |||
| 10245 | |||
| 10246 | |||
| 10247 | /* Return true if input events are pending. */ | 9866 | /* Return true if input events are pending. */ |
| 10248 | 9867 | ||
| 10249 | bool | 9868 | bool |
| @@ -10718,7 +10337,7 @@ handle_interrupt (bool in_signal_handler) | |||
| 10718 | fflush (stdout); | 10337 | fflush (stdout); |
| 10719 | reset_all_sys_modes (); | 10338 | reset_all_sys_modes (); |
| 10720 | 10339 | ||
| 10721 | #ifdef SIGTSTP /* Support possible in later USG versions */ | 10340 | #ifdef SIGTSTP |
| 10722 | /* | 10341 | /* |
| 10723 | * On systems which can suspend the current process and return to the original | 10342 | * On systems which can suspend the current process and return to the original |
| 10724 | * shell, this command causes the user to end up back at the shell. | 10343 | * shell, this command causes the user to end up back at the shell. |
| @@ -10923,7 +10542,7 @@ See also `current-input-mode'. */) | |||
| 10923 | if (tty->flow_control != !NILP (flow)) | 10542 | if (tty->flow_control != !NILP (flow)) |
| 10924 | { | 10543 | { |
| 10925 | #ifndef DOS_NT | 10544 | #ifndef DOS_NT |
| 10926 | /* this causes startup screen to be restored and messes with the mouse */ | 10545 | /* This causes startup screen to be restored and messes with the mouse. */ |
| 10927 | reset_sys_modes (tty); | 10546 | reset_sys_modes (tty); |
| 10928 | #endif | 10547 | #endif |
| 10929 | 10548 | ||
| @@ -11233,9 +10852,7 @@ init_keyboard (void) | |||
| 11233 | recent_keys_index = 0; | 10852 | recent_keys_index = 0; |
| 11234 | kbd_fetch_ptr = kbd_buffer; | 10853 | kbd_fetch_ptr = kbd_buffer; |
| 11235 | kbd_store_ptr = kbd_buffer; | 10854 | kbd_store_ptr = kbd_buffer; |
| 11236 | #if defined (HAVE_MOUSE) || defined (HAVE_GPM) | ||
| 11237 | do_mouse_tracking = Qnil; | 10855 | do_mouse_tracking = Qnil; |
| 11238 | #endif | ||
| 11239 | input_pending = 0; | 10856 | input_pending = 0; |
| 11240 | interrupt_input_blocked = 0; | 10857 | interrupt_input_blocked = 0; |
| 11241 | pending_signals = 0; | 10858 | pending_signals = 0; |
| @@ -11365,10 +10982,18 @@ syms_of_keyboard (void) | |||
| 11365 | DEFSYM (Qlanguage_change, "language-change"); | 10982 | DEFSYM (Qlanguage_change, "language-change"); |
| 11366 | #endif | 10983 | #endif |
| 11367 | 10984 | ||
| 10985 | #ifdef WINDOWSNT | ||
| 10986 | DEFSYM (Qfile_w32notify, "file-w32notify"); | ||
| 10987 | #endif | ||
| 10988 | |||
| 11368 | #ifdef HAVE_DBUS | 10989 | #ifdef HAVE_DBUS |
| 11369 | DEFSYM (Qdbus_event, "dbus-event"); | 10990 | DEFSYM (Qdbus_event, "dbus-event"); |
| 11370 | #endif | 10991 | #endif |
| 11371 | 10992 | ||
| 10993 | #ifdef HAVE_INOTIFY | ||
| 10994 | DEFSYM (Qfile_inotify, "file-inotify"); | ||
| 10995 | #endif /* HAVE_INOTIFY */ | ||
| 10996 | |||
| 11372 | DEFSYM (QCenable, ":enable"); | 10997 | DEFSYM (QCenable, ":enable"); |
| 11373 | DEFSYM (QCvisible, ":visible"); | 10998 | DEFSYM (QCvisible, ":visible"); |
| 11374 | DEFSYM (QChelp, ":help"); | 10999 | DEFSYM (QChelp, ":help"); |
| @@ -11386,9 +11011,7 @@ syms_of_keyboard (void) | |||
| 11386 | DEFSYM (Qvertical_scroll_bar, "vertical-scroll-bar"); | 11011 | DEFSYM (Qvertical_scroll_bar, "vertical-scroll-bar"); |
| 11387 | DEFSYM (Qmenu_bar, "menu-bar"); | 11012 | DEFSYM (Qmenu_bar, "menu-bar"); |
| 11388 | 11013 | ||
| 11389 | #if defined (HAVE_MOUSE) || defined (HAVE_GPM) | ||
| 11390 | DEFSYM (Qmouse_fixup_help_message, "mouse-fixup-help-message"); | 11014 | DEFSYM (Qmouse_fixup_help_message, "mouse-fixup-help-message"); |
| 11391 | #endif | ||
| 11392 | 11015 | ||
| 11393 | DEFSYM (Qabove_handle, "above-handle"); | 11016 | DEFSYM (Qabove_handle, "above-handle"); |
| 11394 | DEFSYM (Qhandle, "handle"); | 11017 | DEFSYM (Qhandle, "handle"); |
| @@ -11470,8 +11093,7 @@ syms_of_keyboard (void) | |||
| 11470 | raw_keybuf = Fmake_vector (make_number (30), Qnil); | 11093 | raw_keybuf = Fmake_vector (make_number (30), Qnil); |
| 11471 | staticpro (&raw_keybuf); | 11094 | staticpro (&raw_keybuf); |
| 11472 | 11095 | ||
| 11473 | DEFSYM (Qextended_command_history, "extended-command-history"); | 11096 | DEFSYM (Qcommand_execute, "command-execute"); |
| 11474 | Fset (Qextended_command_history, Qnil); | ||
| 11475 | 11097 | ||
| 11476 | accent_key_syms = Qnil; | 11098 | accent_key_syms = Qnil; |
| 11477 | staticpro (&accent_key_syms); | 11099 | staticpro (&accent_key_syms); |
| @@ -11508,11 +11130,8 @@ syms_of_keyboard (void) | |||
| 11508 | defsubr (&Sread_key_sequence); | 11130 | defsubr (&Sread_key_sequence); |
| 11509 | defsubr (&Sread_key_sequence_vector); | 11131 | defsubr (&Sread_key_sequence_vector); |
| 11510 | defsubr (&Srecursive_edit); | 11132 | defsubr (&Srecursive_edit); |
| 11511 | #if defined (HAVE_MOUSE) || defined (HAVE_GPM) | ||
| 11512 | defsubr (&Strack_mouse); | 11133 | defsubr (&Strack_mouse); |
| 11513 | #endif | ||
| 11514 | defsubr (&Sinput_pending_p); | 11134 | defsubr (&Sinput_pending_p); |
| 11515 | defsubr (&Scommand_execute); | ||
| 11516 | defsubr (&Srecent_keys); | 11135 | defsubr (&Srecent_keys); |
| 11517 | defsubr (&Sthis_command_keys); | 11136 | defsubr (&Sthis_command_keys); |
| 11518 | defsubr (&Sthis_command_keys_vector); | 11137 | defsubr (&Sthis_command_keys_vector); |
| @@ -11670,10 +11289,6 @@ This variable is also the threshold for motion of the mouse | |||
| 11670 | to count as a drag. */); | 11289 | to count as a drag. */); |
| 11671 | double_click_fuzz = 3; | 11290 | double_click_fuzz = 3; |
| 11672 | 11291 | ||
| 11673 | DEFVAR_BOOL ("inhibit-local-menu-bar-menus", inhibit_local_menu_bar_menus, | ||
| 11674 | doc: /* Non-nil means inhibit local map menu bar menus. */); | ||
| 11675 | inhibit_local_menu_bar_menus = 0; | ||
| 11676 | |||
| 11677 | DEFVAR_INT ("num-input-keys", num_input_keys, | 11292 | DEFVAR_INT ("num-input-keys", num_input_keys, |
| 11678 | doc: /* Number of complete key sequences read as input so far. | 11293 | doc: /* Number of complete key sequences read as input so far. |
| 11679 | This includes key sequences read from keyboard macros. | 11294 | This includes key sequences read from keyboard macros. |
| @@ -11901,9 +11516,7 @@ If the binding is a function, it is called with one argument (the prompt) | |||
| 11901 | and its return value (a key sequence) is used. | 11516 | and its return value (a key sequence) is used. |
| 11902 | 11517 | ||
| 11903 | The events that come from bindings in `input-decode-map' are not | 11518 | The events that come from bindings in `input-decode-map' are not |
| 11904 | themselves looked up in `input-decode-map'. | 11519 | themselves looked up in `input-decode-map'. */); |
| 11905 | |||
| 11906 | This variable is keyboard-local. */); | ||
| 11907 | 11520 | ||
| 11908 | DEFVAR_LISP ("function-key-map", Vfunction_key_map, | 11521 | DEFVAR_LISP ("function-key-map", Vfunction_key_map, |
| 11909 | doc: /* The parent keymap of all `local-function-key-map' instances. | 11522 | doc: /* The parent keymap of all `local-function-key-map' instances. |
| @@ -11915,9 +11528,8 @@ definition will take precedence. */); | |||
| 11915 | 11528 | ||
| 11916 | DEFVAR_LISP ("key-translation-map", Vkey_translation_map, | 11529 | DEFVAR_LISP ("key-translation-map", Vkey_translation_map, |
| 11917 | doc: /* Keymap of key translations that can override keymaps. | 11530 | doc: /* Keymap of key translations that can override keymaps. |
| 11918 | This keymap works like `function-key-map', but comes after that, | 11531 | This keymap works like `input-decode-map', but comes after `function-key-map'. |
| 11919 | and its non-prefix bindings override ordinary bindings. | 11532 | Another difference is that it is global rather than terminal-local. */); |
| 11920 | Another difference is that it is global rather than keyboard-local. */); | ||
| 11921 | Vkey_translation_map = Fmake_sparse_keymap (Qnil); | 11533 | Vkey_translation_map = Fmake_sparse_keymap (Qnil); |
| 11922 | 11534 | ||
| 11923 | DEFVAR_LISP ("deferred-action-list", Vdeferred_action_list, | 11535 | DEFVAR_LISP ("deferred-action-list", Vdeferred_action_list, |
| @@ -12042,8 +11654,8 @@ This takes effect only when Transient Mark mode is enabled. */); | |||
| 12042 | Vsaved_region_selection, | 11654 | Vsaved_region_selection, |
| 12043 | doc: /* Contents of active region prior to buffer modification. | 11655 | doc: /* Contents of active region prior to buffer modification. |
| 12044 | If `select-active-regions' is non-nil, Emacs sets this to the | 11656 | If `select-active-regions' is non-nil, Emacs sets this to the |
| 12045 | text in the region before modifying the buffer. The next | 11657 | text in the region before modifying the buffer. The next call to |
| 12046 | `deactivate-mark' call uses this to set the window selection. */); | 11658 | the function `deactivate-mark' uses this to set the window selection. */); |
| 12047 | Vsaved_region_selection = Qnil; | 11659 | Vsaved_region_selection = Qnil; |
| 12048 | 11660 | ||
| 12049 | DEFVAR_LISP ("selection-inhibit-update-commands", | 11661 | DEFVAR_LISP ("selection-inhibit-update-commands", |
| @@ -12129,11 +11741,20 @@ keys_of_keyboard (void) | |||
| 12129 | "dbus-handle-event"); | 11741 | "dbus-handle-event"); |
| 12130 | #endif | 11742 | #endif |
| 12131 | 11743 | ||
| 11744 | #ifdef HAVE_INOTIFY | ||
| 11745 | /* Define a special event which is raised for inotify callback | ||
| 11746 | functions. */ | ||
| 11747 | initial_define_lispy_key (Vspecial_event_map, "file-inotify", | ||
| 11748 | "inotify-handle-event"); | ||
| 11749 | #endif /* HAVE_INOTIFY */ | ||
| 11750 | |||
| 12132 | initial_define_lispy_key (Vspecial_event_map, "config-changed-event", | 11751 | initial_define_lispy_key (Vspecial_event_map, "config-changed-event", |
| 12133 | "ignore"); | 11752 | "ignore"); |
| 12134 | #if defined (WINDOWSNT) | 11753 | #if defined (WINDOWSNT) |
| 12135 | initial_define_lispy_key (Vspecial_event_map, "language-change", | 11754 | initial_define_lispy_key (Vspecial_event_map, "language-change", |
| 12136 | "ignore"); | 11755 | "ignore"); |
| 11756 | initial_define_lispy_key (Vspecial_event_map, "file-w32notify", | ||
| 11757 | "w32notify-handle-event"); | ||
| 12137 | #endif | 11758 | #endif |
| 12138 | } | 11759 | } |
| 12139 | 11760 | ||