aboutsummaryrefslogtreecommitdiffstats
path: root/src/keyboard.c
diff options
context:
space:
mode:
authorStefan Monnier2011-03-31 00:24:03 -0400
committerStefan Monnier2011-03-31 00:24:03 -0400
commit40d83b412f584cc02e68d4eac8fd5e6eb769e2fe (patch)
treeb56f27a7e6d75a8c1fd27b00179a27b5efea0a32 /src/keyboard.c
parentf488fb6528738131ef41859e1f04125f2e50efce (diff)
parent44f230aa043ebb222aa0876b44d70484d5dd38db (diff)
downloademacs-40d83b412f584cc02e68d4eac8fd5e6eb769e2fe.tar.gz
emacs-40d83b412f584cc02e68d4eac8fd5e6eb769e2fe.zip
Merge from trunk
Diffstat (limited to 'src/keyboard.c')
-rw-r--r--src/keyboard.c314
1 files changed, 171 insertions, 143 deletions
diff --git a/src/keyboard.c b/src/keyboard.c
index 63e7573fbe9..d307250b868 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -201,8 +201,8 @@ Lisp_Object unread_switch_frame;
201/* Last size recorded for a current buffer which is not a minibuffer. */ 201/* Last size recorded for a current buffer which is not a minibuffer. */
202static EMACS_INT last_non_minibuf_size; 202static EMACS_INT last_non_minibuf_size;
203 203
204/* Total number of times read_char has returned. */ 204/* Total number of times read_char has returned, modulo SIZE_MAX + 1. */
205int num_input_events; 205size_t num_input_events;
206 206
207/* Value of num_nonmacro_input_events as of last auto save. */ 207/* Value of num_nonmacro_input_events as of last auto save. */
208 208
@@ -254,7 +254,6 @@ Lisp_Object Qecho_area_clear_hook;
254/* Hooks to run before and after each command. */ 254/* Hooks to run before and after each command. */
255Lisp_Object Qpre_command_hook; 255Lisp_Object Qpre_command_hook;
256Lisp_Object Qpost_command_hook; 256Lisp_Object Qpost_command_hook;
257Lisp_Object Qcommand_hook_internal;
258 257
259Lisp_Object Qdeferred_action_function; 258Lisp_Object Qdeferred_action_function;
260 259
@@ -351,7 +350,7 @@ Lisp_Object Qmenu_bar;
351Lisp_Object recursive_edit_unwind (Lisp_Object buffer), command_loop (void); 350Lisp_Object recursive_edit_unwind (Lisp_Object buffer), command_loop (void);
352Lisp_Object Fthis_command_keys (void); 351Lisp_Object Fthis_command_keys (void);
353Lisp_Object Qextended_command_history; 352Lisp_Object Qextended_command_history;
354EMACS_TIME timer_check (int do_it_now); 353EMACS_TIME timer_check (void);
355 354
356static void record_menu_key (Lisp_Object c); 355static void record_menu_key (Lisp_Object c);
357static int echo_length (void); 356static int echo_length (void);
@@ -434,15 +433,15 @@ static void restore_getcjmp (jmp_buf);
434static Lisp_Object apply_modifiers (int, Lisp_Object); 433static Lisp_Object apply_modifiers (int, Lisp_Object);
435static void clear_event (struct input_event *); 434static void clear_event (struct input_event *);
436static Lisp_Object restore_kboard_configuration (Lisp_Object); 435static Lisp_Object restore_kboard_configuration (Lisp_Object);
437static SIGTYPE interrupt_signal (int signalnum); 436static void interrupt_signal (int signalnum);
438#ifdef SIGIO 437#ifdef SIGIO
439static SIGTYPE input_available_signal (int signo); 438static void input_available_signal (int signo);
440#endif 439#endif
441static void handle_interrupt (void); 440static void handle_interrupt (void);
442static void timer_start_idle (void); 441static void timer_start_idle (void);
443static void timer_stop_idle (void); 442static void timer_stop_idle (void);
444static void timer_resume_idle (void); 443static void timer_resume_idle (void);
445static SIGTYPE handle_user_signal (int); 444static void handle_user_signal (int);
446static char *find_user_signal_name (int); 445static char *find_user_signal_name (int);
447static int store_user_signal_events (void); 446static int store_user_signal_events (void);
448 447
@@ -1270,7 +1269,7 @@ some_mouse_moved (void)
1270/* This is the actual command reading loop, 1269/* This is the actual command reading loop,
1271 sans error-handling encapsulation. */ 1270 sans error-handling encapsulation. */
1272 1271
1273static int read_key_sequence (Lisp_Object *, int, Lisp_Object, 1272static int read_key_sequence (Lisp_Object *, size_t, Lisp_Object,
1274 int, int, int); 1273 int, int, int);
1275void safe_run_hooks (Lisp_Object); 1274void safe_run_hooks (Lisp_Object);
1276static void adjust_point_for_property (EMACS_INT, int); 1275static void adjust_point_for_property (EMACS_INT, int);
@@ -1492,10 +1491,7 @@ command_loop_1 (void)
1492 1491
1493 Vthis_command = cmd; 1492 Vthis_command = cmd;
1494 real_this_command = cmd; 1493 real_this_command = cmd;
1495 /* Note that the value cell will never directly contain nil 1494 safe_run_hooks (Qpre_command_hook);
1496 if the symbol is a local variable. */
1497 if (!NILP (Vpre_command_hook) && !NILP (Vrun_hooks))
1498 safe_run_hooks (Qpre_command_hook);
1499 1495
1500 already_adjusted = 0; 1496 already_adjusted = 0;
1501 1497
@@ -1541,18 +1537,14 @@ command_loop_1 (void)
1541 } 1537 }
1542 KVAR (current_kboard, Vlast_prefix_arg) = Vcurrent_prefix_arg; 1538 KVAR (current_kboard, Vlast_prefix_arg) = Vcurrent_prefix_arg;
1543 1539
1544 /* Note that the value cell will never directly contain nil 1540 safe_run_hooks (Qpost_command_hook);
1545 if the symbol is a local variable. */
1546 if (!NILP (Vpost_command_hook) && !NILP (Vrun_hooks))
1547 safe_run_hooks (Qpost_command_hook);
1548 1541
1549 /* If displaying a message, resize the echo area window to fit 1542 /* If displaying a message, resize the echo area window to fit
1550 that message's size exactly. */ 1543 that message's size exactly. */
1551 if (!NILP (echo_area_buffer[0])) 1544 if (!NILP (echo_area_buffer[0]))
1552 resize_echo_area_exactly (); 1545 resize_echo_area_exactly ();
1553 1546
1554 if (!NILP (Vdeferred_action_list)) 1547 safe_run_hooks (Qdeferred_action_function);
1555 safe_run_hooks (Qdeferred_action_function);
1556 1548
1557 /* If there is a prefix argument, 1549 /* If there is a prefix argument,
1558 1) We don't want Vlast_command to be ``universal-argument'' 1550 1) We don't want Vlast_command to be ``universal-argument''
@@ -1621,7 +1613,10 @@ command_loop_1 (void)
1621 } 1613 }
1622 1614
1623 if (current_buffer != prev_buffer || MODIFF != prev_modiff) 1615 if (current_buffer != prev_buffer || MODIFF != prev_modiff)
1624 call1 (Vrun_hooks, intern ("activate-mark-hook")); 1616 {
1617 Lisp_Object hook = intern ("activate-mark-hook");
1618 Frun_hooks (1, &hook);
1619 }
1625 } 1620 }
1626 1621
1627 Vsaved_region_selection = Qnil; 1622 Vsaved_region_selection = Qnil;
@@ -1819,22 +1814,63 @@ adjust_point_for_property (EMACS_INT last_pt, int modified)
1819static Lisp_Object 1814static Lisp_Object
1820safe_run_hooks_1 (void) 1815safe_run_hooks_1 (void)
1821{ 1816{
1822 if (NILP (Vrun_hooks)) 1817 eassert (CONSP (Vinhibit_quit));
1823 return Qnil; 1818 return call0 (XCDR (Vinhibit_quit));
1824 return call1 (Vrun_hooks, Vinhibit_quit);
1825} 1819}
1826 1820
1827/* Subroutine for safe_run_hooks: handle an error by clearing out the hook. */ 1821/* Subroutine for safe_run_hooks: handle an error by clearing out the function
1822 from the hook. */
1823
1824static Lisp_Object
1825safe_run_hooks_error (Lisp_Object error_data)
1826{
1827 Lisp_Object hook
1828 = CONSP (Vinhibit_quit) ? XCAR (Vinhibit_quit) : Vinhibit_quit;
1829 Lisp_Object fun = CONSP (Vinhibit_quit) ? XCDR (Vinhibit_quit) : Qnil;
1830 Lisp_Object args[4];
1831 args[0] = build_string ("Error in %s (%s): %s");
1832 args[1] = hook;
1833 args[2] = fun;
1834 args[3] = error_data;
1835 Fmessage (4, args);
1836 if (SYMBOLP (hook))
1837 {
1838 Lisp_Object val;
1839 int found = 0;
1840 Lisp_Object newval = Qnil;
1841 for (val = find_symbol_value (hook); CONSP (val); val = XCDR (val))
1842 if (EQ (fun, XCAR (val)))
1843 found = 1;
1844 else
1845 newval = Fcons (XCAR (val), newval);
1846 if (found)
1847 return Fset (hook, Fnreverse (newval));
1848 /* Not found in the local part of the hook. Let's look at the global
1849 part. */
1850 newval = Qnil;
1851 for (val = (NILP (Fdefault_boundp (hook)) ? Qnil
1852 : Fdefault_value (hook));
1853 CONSP (val); val = XCDR (val))
1854 if (EQ (fun, XCAR (val)))
1855 found = 1;
1856 else
1857 newval = Fcons (XCAR (val), newval);
1858 if (found)
1859 return Fset_default (hook, Fnreverse (newval));
1860 }
1861 return Qnil;
1862}
1828 1863
1829static Lisp_Object 1864static Lisp_Object
1830safe_run_hooks_error (Lisp_Object data) 1865safe_run_hook_funcall (size_t nargs, Lisp_Object *args)
1831{ 1866{
1832 Lisp_Object args[3]; 1867 eassert (nargs == 1);
1833 args[0] = build_string ("Error in %s: %s"); 1868 if (CONSP (Vinhibit_quit))
1834 args[1] = Vinhibit_quit; 1869 XSETCDR (Vinhibit_quit, args[0]);
1835 args[2] = data; 1870 else
1836 Fmessage (3, args); 1871 Vinhibit_quit = Fcons (Vinhibit_quit, args[0]);
1837 return Fset (Vinhibit_quit, Qnil); 1872
1873 return internal_condition_case (safe_run_hooks_1, Qt, safe_run_hooks_error);
1838} 1874}
1839 1875
1840/* If we get an error while running the hook, cause the hook variable 1876/* If we get an error while running the hook, cause the hook variable
@@ -1844,10 +1880,13 @@ safe_run_hooks_error (Lisp_Object data)
1844void 1880void
1845safe_run_hooks (Lisp_Object hook) 1881safe_run_hooks (Lisp_Object hook)
1846{ 1882{
1883 /* FIXME: our `internal_condition_case' does not provide any way to pass data
1884 to its body or to its handlers other than via globals such as
1885 dynamically-bound variables ;-) */
1847 int count = SPECPDL_INDEX (); 1886 int count = SPECPDL_INDEX ();
1848 specbind (Qinhibit_quit, hook); 1887 specbind (Qinhibit_quit, hook);
1849 1888
1850 internal_condition_case (safe_run_hooks_1, Qt, safe_run_hooks_error); 1889 run_hook_with_args (1, &hook, safe_run_hook_funcall);
1851 1890
1852 unbind_to (count, Qnil); 1891 unbind_to (count, Qnil);
1853} 1892}
@@ -2074,16 +2113,12 @@ make_ctrl_char (int c)
2074 the `display' property). POS is the position in that string under 2113 the `display' property). POS is the position in that string under
2075 the mouse. 2114 the mouse.
2076 2115
2077 OK_TO_OVERWRITE_KEYSTROKE_ECHO non-zero means it's okay if the help
2078 echo overwrites a keystroke echo currently displayed in the echo
2079 area.
2080
2081 Note: this function may only be called with HELP nil or a string 2116 Note: this function may only be called with HELP nil or a string
2082 from X code running asynchronously. */ 2117 from X code running asynchronously. */
2083 2118
2084void 2119void
2085show_help_echo (Lisp_Object help, Lisp_Object window, Lisp_Object object, 2120show_help_echo (Lisp_Object help, Lisp_Object window, Lisp_Object object,
2086 Lisp_Object pos, int ok_to_overwrite_keystroke_echo) 2121 Lisp_Object pos)
2087{ 2122{
2088 if (!NILP (help) && !STRINGP (help)) 2123 if (!NILP (help) && !STRINGP (help))
2089 { 2124 {
@@ -3013,7 +3048,7 @@ read_char (int commandflag, int nmaps, Lisp_Object *maps, Lisp_Object prev_event
3013 htem = Fcdr (htem); 3048 htem = Fcdr (htem);
3014 position = Fcar (htem); 3049 position = Fcar (htem);
3015 3050
3016 show_help_echo (help, window, object, position, 0); 3051 show_help_echo (help, window, object, position);
3017 3052
3018 /* We stopped being idle for this event; undo that. */ 3053 /* We stopped being idle for this event; undo that. */
3019 if (!end_time) 3054 if (!end_time)
@@ -3315,7 +3350,7 @@ static int
3315readable_events (int flags) 3350readable_events (int flags)
3316{ 3351{
3317 if (flags & READABLE_EVENTS_DO_TIMERS_NOW) 3352 if (flags & READABLE_EVENTS_DO_TIMERS_NOW)
3318 timer_check (1); 3353 timer_check ();
3319 3354
3320 /* If the buffer contains only FOCUS_IN_EVENT events, and 3355 /* If the buffer contains only FOCUS_IN_EVENT events, and
3321 READABLE_EVENTS_FILTER_EVENTS is set, report it as empty. */ 3356 READABLE_EVENTS_FILTER_EVENTS is set, report it as empty. */
@@ -4389,14 +4424,10 @@ timer_check_2 (void)
4389 Returns the time to wait until the next timer fires. 4424 Returns the time to wait until the next timer fires.
4390 If no timer is active, return -1. 4425 If no timer is active, return -1.
4391 4426
4392 As long as any timer is ripe, we run it. 4427 As long as any timer is ripe, we run it. */
4393
4394 DO_IT_NOW is now ignored. It used to mean that we should
4395 run the timer directly instead of queueing a timer-event.
4396 Now we always run timers directly. */
4397 4428
4398EMACS_TIME 4429EMACS_TIME
4399timer_check (int do_it_now) 4430timer_check (void)
4400{ 4431{
4401 EMACS_TIME nexttime; 4432 EMACS_TIME nexttime;
4402 4433
@@ -5405,7 +5436,6 @@ make_lispy_event (struct input_event *event)
5405 && (event->modifiers & down_modifier)) 5436 && (event->modifiers & down_modifier))
5406 { 5437 {
5407 Lisp_Object items, item; 5438 Lisp_Object items, item;
5408 int hpos;
5409 int i; 5439 int i;
5410 5440
5411 /* Find the menu bar item under `column'. */ 5441 /* Find the menu bar item under `column'. */
@@ -5974,10 +6004,10 @@ make_lispy_switch_frame (Lisp_Object frame)
5974 This doesn't use any caches. */ 6004 This doesn't use any caches. */
5975 6005
5976static int 6006static int
5977parse_modifiers_uncached (Lisp_Object symbol, int *modifier_end) 6007parse_modifiers_uncached (Lisp_Object symbol, EMACS_INT *modifier_end)
5978{ 6008{
5979 Lisp_Object name; 6009 Lisp_Object name;
5980 int i; 6010 EMACS_INT i;
5981 int modifiers; 6011 int modifiers;
5982 6012
5983 CHECK_SYMBOL (symbol); 6013 CHECK_SYMBOL (symbol);
@@ -5987,7 +6017,7 @@ parse_modifiers_uncached (Lisp_Object symbol, int *modifier_end)
5987 6017
5988 for (i = 0; i+2 <= SBYTES (name); ) 6018 for (i = 0; i+2 <= SBYTES (name); )
5989 { 6019 {
5990 int this_mod_end = 0; 6020 EMACS_INT this_mod_end = 0;
5991 int this_mod = 0; 6021 int this_mod = 0;
5992 6022
5993 /* See if the name continues with a modifier word. 6023 /* See if the name continues with a modifier word.
@@ -6184,7 +6214,7 @@ parse_modifiers (Lisp_Object symbol)
6184 return elements; 6214 return elements;
6185 else 6215 else
6186 { 6216 {
6187 int end; 6217 EMACS_INT end;
6188 int modifiers = parse_modifiers_uncached (symbol, &end); 6218 int modifiers = parse_modifiers_uncached (symbol, &end);
6189 Lisp_Object unmodified; 6219 Lisp_Object unmodified;
6190 Lisp_Object mask; 6220 Lisp_Object mask;
@@ -7097,7 +7127,7 @@ process_pending_signals (void)
7097#ifdef SIGIO /* for entire page */ 7127#ifdef SIGIO /* for entire page */
7098/* Note SIGIO has been undef'd if FIONREAD is missing. */ 7128/* Note SIGIO has been undef'd if FIONREAD is missing. */
7099 7129
7100static SIGTYPE 7130static void
7101input_available_signal (int signo) 7131input_available_signal (int signo)
7102{ 7132{
7103 /* Must preserve main program's value of errno. */ 7133 /* Must preserve main program's value of errno. */
@@ -7175,7 +7205,7 @@ add_user_signal (int sig, const char *name)
7175 signal (sig, handle_user_signal); 7205 signal (sig, handle_user_signal);
7176} 7206}
7177 7207
7178static SIGTYPE 7208static void
7179handle_user_signal (int sig) 7209handle_user_signal (int sig)
7180{ 7210{
7181 int old_errno = errno; 7211 int old_errno = errno;
@@ -8769,7 +8799,7 @@ access_keymap_keyremap (Lisp_Object map, Lisp_Object key, Lisp_Object prompt,
8769 The return value is non-zero if the remapping actually took place. */ 8799 The return value is non-zero if the remapping actually took place. */
8770 8800
8771static int 8801static int
8772keyremap_step (Lisp_Object *keybuf, int bufsize, volatile keyremap *fkey, 8802keyremap_step (Lisp_Object *keybuf, size_t bufsize, volatile keyremap *fkey,
8773 int input, int doit, int *diff, Lisp_Object prompt) 8803 int input, int doit, int *diff, Lisp_Object prompt)
8774{ 8804{
8775 Lisp_Object next, key; 8805 Lisp_Object next, key;
@@ -8862,7 +8892,7 @@ keyremap_step (Lisp_Object *keybuf, int bufsize, volatile keyremap *fkey,
8862 from the selected window's buffer. */ 8892 from the selected window's buffer. */
8863 8893
8864static int 8894static int
8865read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt, 8895read_key_sequence (Lisp_Object *keybuf, size_t bufsize, Lisp_Object prompt,
8866 int dont_downcase_last, int can_return_switch_frame, 8896 int dont_downcase_last, int can_return_switch_frame,
8867 int fix_current_buffer) 8897 int fix_current_buffer)
8868{ 8898{
@@ -9380,80 +9410,84 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
9380 last_real_key_start = t - 1; 9410 last_real_key_start = t - 1;
9381 } 9411 }
9382 9412
9383 /* Key sequences beginning with mouse clicks are 9413 if (last_real_key_start == 0)
9384 read using the keymaps in the buffer clicked on,
9385 not the current buffer. If we're at the
9386 beginning of a key sequence, switch buffers. */
9387 if (last_real_key_start == 0
9388 && WINDOWP (window)
9389 && BUFFERP (XWINDOW (window)->buffer)
9390 && XBUFFER (XWINDOW (window)->buffer) != current_buffer)
9391 { 9414 {
9392 XVECTOR (raw_keybuf)->contents[raw_keybuf_count++] = key; 9415 /* Key sequences beginning with mouse clicks are
9393 keybuf[t] = key; 9416 read using the keymaps in the buffer clicked on,
9394 mock_input = t + 1; 9417 not the current buffer. If we're at the
9395 9418 beginning of a key sequence, switch buffers. */
9396 /* Arrange to go back to the original buffer once we're 9419 if (WINDOWP (window)
9397 done reading the key sequence. Note that we can't 9420 && BUFFERP (XWINDOW (window)->buffer)
9398 use save_excursion_{save,restore} here, because they 9421 && XBUFFER (XWINDOW (window)->buffer) != current_buffer)
9399 save point as well as the current buffer; we don't 9422 {
9400 want to save point, because redisplay may change it, 9423 XVECTOR (raw_keybuf)->contents[raw_keybuf_count++] = key;
9401 to accommodate a Fset_window_start or something. We 9424 keybuf[t] = key;
9402 don't want to do this at the top of the function, 9425 mock_input = t + 1;
9403 because we may get input from a subprocess which 9426
9404 wants to change the selected window and stuff (say, 9427 /* Arrange to go back to the original buffer once we're
9405 emacsclient). */ 9428 done reading the key sequence. Note that we can't
9406 record_unwind_protect (Fset_buffer, Fcurrent_buffer ()); 9429 use save_excursion_{save,restore} here, because they
9407 9430 save point as well as the current buffer; we don't
9408 if (! FRAME_LIVE_P (XFRAME (selected_frame))) 9431 want to save point, because redisplay may change it,
9409 Fkill_emacs (Qnil); 9432 to accommodate a Fset_window_start or something. We
9410 set_buffer_internal (XBUFFER (XWINDOW (window)->buffer)); 9433 don't want to do this at the top of the function,
9411 orig_local_map = get_local_map (PT, current_buffer, 9434 because we may get input from a subprocess which
9412 Qlocal_map); 9435 wants to change the selected window and stuff (say,
9413 orig_keymap = get_local_map (PT, current_buffer, Qkeymap); 9436 emacsclient). */
9414 goto replay_sequence; 9437 record_unwind_protect (Fset_buffer, Fcurrent_buffer ());
9415 } 9438
9439 if (! FRAME_LIVE_P (XFRAME (selected_frame)))
9440 Fkill_emacs (Qnil);
9441 set_buffer_internal (XBUFFER (XWINDOW (window)->buffer));
9442 orig_local_map = get_local_map (PT, current_buffer,
9443 Qlocal_map);
9444 orig_keymap = get_local_map (PT, current_buffer,
9445 Qkeymap);
9446 goto replay_sequence;
9447 }
9416 9448
9417 /* For a mouse click, get the local text-property keymap 9449 /* For a mouse click, get the local text-property keymap
9418 of the place clicked on, rather than point. */ 9450 of the place clicked on, rather than point. */
9419 if (last_real_key_start == 0 9451 if (CONSP (XCDR (key))
9420 && CONSP (XCDR (key)) 9452 && ! localized_local_map)
9421 && ! localized_local_map) 9453 {
9422 { 9454 Lisp_Object map_here, start, pos;
9423 Lisp_Object map_here, start, pos;
9424 9455
9425 localized_local_map = 1; 9456 localized_local_map = 1;
9426 start = EVENT_START (key); 9457 start = EVENT_START (key);
9427 9458
9428 if (CONSP (start) && POSN_INBUFFER_P (start)) 9459 if (CONSP (start) && POSN_INBUFFER_P (start))
9429 {
9430 pos = POSN_BUFFER_POSN (start);
9431 if (INTEGERP (pos)
9432 && XINT (pos) >= BEGV
9433 && XINT (pos) <= ZV)
9434 { 9460 {
9435 map_here = get_local_map (XINT (pos), 9461 pos = POSN_BUFFER_POSN (start);
9436 current_buffer, Qlocal_map); 9462 if (INTEGERP (pos)
9437 if (!EQ (map_here, orig_local_map)) 9463 && XINT (pos) >= BEGV
9464 && XINT (pos) <= ZV)
9438 { 9465 {
9439 orig_local_map = map_here; 9466 map_here = get_local_map (XINT (pos),
9440 ++localized_local_map; 9467 current_buffer,
9441 } 9468 Qlocal_map);
9469 if (!EQ (map_here, orig_local_map))
9470 {
9471 orig_local_map = map_here;
9472 ++localized_local_map;
9473 }
9442 9474
9443 map_here = get_local_map (XINT (pos), 9475 map_here = get_local_map (XINT (pos),
9444 current_buffer, Qkeymap); 9476 current_buffer,
9445 if (!EQ (map_here, orig_keymap)) 9477 Qkeymap);
9446 { 9478 if (!EQ (map_here, orig_keymap))
9447 orig_keymap = map_here; 9479 {
9448 ++localized_local_map; 9480 orig_keymap = map_here;
9449 } 9481 ++localized_local_map;
9482 }
9450 9483
9451 if (localized_local_map > 1) 9484 if (localized_local_map > 1)
9452 { 9485 {
9453 keybuf[t] = key; 9486 keybuf[t] = key;
9454 mock_input = t + 1; 9487 mock_input = t + 1;
9455 9488
9456 goto replay_sequence; 9489 goto replay_sequence;
9490 }
9457 } 9491 }
9458 } 9492 }
9459 } 9493 }
@@ -10135,11 +10169,11 @@ a special event, so ignore the prefix argument and don't clear it. */)
10135 if (SYMBOLP (cmd)) 10169 if (SYMBOLP (cmd))
10136 { 10170 {
10137 tem = Fget (cmd, Qdisabled); 10171 tem = Fget (cmd, Qdisabled);
10138 if (!NILP (tem) && !NILP (Vrun_hooks)) 10172 if (!NILP (tem))
10139 { 10173 {
10140 tem = Fsymbol_value (Qdisabled_command_function); 10174 tem = Fsymbol_value (Qdisabled_command_function);
10141 if (!NILP (tem)) 10175 if (!NILP (tem))
10142 return call1 (Vrun_hooks, Qdisabled_command_function); 10176 return Frun_hooks (1, &Qdisabled_command_function);
10143 } 10177 }
10144 } 10178 }
10145 10179
@@ -10312,9 +10346,9 @@ give to the command you invoke, if it asks for an argument. */)
10312 sprintf (newmessage, "You can run the command `%s' with %s", 10346 sprintf (newmessage, "You can run the command `%s' with %s",
10313 SDATA (SYMBOL_NAME (function)), 10347 SDATA (SYMBOL_NAME (function)),
10314 SDATA (binding)); 10348 SDATA (binding));
10315 message2_nolog (newmessage, 10349 message2 (newmessage,
10316 strlen (newmessage), 10350 strlen (newmessage),
10317 STRING_MULTIBYTE (binding)); 10351 STRING_MULTIBYTE (binding));
10318 if (NUMBERP (Vsuggest_key_bindings)) 10352 if (NUMBERP (Vsuggest_key_bindings))
10319 waited = sit_for (Vsuggest_key_bindings, 0, 2); 10353 waited = sit_for (Vsuggest_key_bindings, 0, 2);
10320 else 10354 else
@@ -10623,6 +10657,7 @@ On such systems, Emacs starts a subshell instead of suspending. */)
10623 int old_height, old_width; 10657 int old_height, old_width;
10624 int width, height; 10658 int width, height;
10625 struct gcpro gcpro1; 10659 struct gcpro gcpro1;
10660 Lisp_Object hook;
10626 10661
10627 if (tty_list && tty_list->next) 10662 if (tty_list && tty_list->next)
10628 error ("There are other tty frames open; close them before suspending Emacs"); 10663 error ("There are other tty frames open; close them before suspending Emacs");
@@ -10631,8 +10666,8 @@ On such systems, Emacs starts a subshell instead of suspending. */)
10631 CHECK_STRING (stuffstring); 10666 CHECK_STRING (stuffstring);
10632 10667
10633 /* Run the functions in suspend-hook. */ 10668 /* Run the functions in suspend-hook. */
10634 if (!NILP (Vrun_hooks)) 10669 hook = intern ("suspend-hook");
10635 call1 (Vrun_hooks, intern ("suspend-hook")); 10670 Frun_hooks (1, &hook);
10636 10671
10637 GCPRO1 (stuffstring); 10672 GCPRO1 (stuffstring);
10638 get_tty_size (fileno (CURTTY ()->input), &old_width, &old_height); 10673 get_tty_size (fileno (CURTTY ()->input), &old_width, &old_height);
@@ -10656,8 +10691,8 @@ On such systems, Emacs starts a subshell instead of suspending. */)
10656 change_frame_size (SELECTED_FRAME (), height, width, 0, 0, 0); 10691 change_frame_size (SELECTED_FRAME (), height, width, 0, 0, 0);
10657 10692
10658 /* Run suspend-resume-hook. */ 10693 /* Run suspend-resume-hook. */
10659 if (!NILP (Vrun_hooks)) 10694 hook = intern ("suspend-resume-hook");
10660 call1 (Vrun_hooks, intern ("suspend-resume-hook")); 10695 Frun_hooks (1, &hook);
10661 10696
10662 UNGCPRO; 10697 UNGCPRO;
10663 return Qnil; 10698 return Qnil;
@@ -10732,7 +10767,7 @@ clear_waiting_for_input (void)
10732 SIGINT was generated by C-g, so we call handle_interrupt. 10767 SIGINT was generated by C-g, so we call handle_interrupt.
10733 Otherwise, the handler kills Emacs. */ 10768 Otherwise, the handler kills Emacs. */
10734 10769
10735static SIGTYPE 10770static void
10736interrupt_signal (int signalnum) /* If we don't have an argument, some */ 10771interrupt_signal (int signalnum) /* If we don't have an argument, some */
10737 /* compilers complain in signal calls. */ 10772 /* compilers complain in signal calls. */
10738{ 10773{
@@ -11458,9 +11493,6 @@ syms_of_keyboard (void)
11458 Qdeferred_action_function = intern_c_string ("deferred-action-function"); 11493 Qdeferred_action_function = intern_c_string ("deferred-action-function");
11459 staticpro (&Qdeferred_action_function); 11494 staticpro (&Qdeferred_action_function);
11460 11495
11461 Qcommand_hook_internal = intern_c_string ("command-hook-internal");
11462 staticpro (&Qcommand_hook_internal);
11463
11464 Qfunction_key = intern_c_string ("function-key"); 11496 Qfunction_key = intern_c_string ("function-key");
11465 staticpro (&Qfunction_key); 11497 staticpro (&Qfunction_key);
11466 Qmouse_click = intern_c_string ("mouse-click"); 11498 Qmouse_click = intern_c_string ("mouse-click");
@@ -11580,12 +11612,12 @@ syms_of_keyboard (void)
11580 last_point_position_window = Qnil; 11612 last_point_position_window = Qnil;
11581 11613
11582 { 11614 {
11583 const struct event_head *p; 11615 int i;
11616 int len = sizeof (head_table) / sizeof (head_table[0]);
11584 11617
11585 for (p = head_table; 11618 for (i = 0; i < len; i++)
11586 p < head_table + (sizeof (head_table) / sizeof (head_table[0]));
11587 p++)
11588 { 11619 {
11620 const struct event_head *p = &head_table[i];
11589 *p->var = intern_c_string (p->name); 11621 *p->var = intern_c_string (p->name);
11590 staticpro (p->var); 11622 staticpro (p->var);
11591 Fput (*p->var, Qevent_kind, *p->kind); 11623 Fput (*p->var, Qevent_kind, *p->kind);
@@ -11928,22 +11960,18 @@ Buffer modification stores t in this variable. */);
11928 Qdeactivate_mark = intern_c_string ("deactivate-mark"); 11960 Qdeactivate_mark = intern_c_string ("deactivate-mark");
11929 staticpro (&Qdeactivate_mark); 11961 staticpro (&Qdeactivate_mark);
11930 11962
11931 DEFVAR_LISP ("command-hook-internal", Vcommand_hook_internal,
11932 doc: /* Temporary storage of `pre-command-hook' or `post-command-hook'. */);
11933 Vcommand_hook_internal = Qnil;
11934
11935 DEFVAR_LISP ("pre-command-hook", Vpre_command_hook, 11963 DEFVAR_LISP ("pre-command-hook", Vpre_command_hook,
11936 doc: /* Normal hook run before each command is executed. 11964 doc: /* Normal hook run before each command is executed.
11937If an unhandled error happens in running this hook, 11965If an unhandled error happens in running this hook,
11938the hook value is set to nil, since otherwise the error 11966the function in which the error occurred is unconditionally removed, since
11939might happen repeatedly and make Emacs nonfunctional. */); 11967otherwise the error might happen repeatedly and make Emacs nonfunctional. */);
11940 Vpre_command_hook = Qnil; 11968 Vpre_command_hook = Qnil;
11941 11969
11942 DEFVAR_LISP ("post-command-hook", Vpost_command_hook, 11970 DEFVAR_LISP ("post-command-hook", Vpost_command_hook,
11943 doc: /* Normal hook run after each command is executed. 11971 doc: /* Normal hook run after each command is executed.
11944If an unhandled error happens in running this hook, 11972If an unhandled error happens in running this hook,
11945the hook value is set to nil, since otherwise the error 11973the function in which the error occurred is unconditionally removed, since
11946might happen repeatedly and make Emacs nonfunctional. */); 11974otherwise the error might happen repeatedly and make Emacs nonfunctional. */);
11947 Vpost_command_hook = Qnil; 11975 Vpost_command_hook = Qnil;
11948 11976
11949#if 0 11977#if 0