From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Dima Kogan Newsgroups: gmane.emacs.bugs Subject: bug#24456: 25.1; [PATCH] Caps-lock doesn't affect interpretation of key chords Date: Sun, 25 Sep 2016 11:44:23 -0700 Message-ID: <87shsnddko.fsf@secretsauce.net> References: <87oa3l7ku4.fsf@secretsauce.net> <87k2e9z4l9.fsf@users.sourceforge.net> <87lgyp6p5h.fsf@secretsauce.net> <834m5ciq4m.fsf@gnu.org> <87k2e879by.fsf@secretsauce.net> <83shsvhmc2.fsf@gnu.org> <87fuov7o3a.fsf@secretsauce.net> <83lgynhgg1.fsf@gnu.org> <87d1jz7hx3.fsf@secretsauce.net> <83mvj1fgi4.fsf@gnu.org> <8737ks7rw2.fsf@secretsauce.net> <83oa3gdkmo.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: blaine.gmane.org 1474829140 23075 195.159.176.226 (25 Sep 2016 18:45:40 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 25 Sep 2016 18:45:40 +0000 (UTC) User-Agent: mu4e 0.9.17; emacs 25.1.50.1 Cc: 24456@debbugs.gnu.org, npostavs@users.sourceforge.net To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Sep 25 20:45:35 2016 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1boEQU-000428-DG for geb-bug-gnu-emacs@m.gmane.org; Sun, 25 Sep 2016 20:45:22 +0200 Original-Received: from localhost ([::1]:40008 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1boEQS-0006ZI-S9 for geb-bug-gnu-emacs@m.gmane.org; Sun, 25 Sep 2016 14:45:20 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:46498) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1boEQI-0006U1-R8 for bug-gnu-emacs@gnu.org; Sun, 25 Sep 2016 14:45:11 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1boEQC-0000rl-T9 for bug-gnu-emacs@gnu.org; Sun, 25 Sep 2016 14:45:09 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:57818) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1boEQA-0000qZ-Kb for bug-gnu-emacs@gnu.org; Sun, 25 Sep 2016 14:45:04 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1boEQA-0000DT-Ak for bug-gnu-emacs@gnu.org; Sun, 25 Sep 2016 14:45:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Dima Kogan Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 25 Sep 2016 18:45:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 24456 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 24456-submit@debbugs.gnu.org id=B24456.1474829068764 (code B ref 24456); Sun, 25 Sep 2016 18:45:02 +0000 Original-Received: (at 24456) by debbugs.gnu.org; 25 Sep 2016 18:44:28 +0000 Original-Received: from localhost ([127.0.0.1]:35775 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1boEPc-0000CG-0Y for submit@debbugs.gnu.org; Sun, 25 Sep 2016 14:44:28 -0400 Original-Received: from out2-smtp.messagingengine.com ([66.111.4.26]:37561) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1boEPa-0000C8-Gk for 24456@debbugs.gnu.org; Sun, 25 Sep 2016 14:44:26 -0400 Original-Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id CB63F206B4; Sun, 25 Sep 2016 14:44:25 -0400 (EDT) Original-Received: from frontend2 ([10.202.2.161]) by compute5.internal (MEProxy); Sun, 25 Sep 2016 14:44:25 -0400 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=secretsauce.net; h=cc:content-type:date:from:in-reply-to:message-id:mime-version :references:subject:to:x-sasl-enc:x-sasl-enc; s=mesmtp; bh=Nx5+g Qb3qrk06PGF/tfuW5YGmnU=; b=dMPD4gwJVmAjqZr9yg07X9CC657ho6OXytpyj xdeylIfv0424ECzJmoBj6rj5suOtAfzj2DJXbN/VKJ3Eyp58CQmuajHnDOvTOy52 A+p5Af+f/ry00l7++WkoY2lJZA9J2xdxkcPgstYheU3a4K8HfR5Tx5vDRXXsr6gH 8jxQn0= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-sasl-enc :x-sasl-enc; s=smtpout; bh=Nx5+gQb3qrk06PGF/tfuW5YGmnU=; b=CAAsP Xf/IskEcJyKlgCaVhDrxs+PjWzq863Fppi14Bzj1F1BEGQtLKZ+cZ9Lr1x82NXpQ ZeXT3AqCJIXLrQz6i2i7K2IAWEL4s/jMswvdoDgp3qpxtpNyVNLm2OxPdu2P4brK uL+d1KuiYwBNWDTCZn5MAU/zU6Xa8uF1PKbHXw= X-Sasl-enc: IqrFkAOOETohfTFmUQ+nqNC9xnVHjAvFGcjCnCXjgLpe 1474829065 Original-Received: from shorty.local (50-1-153-216.dsl.dynamic.fusionbroadband.com [50.1.153.216]) by mail.messagingengine.com (Postfix) with ESMTPA id 5A0BFCCE88; Sun, 25 Sep 2016 14:44:25 -0400 (EDT) Original-Received: from dima by shorty.local with local (Exim 4.87) (envelope-from ) id 1boEPX-0006OA-Mx; Sun, 25 Sep 2016 11:44:23 -0700 In-reply-to: <83oa3gdkmo.fsf@gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:123688 Archived-At: --=-=-= Content-Type: text/plain Eli Zaretskii writes: > Thanks. However, this doesn't look right to me: your code is entirely > inside the following condition: > > if (event->kind == ASCII_KEYSTROKE_EVENT) > > So it will not do anything for non-ASCII keystrokes. You should move > the code out of that condition, I think. > >> + if (uppercasep(c) && >> + !(event->modifiers & shift_modifier) ) > > A nit: our coding standards request a space between the function name > and the opening parenthesis that follows it, and no spaces between > closing parentheses. OK. How about this? --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Caps-lock-doesn-t-affect-interpretation-of-key-chord.patch >From e3a0375ea66a746a6a02e94f85ef71bf7fe9db5d Mon Sep 17 00:00:00 2001 From: Dima Kogan 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 b8bc361..e8a199d 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -5417,6 +5417,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.9.3 --=-=-=--