Commit 30690496 authored by Dave Love's avatar Dave Love
Browse files

(menu_bar_items, tool_bar_items, Fexecute_extended_command): Deal with

`keymap' property.
(read_key_sequence): Track map from `keymap' property as well as
`local_map'.
parent b4030d7b
...@@ -1695,7 +1695,7 @@ static Lisp_Object ...@@ -1695,7 +1695,7 @@ static Lisp_Object
safe_run_hooks_error (data) safe_run_hooks_error (data)
Lisp_Object data; Lisp_Object data;
{ {
Fset (Vinhibit_quit, Qnil); return Fset (Vinhibit_quit, Qnil);
} }
/* If we get an error while running the hook, cause the hook variable /* If we get an error while running the hook, cause the hook variable
...@@ -2873,6 +2873,7 @@ tracking_off (old_value) ...@@ -2873,6 +2873,7 @@ tracking_off (old_value)
get_input_pending (&input_pending, 1); get_input_pending (&input_pending, 1);
} }
} }
return Qnil;
} }
DEFUN ("track-mouse", Ftrack_mouse, Strack_mouse, 0, UNEVALLED, 0, DEFUN ("track-mouse", Ftrack_mouse, Strack_mouse, 0, UNEVALLED, 0,
...@@ -5951,11 +5952,18 @@ menu_bar_items (old) ...@@ -5951,11 +5952,18 @@ menu_bar_items (old)
} }
else else
{ {
/* No, so use major and minor mode keymaps. */ /* No, so use major and minor mode keymaps and keymap property. */
int extra_maps = 2;
Lisp_Object map = get_local_map (PT, current_buffer, keymap);
if (!NILP (map))
extra_maps = 3;
nmaps = current_minor_maps (NULL, &tmaps); nmaps = current_minor_maps (NULL, &tmaps);
maps = (Lisp_Object *) alloca ((nmaps + 2) * sizeof (maps[0])); maps = (Lisp_Object *) alloca ((nmaps + extra_maps)
* sizeof (maps[0]));
bcopy (tmaps, maps, nmaps * sizeof (maps[0])); bcopy (tmaps, maps, nmaps * sizeof (maps[0]));
maps[nmaps++] = get_local_map (PT, current_buffer); if (!NILP (map))
maps[nmaps++] = get_local_map (PT, current_buffer, keymap);
maps[nmaps++] = get_local_map (PT, current_buffer, local_map);
} }
maps[nmaps++] = current_global_map; maps[nmaps++] = current_global_map;
} }
...@@ -6603,11 +6611,18 @@ tool_bar_items (reuse, nitems) ...@@ -6603,11 +6611,18 @@ tool_bar_items (reuse, nitems)
} }
else else
{ {
/* No, so use major and minor mode keymaps. */ /* No, so use major and minor mode keymaps and keymap property. */
int extra_maps = 2;
Lisp_Object map = get_local_map (PT, current_buffer, keymap);
if (!NILP (map))
extra_maps = 3;
nmaps = current_minor_maps (NULL, &tmaps); nmaps = current_minor_maps (NULL, &tmaps);
maps = (Lisp_Object *) alloca ((nmaps + 2) * sizeof (maps[0])); maps = (Lisp_Object *) alloca ((nmaps + extra_maps)
* sizeof (maps[0]));
bcopy (tmaps, maps, nmaps * sizeof (maps[0])); bcopy (tmaps, maps, nmaps * sizeof (maps[0]));
maps[nmaps++] = get_local_map (PT, current_buffer); if (!NILP (map))
maps[nmaps++] = get_local_map (PT, current_buffer, keymap);
maps[nmaps++] = get_local_map (PT, current_buffer, local_map);
} }
/* Add global keymap at the end. */ /* Add global keymap at the end. */
...@@ -7421,6 +7436,10 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last, ...@@ -7421,6 +7436,10 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last,
/* The local map to start out with at start of key sequence. */ /* The local map to start out with at start of key sequence. */
Lisp_Object orig_local_map; Lisp_Object orig_local_map;
/* The map from the `keymap' property to start out with at start of
key sequence. */
Lisp_Object orig_keymap;
/* 1 if we have already considered switching to the local-map property /* 1 if we have already considered switching to the local-map property
of the place where a mouse click occurred. */ of the place where a mouse click occurred. */
int localized_local_map = 0; int localized_local_map = 0;
...@@ -7542,7 +7561,8 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last, ...@@ -7542,7 +7561,8 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last,
&junk); &junk);
#endif /* GOBBLE_FIRST_EVENT */ #endif /* GOBBLE_FIRST_EVENT */
orig_local_map = get_local_map (PT, current_buffer); orig_local_map = get_local_map (PT, current_buffer, local_map);
orig_keymap = get_local_map (PT, current_buffer, keymap);
/* We jump here when the key sequence has been thoroughly changed, and /* We jump here when the key sequence has been thoroughly changed, and
we need to rescan it starting from the beginning. When we jump here, we need to rescan it starting from the beginning. When we jump here,
...@@ -7578,14 +7598,21 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last, ...@@ -7578,14 +7598,21 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last,
} }
else else
{ {
int extra_maps = 2;
nmaps = current_minor_maps (0, &maps); nmaps = current_minor_maps (0, &maps);
if (nmaps + 2 > nmaps_allocated) if (!NILP (orig_keymap))
extra_maps = 3;
if (nmaps + extra_maps > nmaps_allocated)
{ {
submaps = (Lisp_Object *) alloca ((nmaps+2) * sizeof (submaps[0])); submaps = (Lisp_Object *) alloca ((nmaps+extra_maps)
defs = (Lisp_Object *) alloca ((nmaps+2) * sizeof (defs[0])); * sizeof (submaps[0]));
nmaps_allocated = nmaps + 2; defs = (Lisp_Object *) alloca ((nmaps+extra_maps)
* sizeof (defs[0]));
nmaps_allocated = nmaps + extra_maps;
} }
bcopy (maps, submaps, nmaps * sizeof (submaps[0])); bcopy (maps, submaps, nmaps * sizeof (submaps[0]));
if (!NILP (orig_keymap))
submaps[nmaps++] = orig_keymap;
submaps[nmaps++] = orig_local_map; submaps[nmaps++] = orig_local_map;
} }
submaps[nmaps++] = current_global_map; submaps[nmaps++] = current_global_map;
...@@ -7704,7 +7731,8 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last, ...@@ -7704,7 +7731,8 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last,
interrupted_kboard->kbd_queue); interrupted_kboard->kbd_queue);
} }
mock_input = 0; mock_input = 0;
orig_local_map = get_local_map (PT, current_buffer); orig_local_map = get_local_map (PT, current_buffer, local_map);
orig_keymap = get_local_map (PT, current_buffer, keymap);
goto replay_sequence; goto replay_sequence;
} }
#endif #endif
...@@ -7749,7 +7777,8 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last, ...@@ -7749,7 +7777,8 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last,
Fset_buffer (XWINDOW (selected_window)->buffer); Fset_buffer (XWINDOW (selected_window)->buffer);
} }
orig_local_map = get_local_map (PT, current_buffer); orig_local_map = get_local_map (PT, current_buffer, local_map);
orig_keymap = get_local_map (PT, current_buffer, keymap);
goto replay_sequence; goto replay_sequence;
} }
...@@ -7763,7 +7792,8 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last, ...@@ -7763,7 +7792,8 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last,
keybuf[t++] = key; keybuf[t++] = key;
mock_input = t; mock_input = t;
Vquit_flag = Qnil; Vquit_flag = Qnil;
orig_local_map = get_local_map (PT, current_buffer); orig_local_map = get_local_map (PT, current_buffer, local_map);
orig_keymap = get_local_map (PT, current_buffer, keymap);
goto replay_sequence; goto replay_sequence;
} }
...@@ -7848,8 +7878,12 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last, ...@@ -7848,8 +7878,12 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last,
if (! FRAME_LIVE_P (XFRAME (selected_frame))) if (! FRAME_LIVE_P (XFRAME (selected_frame)))
Fkill_emacs (Qnil); Fkill_emacs (Qnil);
set_buffer_internal (XBUFFER (XWINDOW (window)->buffer)); set_buffer_internal (XBUFFER (XWINDOW
orig_local_map = get_local_map (PT, current_buffer); (window)->buffer)
);
orig_local_map = get_local_map (PT, current_buffer,
local_map);
orig_keymap = get_local_map (PT, current_buffer, keymap);
goto replay_sequence; goto replay_sequence;
} }
...@@ -7870,13 +7904,24 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last, ...@@ -7870,13 +7904,24 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last,
if (INTEGERP (pos) if (INTEGERP (pos)
&& XINT (pos) >= BEG && XINT (pos) <= Z) && XINT (pos) >= BEG && XINT (pos) <= Z)
{ {
map_here = get_local_map (XINT (pos), current_buffer); map_here = get_local_map (XINT (pos),
current_buffer, local_map);
if (!EQ (map_here, orig_local_map)) if (!EQ (map_here, orig_local_map))
{ {
orig_local_map = map_here; orig_local_map = map_here;
keybuf[t] = key; keybuf[t] = key;
mock_input = t + 1; mock_input = t + 1;
goto replay_sequence;
}
map_here = get_local_map (XINT (pos),
current_buffer, keymap);
if (!EQ (map_here, orig_keymap))
{
orig_keymap = map_here;
keybuf[t] = key;
mock_input = t + 1;
goto replay_sequence; goto replay_sequence;
} }
} }
...@@ -7902,21 +7947,22 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last, ...@@ -7902,21 +7947,22 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last,
reconsider the key sequence with that keymap. */ reconsider the key sequence with that keymap. */
if (CONSP (POSN_STRING (EVENT_START (key)))) if (CONSP (POSN_STRING (EVENT_START (key))))
{ {
Lisp_Object string, pos, map; Lisp_Object string, pos, map, map2;
string = POSN_STRING (EVENT_START (key)); string = POSN_STRING (EVENT_START (key));
pos = XCDR (string); pos = XCDR (string);
string = XCAR (string); string = XCAR (string);
if (pos >= 0 && pos < XSTRING (string)->size)
if (XINT (pos) >= 0 {
&& XINT (pos) < XSTRING (string)->size map = Fget_text_property (pos, Qlocal_map, string);
&& (map = Fget_text_property (pos, Qlocal_map, if (!NILP (map))
string), orig_local_map = map;
!NILP (map))) map2 = Fget_text_property (pos, Qkeymap, string);
{ if (!NILP (map2))
orig_local_map = map; orig_keymap = map2;
goto replay_sequence; if (!NILP (map) || !NILP (map2))
} goto replay_sequence;
}
} }
goto replay_key; goto replay_key;
...@@ -8896,11 +8942,18 @@ current_active_maps (maps_p) ...@@ -8896,11 +8942,18 @@ current_active_maps (maps_p)
} }
else else
{ {
/* No, so use major and minor mode keymaps. */ /* No, so use major and minor mode keymaps and keymap property. */
int extra_maps = 2;
Lisp_Object map = get_local_map (PT, current_buffer, keymap);
if (!NILP (map))
extra_maps = 3;
nmaps = current_minor_maps (NULL, &tmaps); nmaps = current_minor_maps (NULL, &tmaps);
maps = (Lisp_Object *) xmalloc ((nmaps + 2) * sizeof (maps[0])); maps = (Lisp_Object *) alloca ((nmaps + extra_maps)
* sizeof (maps[0]));
bcopy (tmaps, maps, nmaps * sizeof (maps[0])); bcopy (tmaps, maps, nmaps * sizeof (maps[0]));
maps[nmaps++] = get_local_map (PT, current_buffer); if (!NILP (map))
maps[nmaps++] = get_local_map (PT, current_buffer, keymap);
maps[nmaps++] = get_local_map (PT, current_buffer, local_map);
} }
maps[nmaps++] = current_global_map; maps[nmaps++] = current_global_map;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment