diff options
| author | Karl Heuer | 1994-04-20 04:22:24 +0000 |
|---|---|---|
| committer | Karl Heuer | 1994-04-20 04:22:24 +0000 |
| commit | 925083d1c26e9973f3425a8be31965f046804c05 (patch) | |
| tree | a93b9a930a401e5ec8e441a33fc75c016074c52a /src | |
| parent | 39e9ebcd7ff1f9ddeb9fb1d323b20d0eb88ed2fd (diff) | |
| download | emacs-925083d1c26e9973f3425a8be31965f046804c05.tar.gz emacs-925083d1c26e9973f3425a8be31965f046804c05.zip | |
(describe_map_tree, describe_map): Skip keymaps we've seen before.
Diffstat (limited to 'src')
| -rw-r--r-- | src/keymap.c | 34 |
1 files changed, 23 insertions, 11 deletions
diff --git a/src/keymap.c b/src/keymap.c index 8f9b9d8a011..44563286e72 100644 --- a/src/keymap.c +++ b/src/keymap.c | |||
| @@ -1878,8 +1878,8 @@ describe_map_tree (startmap, partial, shadow, prefix, title, nomenu) | |||
| 1878 | char *title; | 1878 | char *title; |
| 1879 | int nomenu; | 1879 | int nomenu; |
| 1880 | { | 1880 | { |
| 1881 | Lisp_Object maps; | 1881 | Lisp_Object maps, seen; |
| 1882 | struct gcpro gcpro1; | 1882 | struct gcpro gcpro1, gcpro2; |
| 1883 | int something = 0; | 1883 | int something = 0; |
| 1884 | char *key_heading | 1884 | char *key_heading |
| 1885 | = "\ | 1885 | = "\ |
| @@ -1887,7 +1887,8 @@ key binding\n\ | |||
| 1887 | --- -------\n"; | 1887 | --- -------\n"; |
| 1888 | 1888 | ||
| 1889 | maps = Faccessible_keymaps (startmap, prefix); | 1889 | maps = Faccessible_keymaps (startmap, prefix); |
| 1890 | GCPRO1 (maps); | 1890 | seen = Qnil; |
| 1891 | GCPRO2 (maps, seen); | ||
| 1891 | 1892 | ||
| 1892 | if (nomenu) | 1893 | if (nomenu) |
| 1893 | { | 1894 | { |
| @@ -1967,7 +1968,8 @@ key binding\n\ | |||
| 1967 | sub_shadows = Fcons (shmap, sub_shadows); | 1968 | sub_shadows = Fcons (shmap, sub_shadows); |
| 1968 | } | 1969 | } |
| 1969 | 1970 | ||
| 1970 | describe_map (Fcdr (elt), Fcar (elt), describe_command, partial, sub_shadows); | 1971 | describe_map (Fcdr (elt), Fcar (elt), describe_command, |
| 1972 | partial, sub_shadows, &seen); | ||
| 1971 | 1973 | ||
| 1972 | skip: ; | 1974 | skip: ; |
| 1973 | } | 1975 | } |
| @@ -2024,15 +2026,16 @@ shadow_lookup (shadow, key, flag) | |||
| 2024 | 2026 | ||
| 2025 | /* Describe the contents of map MAP, assuming that this map itself is | 2027 | /* Describe the contents of map MAP, assuming that this map itself is |
| 2026 | reached by the sequence of prefix keys KEYS (a string or vector). | 2028 | reached by the sequence of prefix keys KEYS (a string or vector). |
| 2027 | PARTIAL, SHADOW is as in `describe_map_tree' above. */ | 2029 | PARTIAL, SHADOW are as in `describe_map_tree' above. */ |
| 2028 | 2030 | ||
| 2029 | static void | 2031 | static void |
| 2030 | describe_map (map, keys, elt_describer, partial, shadow) | 2032 | describe_map (map, keys, elt_describer, partial, shadow, seen) |
| 2031 | register Lisp_Object map; | 2033 | register Lisp_Object map; |
| 2032 | Lisp_Object keys; | 2034 | Lisp_Object keys; |
| 2033 | int (*elt_describer) (); | 2035 | int (*elt_describer) (); |
| 2034 | int partial; | 2036 | int partial; |
| 2035 | Lisp_Object shadow; | 2037 | Lisp_Object shadow; |
| 2038 | Lisp_Object *seen; | ||
| 2036 | { | 2039 | { |
| 2037 | Lisp_Object elt_prefix; | 2040 | Lisp_Object elt_prefix; |
| 2038 | Lisp_Object tail, definition, event; | 2041 | Lisp_Object tail, definition, event; |
| @@ -2044,7 +2047,6 @@ describe_map (map, keys, elt_describer, partial, shadow) | |||
| 2044 | 2047 | ||
| 2045 | if (!NILP (keys) && XFASTINT (Flength (keys)) > 0) | 2048 | if (!NILP (keys) && XFASTINT (Flength (keys)) > 0) |
| 2046 | { | 2049 | { |
| 2047 | Lisp_Object tem; | ||
| 2048 | /* Call Fkey_description first, to avoid GC bug for the other string. */ | 2050 | /* Call Fkey_description first, to avoid GC bug for the other string. */ |
| 2049 | tem = Fkey_description (keys); | 2051 | tem = Fkey_description (keys); |
| 2050 | elt_prefix = concat2 (tem, build_string (" ")); | 2052 | elt_prefix = concat2 (tem, build_string (" ")); |
| @@ -2063,17 +2065,17 @@ describe_map (map, keys, elt_describer, partial, shadow) | |||
| 2063 | 2065 | ||
| 2064 | GCPRO3 (elt_prefix, definition, kludge); | 2066 | GCPRO3 (elt_prefix, definition, kludge); |
| 2065 | 2067 | ||
| 2066 | for (tail = XCONS (map)->cdr; CONSP (tail); tail = Fcdr (tail)) | 2068 | for (tail = map; CONSP (tail); tail = XCONS (tail)->cdr) |
| 2067 | { | 2069 | { |
| 2068 | QUIT; | 2070 | QUIT; |
| 2069 | 2071 | ||
| 2070 | if (XTYPE (XCONS (tail)->car) == Lisp_Vector) | 2072 | if (XTYPE (XCONS (tail)->car) == Lisp_Vector) |
| 2071 | describe_vector (XCONS (tail)->car, | 2073 | describe_vector (XCONS (tail)->car, |
| 2072 | elt_prefix, elt_describer, partial, shadow); | 2074 | elt_prefix, elt_describer, partial, shadow); |
| 2073 | else | 2075 | else if (CONSP (XCONS (tail)->car)) |
| 2074 | { | 2076 | { |
| 2075 | event = Fcar_safe (Fcar (tail)); | 2077 | event = XCONS (XCONS (tail)->car)->car; |
| 2076 | definition = get_keyelt (Fcdr_safe (Fcar (tail)), 0); | 2078 | definition = get_keyelt (XCONS (XCONS (tail)->car)->cdr, 0); |
| 2077 | 2079 | ||
| 2078 | /* Don't show undefined commands or suppressed commands. */ | 2080 | /* Don't show undefined commands or suppressed commands. */ |
| 2079 | if (NILP (definition)) continue; | 2081 | if (NILP (definition)) continue; |
| @@ -2114,6 +2116,16 @@ describe_map (map, keys, elt_describer, partial, shadow) | |||
| 2114 | for alignment purposes. */ | 2116 | for alignment purposes. */ |
| 2115 | (*elt_describer) (definition); | 2117 | (*elt_describer) (definition); |
| 2116 | } | 2118 | } |
| 2119 | else if (EQ (XCONS (tail)->car, Qkeymap)) | ||
| 2120 | { | ||
| 2121 | /* The same keymap might be in the structure twice, if we're | ||
| 2122 | using an inherited keymap. So skip anything we've already | ||
| 2123 | encountered. */ | ||
| 2124 | tem = Fassq (tail, *seen); | ||
| 2125 | if (CONSP (tem) && Fequal (XCONS (tem)->car, keys)) | ||
| 2126 | break; | ||
| 2127 | *seen = Fcons (Fcons (tail, keys), *seen); | ||
| 2128 | } | ||
| 2117 | } | 2129 | } |
| 2118 | 2130 | ||
| 2119 | UNGCPRO; | 2131 | UNGCPRO; |