diff options
| author | Richard M. Stallman | 1993-03-10 05:24:42 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1993-03-10 05:24:42 +0000 |
| commit | 0b8fc2d4519e687bf3b011e276666c1417826997 (patch) | |
| tree | e42b74630a78b0916de81ae3c6ed08302b3024d5 /src | |
| parent | 6315e7617b69afe2eb1808021f6f8263c6367cb9 (diff) | |
| download | emacs-0b8fc2d4519e687bf3b011e276666c1417826997.tar.gz emacs-0b8fc2d4519e687bf3b011e276666c1417826997.zip | |
(Fdefine_key): Use proper meta-bit to clear.
(access_keymap): Handle ints beyond the ASCII range.
(store_in_keymap): Likewise.
(Faccessible_keymaps): Use meta_modifier.
Use vectors for the key sequences.
(Fwhere_is_internal): Use meta_modifier.
(append_key): Always return a vector.
Diffstat (limited to 'src')
| -rw-r--r-- | src/keymap.c | 56 |
1 files changed, 23 insertions, 33 deletions
diff --git a/src/keymap.c b/src/keymap.c index f088af6a7d6..11a48e2c235 100644 --- a/src/keymap.c +++ b/src/keymap.c | |||
| @@ -266,13 +266,9 @@ access_keymap (map, idx, t_ok) | |||
| 266 | ought to be a symbol. */ | 266 | ought to be a symbol. */ |
| 267 | idx = EVENT_HEAD (idx); | 267 | idx = EVENT_HEAD (idx); |
| 268 | 268 | ||
| 269 | if (XTYPE (idx) == Lisp_Int | ||
| 270 | && (XINT (idx) < 0 || XINT (idx) >= DENSE_TABLE_SIZE)) | ||
| 271 | error ("only ASCII characters may be looked up in keymaps"); | ||
| 272 | |||
| 273 | /* If idx is a symbol, it might have modifiers, which need to | 269 | /* If idx is a symbol, it might have modifiers, which need to |
| 274 | be put in the canonical order. */ | 270 | be put in the canonical order. */ |
| 275 | else if (XTYPE (idx) == Lisp_Symbol) | 271 | if (XTYPE (idx) == Lisp_Symbol) |
| 276 | idx = reorder_modifiers (idx); | 272 | idx = reorder_modifiers (idx); |
| 277 | 273 | ||
| 278 | { | 274 | { |
| @@ -294,7 +290,9 @@ access_keymap (map, idx, t_ok) | |||
| 294 | 290 | ||
| 295 | case Lisp_Vector: | 291 | case Lisp_Vector: |
| 296 | if (XVECTOR (binding)->size == DENSE_TABLE_SIZE | 292 | if (XVECTOR (binding)->size == DENSE_TABLE_SIZE |
| 297 | && XTYPE (idx) == Lisp_Int) | 293 | && XTYPE (idx) == Lisp_Int |
| 294 | && XINT (idx) >= 0 | ||
| 295 | && XINT (idx) < DENSE_TABLE_SIZE) | ||
| 298 | return XVECTOR (binding)->contents[XINT (idx)]; | 296 | return XVECTOR (binding)->contents[XINT (idx)]; |
| 299 | break; | 297 | break; |
| 300 | } | 298 | } |
| @@ -365,13 +363,9 @@ store_in_keymap (keymap, idx, def) | |||
| 365 | ought to be a symbol. */ | 363 | ought to be a symbol. */ |
| 366 | idx = EVENT_HEAD (idx); | 364 | idx = EVENT_HEAD (idx); |
| 367 | 365 | ||
| 368 | if (XTYPE (idx) == Lisp_Int | ||
| 369 | && (XINT (idx) < 0 || XINT (idx) >= DENSE_TABLE_SIZE)) | ||
| 370 | error ("only ASCII characters may be used as keymap indices"); | ||
| 371 | |||
| 372 | /* If idx is a symbol, it might have modifiers, which need to | 366 | /* If idx is a symbol, it might have modifiers, which need to |
| 373 | be put in the canonical order. */ | 367 | be put in the canonical order. */ |
| 374 | else if (XTYPE (idx) == Lisp_Symbol) | 368 | if (XTYPE (idx) == Lisp_Symbol) |
| 375 | idx = reorder_modifiers (idx); | 369 | idx = reorder_modifiers (idx); |
| 376 | 370 | ||
| 377 | 371 | ||
| @@ -396,7 +390,8 @@ store_in_keymap (keymap, idx, def) | |||
| 396 | case Lisp_Vector: | 390 | case Lisp_Vector: |
| 397 | if (XVECTOR (elt)->size != DENSE_TABLE_SIZE) | 391 | if (XVECTOR (elt)->size != DENSE_TABLE_SIZE) |
| 398 | break; | 392 | break; |
| 399 | if (XTYPE (idx) == Lisp_Int) | 393 | if (XTYPE (idx) == Lisp_Int |
| 394 | && XINT (idx) >= 0 && XINT (idx) < DENSE_TABLE_SIZE) | ||
| 400 | { | 395 | { |
| 401 | XVECTOR (elt)->contents[XFASTINT (idx)] = def; | 396 | XVECTOR (elt)->contents[XFASTINT (idx)] = def; |
| 402 | return def; | 397 | return def; |
| @@ -543,7 +538,7 @@ the front of KEYMAP.") | |||
| 543 | else | 538 | else |
| 544 | { | 539 | { |
| 545 | if (XTYPE (c) == Lisp_Int) | 540 | if (XTYPE (c) == Lisp_Int) |
| 546 | XSETINT (c, XINT (c) & 0177); | 541 | XSETINT (c, XINT (c) & ~meta_bit); |
| 547 | 542 | ||
| 548 | metized = 0; | 543 | metized = 0; |
| 549 | idx++; | 544 | idx++; |
| @@ -652,9 +647,8 @@ recognize the default bindings, just as `read-key-sequence' does.") | |||
| 652 | } | 647 | } |
| 653 | } | 648 | } |
| 654 | 649 | ||
| 655 | /* Append a key to the end of a key sequence. If key_sequence is a | 650 | /* Append a key to the end of a key sequence. We always make a vector. */ |
| 656 | string and key is a character, the result will be another string; | 651 | |
| 657 | otherwise, it will be a vector. */ | ||
| 658 | Lisp_Object | 652 | Lisp_Object |
| 659 | append_key (key_sequence, key) | 653 | append_key (key_sequence, key) |
| 660 | Lisp_Object key_sequence, key; | 654 | Lisp_Object key_sequence, key; |
| @@ -663,17 +657,8 @@ append_key (key_sequence, key) | |||
| 663 | 657 | ||
| 664 | args[0] = key_sequence; | 658 | args[0] = key_sequence; |
| 665 | 659 | ||
| 666 | if (XTYPE (key_sequence) == Lisp_String | 660 | args[1] = Fcons (key, Qnil); |
| 667 | && XTYPE (key) == Lisp_Int) | 661 | return Fvconcat (2, args); |
| 668 | { | ||
| 669 | args[1] = Fchar_to_string (key); | ||
| 670 | return Fconcat (2, args); | ||
| 671 | } | ||
| 672 | else | ||
| 673 | { | ||
| 674 | args[1] = Fcons (key, Qnil); | ||
| 675 | return Fvconcat (2, args); | ||
| 676 | } | ||
| 677 | } | 662 | } |
| 678 | 663 | ||
| 679 | 664 | ||
| @@ -1002,7 +987,9 @@ so that the KEYS increase in length. The first element is (\"\" . KEYMAP).") | |||
| 1002 | { | 987 | { |
| 1003 | Lisp_Object maps, tail; | 988 | Lisp_Object maps, tail; |
| 1004 | 989 | ||
| 1005 | maps = Fcons (Fcons (build_string (""), get_keymap (startmap)), Qnil); | 990 | maps = Fcons (Fcons (Fmake_vector (make_number (0), Qnil), |
| 991 | get_keymap (startmap)), | ||
| 992 | Qnil); | ||
| 1006 | 993 | ||
| 1007 | /* For each map in the list maps, | 994 | /* For each map in the list maps, |
| 1008 | look at any other maps it points to, | 995 | look at any other maps it points to, |
| @@ -1054,14 +1041,16 @@ so that the KEYS increase in length. The first element is (\"\" . KEYMAP).") | |||
| 1054 | keymap table. */ | 1041 | keymap table. */ |
| 1055 | if (is_metized) | 1042 | if (is_metized) |
| 1056 | { | 1043 | { |
| 1044 | int meta_bit = meta_modifier; | ||
| 1057 | tem = Fcopy_sequence (thisseq); | 1045 | tem = Fcopy_sequence (thisseq); |
| 1058 | Faset (tem, last, make_number (i | 0200)); | 1046 | |
| 1047 | Faset (tem, last, make_number (i | meta_bit)); | ||
| 1059 | 1048 | ||
| 1060 | /* This new sequence is the same length as | 1049 | /* This new sequence is the same length as |
| 1061 | thisseq, so stick it in the list right | 1050 | thisseq, so stick it in the list right |
| 1062 | after this one. */ | 1051 | after this one. */ |
| 1063 | XCONS (tail)->cdr = | 1052 | XCONS (tail)->cdr |
| 1064 | Fcons (Fcons (tem, cmd), XCONS (tail)->cdr); | 1053 | = Fcons (Fcons (tem, cmd), XCONS (tail)->cdr); |
| 1065 | } | 1054 | } |
| 1066 | else | 1055 | else |
| 1067 | { | 1056 | { |
| @@ -1095,7 +1084,8 @@ so that the KEYS increase in length. The first element is (\"\" . KEYMAP).") | |||
| 1095 | if (is_metized && XTYPE (elt) == Lisp_Int) | 1084 | if (is_metized && XTYPE (elt) == Lisp_Int) |
| 1096 | { | 1085 | { |
| 1097 | tem = Fcopy_sequence (thisseq); | 1086 | tem = Fcopy_sequence (thisseq); |
| 1098 | Faset (tem, last, make_number (XINT (elt) | 0200)); | 1087 | Faset (tem, last, |
| 1088 | make_number (XINT (elt) | meta_modifier)); | ||
| 1099 | 1089 | ||
| 1100 | /* This new sequence is the same length as | 1090 | /* This new sequence is the same length as |
| 1101 | thisseq, so stick it in the list right | 1091 | thisseq, so stick it in the list right |
| @@ -1438,7 +1428,7 @@ indirect definition itself.") | |||
| 1438 | if (XTYPE (key) == Lisp_Int && last_is_meta) | 1428 | if (XTYPE (key) == Lisp_Int && last_is_meta) |
| 1439 | { | 1429 | { |
| 1440 | sequence = Fcopy_sequence (this); | 1430 | sequence = Fcopy_sequence (this); |
| 1441 | Faset (sequence, last, make_number (XINT (key) | 0200)); | 1431 | Faset (sequence, last, make_number (XINT (key) | meta_modifier)); |
| 1442 | } | 1432 | } |
| 1443 | else | 1433 | else |
| 1444 | sequence = append_key (this, key); | 1434 | sequence = append_key (this, key); |