Mercurial > emacs
changeset 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 | 954251d0fbd1 |
children | 93c9529b2b69 |
files | src/keymap.c |
diffstat | 1 files changed, 50 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/src/keymap.c Mon May 10 00:17:08 1993 +0000 +++ b/src/keymap.c Mon May 10 00:17:31 1993 +0000 @@ -73,7 +73,7 @@ documentation. */ Lisp_Object Vfunction_key_map; -Lisp_Object Qkeymapp, Qkeymap; +Lisp_Object Qkeymapp, Qkeymap, Qnon_ascii; /* A char over 0200 in a key sequence is equivalent to prefixing with this character. */ @@ -1311,6 +1311,28 @@ return build_string (tem); } + +/* Return non-zero if SEQ contains only ASCII characters, perhaps with + a meta bit. */ +static int +ascii_sequence_p (seq) + Lisp_Object seq; +{ + Lisp_Object i; + int len = XINT (Flength (seq)); + + for (XFASTINT (i) = 0; XFASTINT (i) < len; XFASTINT (i)++) + { + Lisp_Object elt = Faref (seq, i); + + if (XTYPE (elt) != Lisp_Int + || (XUINT (elt) & ~CHAR_META) >= 0x80) + return 0; + } + + return 1; +} + /* where-is - finding a command in a set of keymaps. */ @@ -1319,9 +1341,12 @@ If KEYMAP is nil, search only KEYMAP1.\n\ If KEYMAP1 is nil, use the current global map.\n\ \n\ -If optional 4th arg FIRSTONLY is non-nil,\n\ -return a string representing the first key sequence found,\n\ -rather than a list of all possible key sequences.\n\ +If optional 4th arg FIRSTONLY is non-nil, return a string representing\n\ +the first key sequence found, rather than a list of all possible key\n\ +sequences. If FIRSTONLY is t, avoid key sequences which use non-ASCII\n\ +keys and therefore may not be usable on ASCII terminals. If FIRSTONLY\n\ +is the symbol `non-ascii', return the first binding found, no matter\n\ +what its components.\n\ \n\ If optional 5th arg NOINDIRECT is non-nil, don't follow indirections\n\ to other keymaps or slots. This makes it possible to search for an\n\ @@ -1469,13 +1494,28 @@ } /* It is a true unshadowed match. Record it. */ + found = Fcons (sequence, found); - if (!NILP (firstonly)) + /* If firstonly is Qnon_ascii, then we can return the first + binding we find. If firstonly is not Qnon_ascii but not + nil, then we should return the first ascii-only binding + we find. */ + if (EQ (firstonly, Qnon_ascii)) return sequence; - found = Fcons (sequence, found); + else if (! NILP (firstonly) && ascii_sequence_p (sequence)) + return sequence; } } - return Fnreverse (found); + + found = Fnreverse (found); + + /* firstonly may have been t, but we may have gone all the way through + the keymaps without finding an all-ASCII key sequence. So just + return the best we could find. */ + if (! NILP (firstonly)) + return Fcar (found); + + return found; } /* Return a string listing the keys and buttons that run DEFINITION. */ @@ -2039,6 +2079,9 @@ Qkeymapp = intern ("keymapp"); staticpro (&Qkeymapp); + Qnon_ascii = intern ("non-ascii"); + staticpro (&Qnon_ascii); + defsubr (&Skeymapp); defsubr (&Smake_keymap); defsubr (&Smake_sparse_keymap);