From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Yuri Khan Newsgroups: gmane.emacs.help Subject: Re: Caps Lock affects Ctrl+keys Date: Tue, 21 Jan 2014 03:38:58 +0700 Message-ID: References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1390250345 15833 80.91.229.3 (20 Jan 2014 20:39:05 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 20 Jan 2014 20:39:05 +0000 (UTC) To: "help-gnu-emacs@gnu.org" Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Jan 20 21:39:12 2014 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1W5Lcl-0002Hk-62 for geh-help-gnu-emacs@m.gmane.org; Mon, 20 Jan 2014 21:39:11 +0100 Original-Received: from localhost ([::1]:54540 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W5Lck-0005Wj-RL for geh-help-gnu-emacs@m.gmane.org; Mon, 20 Jan 2014 15:39:10 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:34706) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W5Lca-0005W5-0D for help-gnu-emacs@gnu.org; Mon, 20 Jan 2014 15:39:00 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W5LcZ-00005i-1R for help-gnu-emacs@gnu.org; Mon, 20 Jan 2014 15:38:59 -0500 Original-Received: from mail-qa0-x22e.google.com ([2607:f8b0:400d:c00::22e]:49042) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W5LcY-00005d-SV for help-gnu-emacs@gnu.org; Mon, 20 Jan 2014 15:38:58 -0500 Original-Received: by mail-qa0-f46.google.com with SMTP id ii20so5819857qab.19 for ; Mon, 20 Jan 2014 12:38:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:content-type:content-transfer-encoding; bh=dFdFnhI+6qBj6IHtcjK0r11GspmZ6O7rsMKjvnxV+Ec=; b=Cprg1mqVJJIexBroXZAOc4LtckY4+VJT6NKims6yznTpopQnIrJ+Z8oVHSVK4iCwg2 GkhipMdYXqacKJ5fGSZ/BkJfsp8sxhPU4LBLibgOx+ePo6zMrNIkxpTrvxz6s5UGqPJw 3efUSgMd1qZ7G/97x1TQXRnR4n/FeBl3jm01okBqctd4IbBFwdQ7hqXYRNilQvbMw85H zn98NlExIkX4xwc6KpIGtymDA+5gov9s2h2zXFjpmkLqh8rM9LutQFohlYmpxZ1ZZdY4 fBcDOXHECXbN6WBcqjHpDGzbRNUYiJad88iLN+HqIpWKm13NITOmwKOvKF9e8QfcK/kB zTrw== X-Received: by 10.224.47.81 with SMTP id m17mr16379999qaf.61.1390250338430; Mon, 20 Jan 2014 12:38:58 -0800 (PST) Original-Received: by 10.96.14.74 with HTTP; Mon, 20 Jan 2014 12:38:58 -0800 (PST) In-Reply-To: X-Google-Sender-Auth: UDHpfTa-8yiqF5V56ee31dg_QVw X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:400d:c00::22e X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:95520 Archived-At: On Mon, Jan 20, 2014 at 6:57 PM, Yuri Khan wrote: > I notice that, when I turn on Caps Lock, all Ctrl+letter combinations > behave as if I pressed Ctrl+Shift+letter. OK, I looked at the code. In xterm.c, function handle_one_xevent, a KeyPress event is received, with state =3D=3D 0x06 (LockMask | ControlMask) and keycode =3D=3D 52 ( according to xkb/keycodes/evdev). Then, XmbLookupString is called on this event, producing keysym =3D=3D 0x5a ('Z') and storing a single 0x1a character to copy_bufptr. The latter is ignored because the =E2=80=9Cif (keysym >=3D 32 && keysym < 128)=E2=80=9D branch is taken, producing an eve= nt {kind: ASCII_KEYSTROKE_EVENT, code: 0x5a, modifiers: ctrl_modifier}. The LockMask bit is lost at this point. Then, under the =E2=80=9Cdone:=E2=80=9D label, the kbd_buffer_store_event_h= old function from keyboard.c is called, which in turn calls make_ctrl_char, which sees 0x5a and sets the shift_modifier. After this, no further processing, in Lisp or in C, can detect that the Shift key was not in fact pressed. The problem stems from the concept that keyboard input is a stream of (extended) characters and any modifier keys just add modifier bits to those characters. I do not think it can be fixed or worked around without a significant rethinking of the input model. This is unfortunate because, as a user, I expect Caps Lock to only affect character input, not command bindings. As it is, turning on Caps Lock upsets any key bindings that involve Shift. This includes cua-mode=E2=80=99s C-x and C-c, and any user-defined bindings (in my case, C-S-z =3D redo and C-S-u =3D insert-char). Related: When I switch XKB groups (e.g. activate Russian layout), I lose all C-letter and M-letter bindings, because they then produce Cyrillic letters with the respective modifiers. E.g. with US English QWERTY as primary and Russian =D0=99=D0=A6=D0=A3=D0=9A=D0=95=D0=9D as secon= dary, pressing Ctrl+W produces C-=D1=86 instead of C-w. I work around this with an ugly key-translation-map hack.