diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 6 | ||||
| -rw-r--r-- | src/keymap.c | 39 |
2 files changed, 33 insertions, 12 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 8404864476a..6b0f59a99c0 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,9 @@ | |||
| 1 | 2001-01-24 Gerd Moellmann <gerd@gnu.org> | ||
| 2 | |||
| 3 | * keymap.c (Fwhere_is_internal): Don't nreverse the cached | ||
| 4 | value in where_is_cache; the next lookup in the cache returns | ||
| 5 | something bogus if we do. | ||
| 6 | |||
| 1 | 2001-01-24 Eli Zaretskii <eliz@is.elta.co.il> | 7 | 2001-01-24 Eli Zaretskii <eliz@is.elta.co.il> |
| 2 | 8 | ||
| 3 | * xdisp.c (syms_of_xdisp) <Stool_bar_lines_needed>: Don't defsubr | 9 | * xdisp.c (syms_of_xdisp) <Stool_bar_lines_needed>: Don't defsubr |
diff --git a/src/keymap.c b/src/keymap.c index f19b1e6146b..c45f4395eda 100644 --- a/src/keymap.c +++ b/src/keymap.c | |||
| @@ -2244,9 +2244,9 @@ indirect definition itself.") | |||
| 2244 | Lisp_Object firstonly, noindirect; | 2244 | Lisp_Object firstonly, noindirect; |
| 2245 | { | 2245 | { |
| 2246 | Lisp_Object sequences, keymaps; | 2246 | Lisp_Object sequences, keymaps; |
| 2247 | struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; | ||
| 2248 | /* 1 means ignore all menu bindings entirely. */ | 2247 | /* 1 means ignore all menu bindings entirely. */ |
| 2249 | int nomenus = !NILP (firstonly) && !EQ (firstonly, Qnon_ascii); | 2248 | int nomenus = !NILP (firstonly) && !EQ (firstonly, Qnon_ascii); |
| 2249 | Lisp_Object result; | ||
| 2250 | 2250 | ||
| 2251 | /* Find the relevant keymaps. */ | 2251 | /* Find the relevant keymaps. */ |
| 2252 | if (CONSP (keymap) && KEYMAPP (XCAR (keymap))) | 2252 | if (CONSP (keymap) && KEYMAPP (XCAR (keymap))) |
| @@ -2266,6 +2266,10 @@ indirect definition itself.") | |||
| 2266 | We don't really need to check `keymap'. */ | 2266 | We don't really need to check `keymap'. */ |
| 2267 | if (nomenus && NILP (noindirect) && NILP (keymap)) | 2267 | if (nomenus && NILP (noindirect) && NILP (keymap)) |
| 2268 | { | 2268 | { |
| 2269 | Lisp_Object *defns; | ||
| 2270 | int i, n; | ||
| 2271 | struct gcpro gcpro1, gcpro2; | ||
| 2272 | |||
| 2269 | /* Check heuristic-consistency of the cache. */ | 2273 | /* Check heuristic-consistency of the cache. */ |
| 2270 | if (NILP (Fequal (keymaps, where_is_cache_keymaps))) | 2274 | if (NILP (Fequal (keymaps, where_is_cache_keymaps))) |
| 2271 | where_is_cache = Qnil; | 2275 | where_is_cache = Qnil; |
| @@ -2285,25 +2289,36 @@ indirect definition itself.") | |||
| 2285 | where_is_cache_keymaps = keymaps; | 2289 | where_is_cache_keymaps = keymaps; |
| 2286 | } | 2290 | } |
| 2287 | 2291 | ||
| 2292 | /* We want to process definitions from the last to the first. | ||
| 2293 | Instead of consing, copy definitions to a vector and step | ||
| 2294 | over that vector. */ | ||
| 2288 | sequences = Fgethash (definition, where_is_cache, Qnil); | 2295 | sequences = Fgethash (definition, where_is_cache, Qnil); |
| 2289 | /* Verify that the key bindings are not shadowed. */ | 2296 | n = Flength (sequences); |
| 2290 | /* key-binding can GC. */ | 2297 | defns = (Lisp_Object *) alloca (n * sizeof *defns); |
| 2291 | GCPRO3 (definition, sequences, keymaps); | 2298 | for (i = 0; CONSP (sequences); sequences = XCDR (sequences)) |
| 2292 | for (sequences = Fnreverse (sequences); | 2299 | defns[i++] = XCAR (sequences); |
| 2293 | CONSP (sequences); | 2300 | |
| 2294 | sequences = XCDR (sequences)) | 2301 | /* Verify that the key bindings are not shadowed. Note that |
| 2295 | if (EQ (shadow_lookup (keymaps, XCAR (sequences), Qnil), definition) | 2302 | the following can GC. */ |
| 2296 | && ascii_sequence_p (XCAR (sequences))) | 2303 | GCPRO2 (definition, keymaps); |
| 2297 | RETURN_UNGCPRO (XCAR (sequences)); | 2304 | result = Qnil; |
| 2298 | RETURN_UNGCPRO (Qnil); | 2305 | for (i = n - 1; i >= 0; --i) |
| 2306 | if (EQ (shadow_lookup (keymaps, defns[i], Qnil), definition) | ||
| 2307 | && ascii_sequence_p (defns[i])) | ||
| 2308 | break; | ||
| 2309 | |||
| 2310 | result = i >= 0 ? defns[i] : Qnil; | ||
| 2311 | UNGCPRO; | ||
| 2299 | } | 2312 | } |
| 2300 | else | 2313 | else |
| 2301 | { | 2314 | { |
| 2302 | /* Kill the cache so that where_is_internal_1 doesn't think | 2315 | /* Kill the cache so that where_is_internal_1 doesn't think |
| 2303 | we're filling it up. */ | 2316 | we're filling it up. */ |
| 2304 | where_is_cache = Qnil; | 2317 | where_is_cache = Qnil; |
| 2305 | return where_is_internal (definition, keymaps, firstonly, noindirect); | 2318 | result = where_is_internal (definition, keymaps, firstonly, noindirect); |
| 2306 | } | 2319 | } |
| 2320 | |||
| 2321 | return result; | ||
| 2307 | } | 2322 | } |
| 2308 | 2323 | ||
| 2309 | /* This is the function that Fwhere_is_internal calls using map_char_table. | 2324 | /* This is the function that Fwhere_is_internal calls using map_char_table. |