bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#24456: 25.1; [PATCH] Caps-lock doesn't affect interpretation of key


From: Dima Kogan
Subject: bug#24456: 25.1; [PATCH] Caps-lock doesn't affect interpretation of key chords
Date: Sat, 01 Oct 2016 08:12:27 -0700
User-agent: mu4e 0.9.17; emacs 25.1.1

Andreas Schwab <schwab@linux-m68k.org> writes:

> Line break before operator, not after.

Eli Zaretskii <eliz@gnu.org> writes:

> Looks okay, but you still didn't leave a space before the opening
> parentheses and the function name.

Attached. Is there a tool to automatically detect/fix these?



> Did you try this with a non-ASCII key (assuming you have one on your
> keyboard)?

I did not try. I live in the US, and pretty much never see keyboards
with anything non-trivial on them. If somebody else would test it, that
would be great.

>From 9b12fff089dd3a4eb99373e92c635c20cebd0198 Mon Sep 17 00:00:00 2001
From: Dima Kogan <dima@secretsauce.net>
Date: Sat, 17 Sep 2016 23:47:48 -0700
Subject: [PATCH] Caps-lock doesn't affect interpretation of key chords

* src/keyboard.c (make_lispy_event): when a user pressed key-chords the
caps-lock no longer affects the "shift" state of the generated chord.  For
instance Control+s produces C-s regardless of the caps-lock state.  And
Control+Shift+s produces C-S-s regardless of the caps-lock state.
---
 src/keyboard.c | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

diff --git a/src/keyboard.c b/src/keyboard.c
index ccd3405..cdeea8e 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -5368,6 +5368,37 @@ 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)
-- 
2.8.0.rc3


reply via email to

[Prev in Thread] Current Thread [Next in Thread]