Mercurial > emacs
comparison src/keymap.c @ 2727:b8911c8b9700
* keymap.c (Fwhere_is_internal): If FIRSTONLY is non-nil, avoid
returning a non-ascii key sequence unless FIRSTONLY is the symbol
`non-ascii'.
author | Jim Blandy <jimb@redhat.com> |
---|---|
date | Mon, 10 May 1993 00:17:31 +0000 |
parents | 90485f37bfc3 |
children | 93eda5bbc4df |
comparison
equal
deleted
inserted
replaced
2726:954251d0fbd1 | 2727:b8911c8b9700 |
---|---|
71 /* Keymap mapping ASCII function key sequences onto their preferred forms. | 71 /* Keymap mapping ASCII function key sequences onto their preferred forms. |
72 Initialized by the terminal-specific lisp files. See DEFVAR for more | 72 Initialized by the terminal-specific lisp files. See DEFVAR for more |
73 documentation. */ | 73 documentation. */ |
74 Lisp_Object Vfunction_key_map; | 74 Lisp_Object Vfunction_key_map; |
75 | 75 |
76 Lisp_Object Qkeymapp, Qkeymap; | 76 Lisp_Object Qkeymapp, Qkeymap, Qnon_ascii; |
77 | 77 |
78 /* A char over 0200 in a key sequence | 78 /* A char over 0200 in a key sequence |
79 is equivalent to prefixing with this character. */ | 79 is equivalent to prefixing with this character. */ |
80 | 80 |
81 extern Lisp_Object meta_prefix_char; | 81 extern Lisp_Object meta_prefix_char; |
1309 | 1309 |
1310 *push_text_char_description (XINT (chr) & 0377, tem) = 0; | 1310 *push_text_char_description (XINT (chr) & 0377, tem) = 0; |
1311 | 1311 |
1312 return build_string (tem); | 1312 return build_string (tem); |
1313 } | 1313 } |
1314 | |
1315 /* Return non-zero if SEQ contains only ASCII characters, perhaps with | |
1316 a meta bit. */ | |
1317 static int | |
1318 ascii_sequence_p (seq) | |
1319 Lisp_Object seq; | |
1320 { | |
1321 Lisp_Object i; | |
1322 int len = XINT (Flength (seq)); | |
1323 | |
1324 for (XFASTINT (i) = 0; XFASTINT (i) < len; XFASTINT (i)++) | |
1325 { | |
1326 Lisp_Object elt = Faref (seq, i); | |
1327 | |
1328 if (XTYPE (elt) != Lisp_Int | |
1329 || (XUINT (elt) & ~CHAR_META) >= 0x80) | |
1330 return 0; | |
1331 } | |
1332 | |
1333 return 1; | |
1334 } | |
1335 | |
1314 | 1336 |
1315 /* where-is - finding a command in a set of keymaps. */ | 1337 /* where-is - finding a command in a set of keymaps. */ |
1316 | 1338 |
1317 DEFUN ("where-is-internal", Fwhere_is_internal, Swhere_is_internal, 1, 5, 0, | 1339 DEFUN ("where-is-internal", Fwhere_is_internal, Swhere_is_internal, 1, 5, 0, |
1318 "Return list of keys that invoke DEFINITION in KEYMAP or KEYMAP1.\n\ | 1340 "Return list of keys that invoke DEFINITION in KEYMAP or KEYMAP1.\n\ |
1319 If KEYMAP is nil, search only KEYMAP1.\n\ | 1341 If KEYMAP is nil, search only KEYMAP1.\n\ |
1320 If KEYMAP1 is nil, use the current global map.\n\ | 1342 If KEYMAP1 is nil, use the current global map.\n\ |
1321 \n\ | 1343 \n\ |
1322 If optional 4th arg FIRSTONLY is non-nil,\n\ | 1344 If optional 4th arg FIRSTONLY is non-nil, return a string representing\n\ |
1323 return a string representing the first key sequence found,\n\ | 1345 the first key sequence found, rather than a list of all possible key\n\ |
1324 rather than a list of all possible key sequences.\n\ | 1346 sequences. If FIRSTONLY is t, avoid key sequences which use non-ASCII\n\ |
1347 keys and therefore may not be usable on ASCII terminals. If FIRSTONLY\n\ | |
1348 is the symbol `non-ascii', return the first binding found, no matter\n\ | |
1349 what its components.\n\ | |
1325 \n\ | 1350 \n\ |
1326 If optional 5th arg NOINDIRECT is non-nil, don't follow indirections\n\ | 1351 If optional 5th arg NOINDIRECT is non-nil, don't follow indirections\n\ |
1327 to other keymaps or slots. This makes it possible to search for an\n\ | 1352 to other keymaps or slots. This makes it possible to search for an\n\ |
1328 indirect definition itself.") | 1353 indirect definition itself.") |
1329 (definition, local_keymap, global_keymap, firstonly, noindirect) | 1354 (definition, local_keymap, global_keymap, firstonly, noindirect) |
1467 continue; | 1492 continue; |
1468 } | 1493 } |
1469 } | 1494 } |
1470 | 1495 |
1471 /* It is a true unshadowed match. Record it. */ | 1496 /* It is a true unshadowed match. Record it. */ |
1472 | 1497 found = Fcons (sequence, found); |
1473 if (!NILP (firstonly)) | 1498 |
1499 /* If firstonly is Qnon_ascii, then we can return the first | |
1500 binding we find. If firstonly is not Qnon_ascii but not | |
1501 nil, then we should return the first ascii-only binding | |
1502 we find. */ | |
1503 if (EQ (firstonly, Qnon_ascii)) | |
1474 return sequence; | 1504 return sequence; |
1475 found = Fcons (sequence, found); | 1505 else if (! NILP (firstonly) && ascii_sequence_p (sequence)) |
1476 } | 1506 return sequence; |
1477 } | 1507 } |
1478 return Fnreverse (found); | 1508 } |
1509 | |
1510 found = Fnreverse (found); | |
1511 | |
1512 /* firstonly may have been t, but we may have gone all the way through | |
1513 the keymaps without finding an all-ASCII key sequence. So just | |
1514 return the best we could find. */ | |
1515 if (! NILP (firstonly)) | |
1516 return Fcar (found); | |
1517 | |
1518 return found; | |
1479 } | 1519 } |
1480 | 1520 |
1481 /* Return a string listing the keys and buttons that run DEFINITION. */ | 1521 /* Return a string listing the keys and buttons that run DEFINITION. */ |
1482 | 1522 |
1483 static Lisp_Object | 1523 static Lisp_Object |
2036 Qkey_description = intern ("key-description"); | 2076 Qkey_description = intern ("key-description"); |
2037 staticpro (&Qkey_description); | 2077 staticpro (&Qkey_description); |
2038 | 2078 |
2039 Qkeymapp = intern ("keymapp"); | 2079 Qkeymapp = intern ("keymapp"); |
2040 staticpro (&Qkeymapp); | 2080 staticpro (&Qkeymapp); |
2081 | |
2082 Qnon_ascii = intern ("non-ascii"); | |
2083 staticpro (&Qnon_ascii); | |
2041 | 2084 |
2042 defsubr (&Skeymapp); | 2085 defsubr (&Skeymapp); |
2043 defsubr (&Smake_keymap); | 2086 defsubr (&Smake_keymap); |
2044 defsubr (&Smake_sparse_keymap); | 2087 defsubr (&Smake_sparse_keymap); |
2045 defsubr (&Scopy_keymap); | 2088 defsubr (&Scopy_keymap); |