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, 18 Sep 2016 11:25:46 -0700 Message-ID: <87lgyp6p5h.fsf@secretsauce.net> References: <87oa3l7ku4.fsf@secretsauce.net> <87k2e9z4l9.fsf@users.sourceforge.net> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: blaine.gmane.org 1474223189 10996 195.159.176.226 (18 Sep 2016 18:26:29 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 18 Sep 2016 18:26:29 +0000 (UTC) User-Agent: mu4e 0.9.17; emacs 25.1.1 Cc: 24456@debbugs.gnu.org To: npostavs@users.sourceforge.net Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Sep 18 20:26:25 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 1blgn8-00015D-1s for geb-bug-gnu-emacs@m.gmane.org; Sun, 18 Sep 2016 20:26:14 +0200 Original-Received: from localhost ([::1]:51137 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1blgn6-0006MZ-BT for geb-bug-gnu-emacs@m.gmane.org; Sun, 18 Sep 2016 14:26:12 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:34414) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1blgn0-0006MQ-Mu for bug-gnu-emacs@gnu.org; Sun, 18 Sep 2016 14:26:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1blgmy-0008QC-IP for bug-gnu-emacs@gnu.org; Sun, 18 Sep 2016 14:26:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:36825) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1blgmw-0008NN-9e for bug-gnu-emacs@gnu.org; Sun, 18 Sep 2016 14:26:04 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1blgmv-0005GC-Vm for bug-gnu-emacs@gnu.org; Sun, 18 Sep 2016 14:26:01 -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, 18 Sep 2016 18:26:01 +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.147422315120204 (code B ref 24456); Sun, 18 Sep 2016 18:26:01 +0000 Original-Received: (at 24456) by debbugs.gnu.org; 18 Sep 2016 18:25:51 +0000 Original-Received: from localhost ([127.0.0.1]:34537 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1blgmk-0005Fn-QQ for submit@debbugs.gnu.org; Sun, 18 Sep 2016 14:25:51 -0400 Original-Received: from out2-smtp.messagingengine.com ([66.111.4.26]:57063) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1blgmj-0005Ff-0R for 24456@debbugs.gnu.org; Sun, 18 Sep 2016 14:25:49 -0400 Original-Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id 96B0820815; Sun, 18 Sep 2016 14:25:48 -0400 (EDT) Original-Received: from frontend2 ([10.202.2.161]) by compute5.internal (MEProxy); Sun, 18 Sep 2016 14:25:48 -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=DFCF4 v3jscrGMjcKVRJbv6wAaco=; b=bOypX/YsA8ZAuBoutv7aezfD1T0RUvuZNkdwG hCP9PtSbqspEq/ZORk3M1T8FFybg24M7IGJ6hX4JAA/N/oMZhD5NzAECZzQtzJyd 3sH1rt1BlsIvZq76CTSZU6svqq2ATcwlINqXTiWv/xBeoupsbj7kV8WgKc/amiGa 3SRY1k= 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=DFCF4v3jscrGMjcKVRJbv6wAaco=; b=liQJu M4aa7kfQG3iFQW7YcSdIgqnYn2sv+kchRYJKsVdpcjJjsMlGTL5ep0KqrRlz+6QZ rhofKFycJQL1c/fJZ3+ZxWWyK/GzBnF98LPKmvo+J28GqywJeypVZUmtL5g2oPwf XhFUzu4DuXEuyOWAwmk0snNAQqEUdfG9XfREKo= X-Sasl-enc: QmujnPV3RFBshehLvu+KfaFY06MherclgFcrWAcO3xTU 1474223148 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 3CE8CCCEA5; Sun, 18 Sep 2016 14:25:48 -0400 (EDT) Original-Received: from dima by shorty.local with local (Exim 4.87) (envelope-from ) id 1blgmg-0006FD-Os; Sun, 18 Sep 2016 11:25:46 -0700 In-reply-to: <87k2e9z4l9.fsf@users.sourceforge.net> 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:123424 Archived-At: --=-=-= Content-Type: text/plain npostavs@users.sourceforge.net writes: > After applying the patch to emacs-25, I built --with-x-toolkit=lucid and > --enable-checking; I get an assertion violation when hitting C-n with > capslock on. Thanks for testing. I didn't realize that assertions are disabled by default. Fixed patch attached. Eli Zaretskii writes: > Doesn't this mean that ASCII keys will behave differently from > non-ASCII when Caps Lock is ON? If you're talking about characters used in non-English languages, then I really have no idea what the current behavior is, or how to test it. I'm hoping one of yall who actually use these languages will tell me. dima --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Caps-lock-doesn-t-affect-interpretation-of-key-chord.patch >From 66510839464f0efdc625790f3e64091012408dda 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 | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/keyboard.c b/src/keyboard.c index b8bc361..cd8413b 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -5417,6 +5417,33 @@ 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 ('A' <= c && c <= 'Z' && + !(event->modifiers & shift_modifier) ) + { + /* Got a capital letter without a shift. The caps + lock is on. Un-capitalize the letter */ + c |= (unsigned)('a' - 'A'); + } + else if (('a' <= c && c <= 'z') && + (event->modifiers & shift_modifier) ) + { + /* Got a lower-case letter even though shift is + depressed. The caps lock is on. Capitalize the + letter */ + c &= ~(unsigned)('a' - 'A'); + } + } + /* Turn ASCII characters into control characters when proper. */ if (event->modifiers & ctrl_modifier) -- 2.9.3 --=-=-=--