aboutsummaryrefslogtreecommitdiffstats
path: root/src/keymap.c
diff options
context:
space:
mode:
authorJim Blandy1993-05-10 00:17:31 +0000
committerJim Blandy1993-05-10 00:17:31 +0000
commit2fc6697323fd6cc950d808347b89ac3483d311e1 (patch)
treef2c8dc5334dd283a8aa6350dfc0feca319078c79 /src/keymap.c
parentad163903cc2d44a2033312d0685031d54aafffb2 (diff)
downloademacs-2fc6697323fd6cc950d808347b89ac3483d311e1.tar.gz
emacs-2fc6697323fd6cc950d808347b89ac3483d311e1.zip
* keymap.c (Fwhere_is_internal): If FIRSTONLY is non-nil, avoid
returning a non-ascii key sequence unless FIRSTONLY is the symbol `non-ascii'.
Diffstat (limited to 'src/keymap.c')
-rw-r--r--src/keymap.c57
1 files changed, 50 insertions, 7 deletions
diff --git a/src/keymap.c b/src/keymap.c
index ea7e4aceca3..096a6ca1e4a 100644
--- a/src/keymap.c
+++ b/src/keymap.c
@@ -73,7 +73,7 @@ Lisp_Object Vminor_mode_map_alist;
73 documentation. */ 73 documentation. */
74Lisp_Object Vfunction_key_map; 74Lisp_Object Vfunction_key_map;
75 75
76Lisp_Object Qkeymapp, Qkeymap; 76Lisp_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. */
@@ -1311,6 +1311,28 @@ Control characters turn into \"^char\", etc.")
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. */
1317static int
1318ascii_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
@@ -1319,9 +1341,12 @@ DEFUN ("where-is-internal", Fwhere_is_internal, Swhere_is_internal, 1, 5, 0,
1319If KEYMAP is nil, search only KEYMAP1.\n\ 1341If KEYMAP is nil, search only KEYMAP1.\n\
1320If KEYMAP1 is nil, use the current global map.\n\ 1342If KEYMAP1 is nil, use the current global map.\n\
1321\n\ 1343\n\
1322If optional 4th arg FIRSTONLY is non-nil,\n\ 1344If optional 4th arg FIRSTONLY is non-nil, return a string representing\n\
1323return a string representing the first key sequence found,\n\ 1345the first key sequence found, rather than a list of all possible key\n\
1324rather than a list of all possible key sequences.\n\ 1346sequences. If FIRSTONLY is t, avoid key sequences which use non-ASCII\n\
1347keys and therefore may not be usable on ASCII terminals. If FIRSTONLY\n\
1348is the symbol `non-ascii', return the first binding found, no matter\n\
1349what its components.\n\
1325\n\ 1350\n\
1326If optional 5th arg NOINDIRECT is non-nil, don't follow indirections\n\ 1351If optional 5th arg NOINDIRECT is non-nil, don't follow indirections\n\
1327to other keymaps or slots. This makes it possible to search for an\n\ 1352to other keymaps or slots. This makes it possible to search for an\n\
@@ -1469,13 +1494,28 @@ indirect definition itself.")
1469 } 1494 }
1470 1495
1471 /* It is a true unshadowed match. Record it. */ 1496 /* It is a true unshadowed match. Record it. */
1497 found = Fcons (sequence, found);
1472 1498
1473 if (!NILP (firstonly)) 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))
1504 return sequence;
1505 else if (! NILP (firstonly) && ascii_sequence_p (sequence))
1474 return sequence; 1506 return sequence;
1475 found = Fcons (sequence, found);
1476 } 1507 }
1477 } 1508 }
1478 return Fnreverse (found); 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. */
@@ -2039,6 +2079,9 @@ key, typing `ESC O P x' would return [pf1 x].");
2039 Qkeymapp = intern ("keymapp"); 2079 Qkeymapp = intern ("keymapp");
2040 staticpro (&Qkeymapp); 2080 staticpro (&Qkeymapp);
2041 2081
2082 Qnon_ascii = intern ("non-ascii");
2083 staticpro (&Qnon_ascii);
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);