Mercurial > emacs
comparison src/keymap.c @ 6976:4d540eeb2dd5
(describe_map_tree, describe_map): Skip keymaps we've seen before.
| author | Karl Heuer <kwzh@gnu.org> |
|---|---|
| date | Wed, 20 Apr 1994 04:22:24 +0000 |
| parents | ab22b527d380 |
| children | b96377c0e49d |
comparison
equal
deleted
inserted
replaced
| 6975:b7411e378b65 | 6976:4d540eeb2dd5 |
|---|---|
| 1876 Lisp_Object startmap, shadow, prefix; | 1876 Lisp_Object startmap, shadow, prefix; |
| 1877 int partial; | 1877 int partial; |
| 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 = "\ |
| 1886 key binding\n\ | 1886 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 { |
| 1894 Lisp_Object list; | 1895 Lisp_Object list; |
| 1895 | 1896 |
| 1965 | 1966 |
| 1966 if (!NILP (shmap)) | 1967 if (!NILP (shmap)) |
| 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 } |
| 1974 | 1976 |
| 1975 if (something) | 1977 if (something) |
| 2022 return Qnil; | 2024 return Qnil; |
| 2023 } | 2025 } |
| 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; |
| 2039 Lisp_Object tem; | 2042 Lisp_Object tem; |
| 2040 Lisp_Object suppress; | 2043 Lisp_Object suppress; |
| 2042 int first = 1; | 2045 int first = 1; |
| 2043 struct gcpro gcpro1, gcpro2, gcpro3; | 2046 struct gcpro gcpro1, gcpro2, gcpro3; |
| 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 (" ")); |
| 2051 } | 2053 } |
| 2052 else | 2054 else |
| 2061 kludge = Fmake_vector (make_number (1), Qnil); | 2063 kludge = Fmake_vector (make_number (1), Qnil); |
| 2062 definition = Qnil; | 2064 definition = Qnil; |
| 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; |
| 2080 if (XTYPE (definition) == Lisp_Symbol && partial) | 2082 if (XTYPE (definition) == Lisp_Symbol && partial) |
| 2081 { | 2083 { |
| 2111 | 2113 |
| 2112 /* Print a description of the definition of this character. | 2114 /* Print a description of the definition of this character. |
| 2113 elt_describer will take care of spacing out far enough | 2115 elt_describer will take care of spacing out far enough |
| 2114 for alignment purposes. */ | 2116 for alignment purposes. */ |
| 2115 (*elt_describer) (definition); | 2117 (*elt_describer) (definition); |
| 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); | |
| 2116 } | 2128 } |
| 2117 } | 2129 } |
| 2118 | 2130 |
| 2119 UNGCPRO; | 2131 UNGCPRO; |
| 2120 } | 2132 } |
