diff options
author | Dima Kogan <dima@secretsauce.net> | 2016-10-15 17:18:40 +0300 |
---|---|---|
committer | Eli Zaretskii <eliz@gnu.org> | 2016-10-15 17:18:40 +0300 |
commit | a38096f8e2978a14f3bc8fa0dc3e0c9d0f753c3c (patch) | |
tree | d7577f27589e17386e097fea2c09d1057aa40908 /src/keyboard.c | |
parent | 07c0db4344072895726101e39eb92a26e1d2d3d1 (diff) | |
download | emacs-a38096f8e2978a14f3bc8fa0dc3e0c9d0f753c3c.tar.gz emacs-a38096f8e2978a14f3bc8fa0dc3e0c9d0f753c3c.tar.bz2 emacs-a38096f8e2978a14f3bc8fa0dc3e0c9d0f753c3c.zip |
Undo the effect of CapsLock when other modifiers are present
* src/keyboard.c (make_lispy_event): Effectively undo the effect
of CapsLock if any modifiers other than Shift are present in a key.
(Bug#24456)
Diffstat (limited to 'src/keyboard.c')
-rw-r--r-- | src/keyboard.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/keyboard.c b/src/keyboard.c index ca40c6e7ad0..87a68511052 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -5417,6 +5417,36 @@ make_lispy_event (struct input_event *event) { c &= 0377; eassert (c == event->code); + } + + /* Caps-lock shouldn't affect interpretation of key chords: + Control+s should produce C-s whether caps-lock is on or + not. And Control+Shift+s should produce C-S-s whether + caps-lock is on or not. */ + if (event->modifiers & ~shift_modifier) + { + /* this is a key chord: some non-shift modifier is + depressed */ + + if (uppercasep (c) && + !(event->modifiers & shift_modifier)) + { + /* Got a capital letter without a shift. The caps + lock is on. Un-capitalize the letter */ + c = downcase(c); + } + else if (lowercasep (c) && + (event->modifiers & shift_modifier)) + { + /* Got a lower-case letter even though shift is + depressed. The caps lock is on. Capitalize the + letter */ + c = upcase(c); + } + } + + if (event->kind == ASCII_KEYSTROKE_EVENT) + { /* Turn ASCII characters into control characters when proper. */ if (event->modifiers & ctrl_modifier) |