comparison src/keymap.c @ 11973:4e0f3e3b4cc7

(describe_vector): New arg entire_map. Don't show bindings shadowed earlier on in the same map. (Fdescribe_vector, describe_map): Pass new arg.
author Karl Heuer <kwzh@gnu.org>
date Mon, 29 May 1995 06:07:34 +0000
parents 4744a12fa933
children 43b030e896eb
comparison
equal deleted inserted replaced
11972:be9d727c58c2 11973:4e0f3e3b4cc7
2106 { 2106 {
2107 QUIT; 2107 QUIT;
2108 2108
2109 if (VECTORP (XCONS (tail)->car)) 2109 if (VECTORP (XCONS (tail)->car))
2110 describe_vector (XCONS (tail)->car, 2110 describe_vector (XCONS (tail)->car,
2111 elt_prefix, elt_describer, partial, shadow); 2111 elt_prefix, elt_describer, partial, shadow, map);
2112 else if (CONSP (XCONS (tail)->car)) 2112 else if (CONSP (XCONS (tail)->car))
2113 { 2113 {
2114 event = XCONS (XCONS (tail)->car)->car; 2114 event = XCONS (XCONS (tail)->car)->car;
2115 2115
2116 /* Ignore bindings whose "keys" are not really valid events. 2116 /* Ignore bindings whose "keys" are not really valid events.
2191 { 2191 {
2192 int count = specpdl_ptr - specpdl; 2192 int count = specpdl_ptr - specpdl;
2193 2193
2194 specbind (Qstandard_output, Fcurrent_buffer ()); 2194 specbind (Qstandard_output, Fcurrent_buffer ());
2195 CHECK_VECTOR (vector, 0); 2195 CHECK_VECTOR (vector, 0);
2196 describe_vector (vector, Qnil, describe_vector_princ, 0, Qnil); 2196 describe_vector (vector, Qnil, describe_vector_princ, 0, Qnil, Qnil);
2197 2197
2198 return unbind_to (count, Qnil); 2198 return unbind_to (count, Qnil);
2199 } 2199 }
2200 2200
2201 describe_vector (vector, elt_prefix, elt_describer, partial, shadow) 2201 describe_vector (vector, elt_prefix, elt_describer,
2202 partial, shadow, entire_map)
2202 register Lisp_Object vector; 2203 register Lisp_Object vector;
2203 Lisp_Object elt_prefix; 2204 Lisp_Object elt_prefix;
2204 int (*elt_describer) (); 2205 int (*elt_describer) ();
2205 int partial; 2206 int partial;
2206 Lisp_Object shadow; 2207 Lisp_Object shadow;
2208 Lisp_Object entire_map;
2207 { 2209 {
2208 Lisp_Object this; 2210 Lisp_Object this;
2209 Lisp_Object dummy; 2211 Lisp_Object dummy;
2210 Lisp_Object tem1, tem2; 2212 Lisp_Object definition;
2213 Lisp_Object tem2;
2211 register int i; 2214 register int i;
2212 Lisp_Object suppress; 2215 Lisp_Object suppress;
2213 Lisp_Object kludge; 2216 Lisp_Object kludge;
2214 int first = 1; 2217 int first = 1;
2215 struct gcpro gcpro1, gcpro2, gcpro3; 2218 struct gcpro gcpro1, gcpro2, gcpro3;
2216 2219
2217 tem1 = Qnil; 2220 definition = Qnil;
2218 2221
2219 /* This vector gets used to present single keys to Flookup_key. Since 2222 /* This vector gets used to present single keys to Flookup_key. Since
2220 that is done once per vector element, we don't want to cons up a 2223 that is done once per vector element, we don't want to cons up a
2221 fresh vector every time. */ 2224 fresh vector every time. */
2222 kludge = Fmake_vector (make_number (1), Qnil); 2225 kludge = Fmake_vector (make_number (1), Qnil);
2223 GCPRO3 (elt_prefix, tem1, kludge); 2226 GCPRO3 (elt_prefix, definition, kludge);
2224 2227
2225 if (partial) 2228 if (partial)
2226 suppress = intern ("suppress-keymap"); 2229 suppress = intern ("suppress-keymap");
2227 2230
2228 for (i = 0; i < XVECTOR (vector)->size; i++) 2231 for (i = 0; i < XVECTOR (vector)->size; i++)
2229 { 2232 {
2230 QUIT; 2233 QUIT;
2231 tem1 = get_keyelt (XVECTOR (vector)->contents[i], 0); 2234 definition = get_keyelt (XVECTOR (vector)->contents[i], 0);
2232 2235
2233 if (NILP (tem1)) continue; 2236 if (NILP (definition)) continue;
2234 2237
2235 /* Don't mention suppressed commands. */ 2238 /* Don't mention suppressed commands. */
2236 if (SYMBOLP (tem1) && partial) 2239 if (SYMBOLP (definition) && partial)
2237 { 2240 {
2238 this = Fget (tem1, suppress); 2241 this = Fget (definition, suppress);
2239 if (!NILP (this)) 2242 if (!NILP (this))
2240 continue; 2243 continue;
2241 } 2244 }
2242 2245
2243 /* If this command in this map is shadowed by some other map, 2246 /* If this binding is shadowed by some other map, ignore it. */
2244 ignore it. */
2245 if (!NILP (shadow)) 2247 if (!NILP (shadow))
2246 { 2248 {
2247 Lisp_Object tem; 2249 Lisp_Object tem;
2248 2250
2249 XVECTOR (kludge)->contents[0] = make_number (i); 2251 XVECTOR (kludge)->contents[0] = make_number (i);
2250 tem = shadow_lookup (shadow, kludge, Qt); 2252 tem = shadow_lookup (shadow, kludge, Qt);
2251 2253
2252 if (!NILP (tem)) continue; 2254 if (!NILP (tem)) continue;
2253 } 2255 }
2254 2256
2257 /* Ignore this definition if it is shadowed by an earlier
2258 one in the same keymap. */
2259 if (!NILP (entire_map))
2260 {
2261 Lisp_Object tem;
2262
2263 XVECTOR (kludge)->contents[0] = make_number (i);
2264 tem = Flookup_key (entire_map, kludge, Qt);
2265
2266 if (! EQ (tem, definition))
2267 continue;
2268 }
2269
2255 if (first) 2270 if (first)
2256 { 2271 {
2257 insert ("\n", 1); 2272 insert ("\n", 1);
2258 first = 0; 2273 first = 0;
2259 } 2274 }
2270 insert1 (this); 2285 insert1 (this);
2271 2286
2272 /* Find all consecutive characters that have the same definition. */ 2287 /* Find all consecutive characters that have the same definition. */
2273 while (i + 1 < XVECTOR (vector)->size 2288 while (i + 1 < XVECTOR (vector)->size
2274 && (tem2 = get_keyelt (XVECTOR (vector)->contents[i+1], 0), 2289 && (tem2 = get_keyelt (XVECTOR (vector)->contents[i+1], 0),
2275 EQ (tem2, tem1))) 2290 EQ (tem2, definition)))
2276 i++; 2291 i++;
2277 2292
2278 /* If we have a range of more than one character, 2293 /* If we have a range of more than one character,
2279 print where the range reaches to. */ 2294 print where the range reaches to. */
2280 2295
2289 } 2304 }
2290 2305
2291 /* Print a description of the definition of this character. 2306 /* Print a description of the definition of this character.
2292 elt_describer will take care of spacing out far enough 2307 elt_describer will take care of spacing out far enough
2293 for alignment purposes. */ 2308 for alignment purposes. */
2294 (*elt_describer) (tem1); 2309 (*elt_describer) (definition);
2295 } 2310 }
2296 2311
2297 UNGCPRO; 2312 UNGCPRO;
2298 } 2313 }
2299 2314