diff options
| author | Stefan Monnier | 2007-11-28 04:45:32 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2007-11-28 04:45:32 +0000 |
| commit | 21ec2c436582ae61ed6c4e8a1549d2924aa3b528 (patch) | |
| tree | 72c301a8b0d3ff8aa4e1cccca0fc3d5b112571d5 /src | |
| parent | 488f4498d44840182a299b50d933522d6b190859 (diff) | |
| download | emacs-21ec2c436582ae61ed6c4e8a1549d2924aa3b528.tar.gz emacs-21ec2c436582ae61ed6c4e8a1549d2924aa3b528.zip | |
(KEY_TO_CHAR): New macro.
(parse_modifiers, apply_modifiers): Accept integer arguments.
(read_key_sequence): Use them to unify the "shift->unshift" mapping
for chars and symbol keys.
After doing such remapping, apply function-key-map again.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 8 | ||||
| -rw-r--r-- | src/keyboard.c | 89 |
2 files changed, 49 insertions, 48 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index ff1d631cfd2..508b8e30903 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,11 @@ | |||
| 1 | 2007-11-28 Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 2 | |||
| 3 | * keyboard.c (KEY_TO_CHAR): New macro. | ||
| 4 | (parse_modifiers, apply_modifiers): Accept integer arguments. | ||
| 5 | (read_key_sequence): Use them to unify the "shift->unshift" mapping | ||
| 6 | for chars and symbol keys. | ||
| 7 | After doing such remapping, apply function-key-map again. | ||
| 8 | |||
| 1 | 2007-11-27 Dan Nicolaescu <dann@ics.uci.edu> | 9 | 2007-11-27 Dan Nicolaescu <dann@ics.uci.edu> |
| 2 | 10 | ||
| 3 | * Makefile.in (SOME_MACHINE_LISP): Remove VMS files, they are not | 11 | * Makefile.in (SOME_MACHINE_LISP): Remove VMS files, they are not |
diff --git a/src/keyboard.c b/src/keyboard.c index 527a4151ba9..3a52afc0cd0 100644 --- a/src/keyboard.c +++ b/src/keyboard.c | |||
| @@ -6505,12 +6505,21 @@ lispy_modifier_list (modifiers) | |||
| 6505 | SYMBOL's Qevent_symbol_element_mask property, and maintains the | 6505 | SYMBOL's Qevent_symbol_element_mask property, and maintains the |
| 6506 | Qevent_symbol_elements property. */ | 6506 | Qevent_symbol_elements property. */ |
| 6507 | 6507 | ||
| 6508 | #define KEY_TO_CHAR(k) (XINT (k) & ((1 << CHARACTERBITS) - 1)) | ||
| 6509 | |||
| 6508 | Lisp_Object | 6510 | Lisp_Object |
| 6509 | parse_modifiers (symbol) | 6511 | parse_modifiers (symbol) |
| 6510 | Lisp_Object symbol; | 6512 | Lisp_Object symbol; |
| 6511 | { | 6513 | { |
| 6512 | Lisp_Object elements; | 6514 | Lisp_Object elements; |
| 6513 | 6515 | ||
| 6516 | if (INTEGERP (symbol)) | ||
| 6517 | return (Fcons (make_number (KEY_TO_CHAR (symbol)), | ||
| 6518 | Fcons (make_number (XINT (symbol) & CHAR_MODIFIER_MASK), | ||
| 6519 | Qnil))); | ||
| 6520 | else if (!SYMBOLP (symbol)) | ||
| 6521 | return Qnil; | ||
| 6522 | |||
| 6514 | elements = Fget (symbol, Qevent_symbol_element_mask); | 6523 | elements = Fget (symbol, Qevent_symbol_element_mask); |
| 6515 | if (CONSP (elements)) | 6524 | if (CONSP (elements)) |
| 6516 | return elements; | 6525 | return elements; |
| @@ -6578,6 +6587,9 @@ apply_modifiers (modifiers, base) | |||
| 6578 | /* Mask out upper bits. We don't know where this value's been. */ | 6587 | /* Mask out upper bits. We don't know where this value's been. */ |
| 6579 | modifiers &= INTMASK; | 6588 | modifiers &= INTMASK; |
| 6580 | 6589 | ||
| 6590 | if (INTEGERP (base)) | ||
| 6591 | return make_number (XINT (base) & modifiers); | ||
| 6592 | |||
| 6581 | /* The click modifier never figures into cache indices. */ | 6593 | /* The click modifier never figures into cache indices. */ |
| 6582 | cache = Fget (base, Qmodifier_cache); | 6594 | cache = Fget (base, Qmodifier_cache); |
| 6583 | XSETFASTINT (index, (modifiers & ~click_modifier)); | 6595 | XSETFASTINT (index, (modifiers & ~click_modifier)); |
| @@ -10083,66 +10095,47 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last, | |||
| 10083 | 10095 | ||
| 10084 | /* If KEY is not defined in any of the keymaps, | 10096 | /* If KEY is not defined in any of the keymaps, |
| 10085 | and cannot be part of a function key or translation, | 10097 | and cannot be part of a function key or translation, |
| 10086 | and is an upper case letter | 10098 | and is an upper case letter or shifted key, |
| 10087 | use the corresponding lower-case letter instead. */ | 10099 | use the corresponding lower-case/unshifted key instead. */ |
| 10088 | if (first_binding >= nmaps | 10100 | if (first_binding >= nmaps |
| 10089 | && /* indec.start >= t && fkey.start >= t && */ keytran.start >= t | 10101 | && /* indec.start >= t && fkey.start >= t && */ keytran.start >= t) |
| 10090 | && INTEGERP (key) | 10102 | { |
| 10091 | && ((((XINT (key) & 0x3ffff) | 10103 | Lisp_Object breakdown = parse_modifiers (key); |
| 10092 | < XCHAR_TABLE (current_buffer->downcase_table)->size) | 10104 | int modifiers |
| 10093 | && UPPERCASEP (XINT (key) & 0x3ffff)) | 10105 | = CONSP (breakdown) ? (XINT (XCAR (XCDR (breakdown)))) : 0; |
| 10094 | || (XINT (key) & shift_modifier))) | 10106 | |
| 10095 | { | 10107 | if (modifiers & shift_modifier |
| 10096 | Lisp_Object new_key; | 10108 | /* Treat uppercase keys as shifted. */ |
| 10097 | 10109 | || (INTEGERP (key) | |
| 10098 | original_uppercase = key; | 10110 | & (KEY_TO_CHAR (key) |
| 10099 | original_uppercase_position = t - 1; | 10111 | < XCHAR_TABLE (current_buffer->downcase_table)->size) |
| 10100 | 10112 | && UPPERCASEP (KEY_TO_CHAR (key)))) | |
| 10101 | if (XINT (key) & shift_modifier) | ||
| 10102 | XSETINT (new_key, XINT (key) & ~shift_modifier); | ||
| 10103 | else | ||
| 10104 | XSETINT (new_key, (DOWNCASE (XINT (key) & 0x3ffff) | ||
| 10105 | | (XINT (key) & ~0x3ffff))); | ||
| 10106 | |||
| 10107 | /* We have to do this unconditionally, regardless of whether | ||
| 10108 | the lower-case char is defined in the keymaps, because they | ||
| 10109 | might get translated through function-key-map. */ | ||
| 10110 | keybuf[t - 1] = new_key; | ||
| 10111 | mock_input = max (t, mock_input); | ||
| 10112 | |||
| 10113 | goto replay_sequence; | ||
| 10114 | } | ||
| 10115 | /* If KEY is not defined in any of the keymaps, | ||
| 10116 | and cannot be part of a function key or translation, | ||
| 10117 | and is a shifted function key, | ||
| 10118 | use the corresponding unshifted function key instead. */ | ||
| 10119 | if (first_binding >= nmaps | ||
| 10120 | && /* indec.start >= t && fkey.start >= t && */ keytran.start >= t | ||
| 10121 | && SYMBOLP (key)) | ||
| 10122 | { | ||
| 10123 | Lisp_Object breakdown; | ||
| 10124 | int modifiers; | ||
| 10125 | |||
| 10126 | breakdown = parse_modifiers (key); | ||
| 10127 | modifiers = XINT (XCAR (XCDR (breakdown))); | ||
| 10128 | if (modifiers & shift_modifier) | ||
| 10129 | { | 10113 | { |
| 10130 | Lisp_Object new_key; | 10114 | Lisp_Object new_key |
| 10115 | = (modifiers & shift_modifier | ||
| 10116 | ? apply_modifiers (modifiers & ~shift_modifier, | ||
| 10117 | XCAR (breakdown)) | ||
| 10118 | : make_number (DOWNCASE (KEY_TO_CHAR (key)) | modifiers)); | ||
| 10131 | 10119 | ||
| 10132 | original_uppercase = key; | 10120 | original_uppercase = key; |
| 10133 | original_uppercase_position = t - 1; | 10121 | original_uppercase_position = t - 1; |
| 10134 | 10122 | ||
| 10135 | modifiers &= ~shift_modifier; | 10123 | /* We have to do this unconditionally, regardless of whether |
| 10136 | new_key = apply_modifiers (modifiers, | 10124 | the lower-case char is defined in the keymaps, because they |
| 10137 | XCAR (breakdown)); | 10125 | might get translated through function-key-map. */ |
| 10138 | |||
| 10139 | keybuf[t - 1] = new_key; | 10126 | keybuf[t - 1] = new_key; |
| 10140 | mock_input = max (t, mock_input); | 10127 | mock_input = max (t, mock_input); |
| 10128 | /* Reset fkey (and consequently keytran) to apply | ||
| 10129 | function-key-map on the result, so that S-backspace is | ||
| 10130 | correctly mapped to DEL (via backspace). OTOH, | ||
| 10131 | input-decode-map doesn't need to go through it again. */ | ||
| 10132 | fkey.start = fkey.end = 0; | ||
| 10133 | keytran.start = keytran.end = 0; | ||
| 10134 | |||
| 10141 | goto replay_sequence; | 10135 | goto replay_sequence; |
| 10142 | } | 10136 | } |
| 10143 | } | 10137 | } |
| 10144 | } | 10138 | } |
| 10145 | |||
| 10146 | if (!dummyflag) | 10139 | if (!dummyflag) |
| 10147 | read_key_sequence_cmd = (first_binding < nmaps | 10140 | read_key_sequence_cmd = (first_binding < nmaps |
| 10148 | ? defs[first_binding] | 10141 | ? defs[first_binding] |