From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Vasilij Schneidermann Newsgroups: gmane.emacs.bugs Subject: bug#24822: 25.1; [PATCH] Support remapping control X keysym Date: Sun, 30 Oct 2016 20:38:10 +0100 Message-ID: <20161030193810.GD555@odonien.localdomain> References: <87oa22beqr.fsf@gmail.com> <20161030100201.GA555@odonien.localdomain> <87bmy1bstc.fsf@gmail.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="yEPQxsgoJgBvi8ip" X-Trace: blaine.gmane.org 1477856374 14540 195.159.176.226 (30 Oct 2016 19:39:34 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 30 Oct 2016 19:39:34 +0000 (UTC) User-Agent: Mutt/1.7.1 (2016-10-04) Cc: 24822@debbugs.gnu.org To: Alex Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Oct 30 20:39:30 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 1c0vwj-0000Z2-2m for geb-bug-gnu-emacs@m.gmane.org; Sun, 30 Oct 2016 20:39:09 +0100 Original-Received: from localhost ([::1]:59820 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c0vwl-0001Dr-Qp for geb-bug-gnu-emacs@m.gmane.org; Sun, 30 Oct 2016 15:39:11 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:42793) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c0vwf-0001DW-9J for bug-gnu-emacs@gnu.org; Sun, 30 Oct 2016 15:39:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c0vwc-0000iP-41 for bug-gnu-emacs@gnu.org; Sun, 30 Oct 2016 15:39:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:50284) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1c0vwb-0000iL-VB for bug-gnu-emacs@gnu.org; Sun, 30 Oct 2016 15:39:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1c0vwb-0000LZ-PZ for bug-gnu-emacs@gnu.org; Sun, 30 Oct 2016 15:39:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Vasilij Schneidermann Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 30 Oct 2016 19:39:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 24822 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 24822-submit@debbugs.gnu.org id=B24822.14778563001283 (code B ref 24822); Sun, 30 Oct 2016 19:39:01 +0000 Original-Received: (at 24822) by debbugs.gnu.org; 30 Oct 2016 19:38:20 +0000 Original-Received: from localhost ([127.0.0.1]:37450 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c0vvv-0000Kd-QI for submit@debbugs.gnu.org; Sun, 30 Oct 2016 15:38:20 -0400 Original-Received: from mail-wm0-f41.google.com ([74.125.82.41]:34969) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c0vvt-0000KO-RF for 24822@debbugs.gnu.org; Sun, 30 Oct 2016 15:38:18 -0400 Original-Received: by mail-wm0-f41.google.com with SMTP id e69so202286685wmg.0 for <24822@debbugs.gnu.org>; Sun, 30 Oct 2016 12:38:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=g4IgawlW0GH9iU1DF5RGlxplQ2P9CygRdt8meMz8x70=; b=aU9PunBueDZNJvxoXpQ88TjluFhAcFcNQd6eD2VKN5azKxW7q1taXaLdxbEBNoV8w6 JEojaM4MfkJ+junRQJbQX7m/lMP0koMgyNYps/71CzMUTgeHvD/chD0eeZ9eVZQCUP7J T/NYg4F1SXluLH/VKaOFCbiOhOIWZ/fB0QvT2RLvJWUtUHJuBtn1//nRnjs7moJSM32G rLak36BlReCeTFtKyOedBlwa3GEbWar3Xa5Z+zCgA81GV82pjhMFAJWxvckbSGHUYWzq CQgg2sZXucwT39GLN3FRTdRTxrAq8LW2bH1KOcntfUFJTXv8fTbxRD/aQYOh8KyuFXci g+2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=g4IgawlW0GH9iU1DF5RGlxplQ2P9CygRdt8meMz8x70=; b=MY9TKxgjWpoGoKgtB4Zs7nlOBG6nje39sqCnFJHFDaCah1D84NumFl3euWKyz7JTp4 M6eW5jCKeqE1avs3ughXL/bFtgFlj3USiqxVfqhEwM22yBU0FIZj8ie+YNNbMbV/82/Z HwEEj06Ww7qLrF0QecDx++TAV4TTufq7ECseOliwZ+LpWQKenGjQRb6hCJPtqyae3ao9 BhLUCn58X5ezoDp6qvvoy6fY0RnkxZEY2m3r9Jap+c5F6AG8CT/vlyOD1pRgZqhWx8AI tWvY/QynIuqcp6yeCMXbWStS6Tb1V+jajI0uS2tgRYBgPdMBknbR/bPkb0K1u5MJva+c tvfQ== X-Gm-Message-State: ABUngve21HytSPBoE4mPh026XV8FN6sOnpJldi9Z6cAY8LW3RIlZX+lVsYBSBkYLBT2KyQ== X-Received: by 10.194.152.4 with SMTP id uu4mr7588812wjb.172.1477856291929; Sun, 30 Oct 2016 12:38:11 -0700 (PDT) Original-Received: from localhost (dslb-092-072-002-098.092.072.pools.vodafone-ip.de. [92.72.2.98]) by smtp.gmail.com with ESMTPSA id c7sm26024854wjk.19.2016.10.30.12.38.11 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 30 Oct 2016 12:38:11 -0700 (PDT) Content-Disposition: inline In-Reply-To: <87bmy1bstc.fsf@gmail.com> 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:125165 Archived-At: --yEPQxsgoJgBvi8ip Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Sorry, I've looked at my version instead of the original one. I've attached a fixed one. --yEPQxsgoJgBvi8ip Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="0001-Support-remapping-control-X-keysym.patch" >From 6e26cf40ce1138ac2739492d8da01dcca1d14371 Mon Sep 17 00:00:00 2001 From: Vasilij Schneidermann Date: Sun, 30 Oct 2016 01:29:18 +0200 Subject: [PATCH] Support remapping control X keysym --- doc/lispref/os.texi | 10 ++++++---- etc/NEWS | 5 +++++ src/xterm.c | 43 +++++++++++++++++++++++++++++-------------- 3 files changed, 40 insertions(+), 18 deletions(-) diff --git a/doc/lispref/os.texi b/doc/lispref/os.texi index 277abb1..97b086c 100644 --- a/doc/lispref/os.texi +++ b/doc/lispref/os.texi @@ -2254,14 +2254,16 @@ The variable is always local to the current terminal, and cannot be buffer-local. @xref{Multiple Terminals}. @end defvar -You can specify which keysyms Emacs should use for the Meta, Alt, Hyper, and Super modifiers by setting these variables: +You can specify which keysyms Emacs should use for the Control, Meta, +Alt, Hyper, and Super modifiers by setting these variables: -@defvar x-alt-keysym +@defvar x-ctrl-keysym +@defvarx x-alt-keysym @defvarx x-meta-keysym @defvarx x-hyper-keysym @defvarx x-super-keysym -The name of the keysym that should stand for the Alt modifier -(respectively, for Meta, Hyper, and Super). For example, here is +The name of the keysym that should stand for the Control modifier +(respectively, for Alt, Meta, Hyper, and Super). For example, here is how to swap the Meta and Alt modifiers within Emacs: @lisp (setq x-alt-keysym 'meta) diff --git a/etc/NEWS b/etc/NEWS index e29dfe2..a773e92 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -233,6 +233,11 @@ questions, with a handy way to display help texts. all call stack frames in a Lisp backtrace buffer as lists. Both debug.el and edebug.el have been updated to heed to this variable. ++++ +** The new variable `x-ctrl-keysym` has been added to the existing +roster of X keysyms. It can be used in combination with another +variable of this kind to swap modifiers in Emacs. + * Editing Changes in Emacs 26.1 diff --git a/src/xterm.c b/src/xterm.c index f0dd0ca..d6e1fe2 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -4701,12 +4701,15 @@ x_find_modifier_meanings (struct x_display_info *dpyinfo) int x_x_to_emacs_modifiers (struct x_display_info *dpyinfo, int state) { + int mod_ctrl = ctrl_modifier; int mod_meta = meta_modifier; int mod_alt = alt_modifier; int mod_hyper = hyper_modifier; int mod_super = super_modifier; Lisp_Object tem; + tem = Fget (Vx_ctrl_keysym, Qmodifier_value); + if (INTEGERP (tem)) mod_ctrl = XINT (tem) & INT_MAX; tem = Fget (Vx_alt_keysym, Qmodifier_value); if (INTEGERP (tem)) mod_alt = XINT (tem) & INT_MAX; tem = Fget (Vx_meta_keysym, Qmodifier_value); @@ -4717,7 +4720,7 @@ x_x_to_emacs_modifiers (struct x_display_info *dpyinfo, int state) if (INTEGERP (tem)) mod_super = XINT (tem) & INT_MAX; return ( ((state & (ShiftMask | dpyinfo->shift_lock_mask)) ? shift_modifier : 0) - | ((state & ControlMask) ? ctrl_modifier : 0) + | ((state & ControlMask) ? mod_ctrl : 0) | ((state & dpyinfo->meta_mod_mask) ? mod_meta : 0) | ((state & dpyinfo->alt_mod_mask) ? mod_alt : 0) | ((state & dpyinfo->super_mod_mask) ? mod_super : 0) @@ -4727,6 +4730,7 @@ x_x_to_emacs_modifiers (struct x_display_info *dpyinfo, int state) static int x_emacs_to_x_modifiers (struct x_display_info *dpyinfo, EMACS_INT state) { + EMACS_INT mod_ctrl = ctrl_modifier; EMACS_INT mod_meta = meta_modifier; EMACS_INT mod_alt = alt_modifier; EMACS_INT mod_hyper = hyper_modifier; @@ -4734,6 +4738,8 @@ x_emacs_to_x_modifiers (struct x_display_info *dpyinfo, EMACS_INT state) Lisp_Object tem; + tem = Fget (Vx_ctrl_keysym, Qmodifier_value); + if (INTEGERP (tem)) mod_ctrl = XINT (tem); tem = Fget (Vx_alt_keysym, Qmodifier_value); if (INTEGERP (tem)) mod_alt = XINT (tem); tem = Fget (Vx_meta_keysym, Qmodifier_value); @@ -4748,7 +4754,7 @@ x_emacs_to_x_modifiers (struct x_display_info *dpyinfo, EMACS_INT state) | ((state & mod_super) ? dpyinfo->super_mod_mask : 0) | ((state & mod_hyper) ? dpyinfo->hyper_mod_mask : 0) | ((state & shift_modifier) ? ShiftMask : 0) - | ((state & ctrl_modifier) ? ControlMask : 0) + | ((state & mod_ctrl) ? ControlMask : 0) | ((state & mod_meta) ? dpyinfo->meta_mod_mask : 0)); } @@ -12863,6 +12869,8 @@ With MS Windows or Nextstep, the value is t. */); #endif DEFSYM (Qmodifier_value, "modifier-value"); + DEFSYM (Qctrl, "ctrl"); + Fput (Qctrl, Qmodifier_value, make_number (ctrl_modifier)); DEFSYM (Qalt, "alt"); Fput (Qalt, Qmodifier_value, make_number (alt_modifier)); DEFSYM (Qhyper, "hyper"); @@ -12872,32 +12880,39 @@ With MS Windows or Nextstep, the value is t. */); DEFSYM (Qsuper, "super"); Fput (Qsuper, Qmodifier_value, make_number (super_modifier)); + DEFVAR_LISP ("x-ctrl-keysym", Vx_ctrl_keysym, + doc: /* Which keys Emacs uses for the ctrl modifier. +This should be one of the symbols `ctrl', `alt', `hyper', `meta', +`super'. For example, `ctrl' means use the Ctrl_L and Ctrl_R keysyms. +The default is nil, which is the same as `ctrl'. */); + Vx_ctrl_keysym = Qnil; + DEFVAR_LISP ("x-alt-keysym", Vx_alt_keysym, doc: /* Which keys Emacs uses for the alt modifier. -This should be one of the symbols `alt', `hyper', `meta', `super'. -For example, `alt' means use the Alt_L and Alt_R keysyms. The default -is nil, which is the same as `alt'. */); +This should be one of the symbols `ctrl', `alt', `hyper', `meta', +`super'. For example, `alt' means use the Alt_L and Alt_R keysyms. +The default is nil, which is the same as `alt'. */); Vx_alt_keysym = Qnil; DEFVAR_LISP ("x-hyper-keysym", Vx_hyper_keysym, doc: /* Which keys Emacs uses for the hyper modifier. -This should be one of the symbols `alt', `hyper', `meta', `super'. -For example, `hyper' means use the Hyper_L and Hyper_R keysyms. The -default is nil, which is the same as `hyper'. */); +This should be one of the symbols `ctrl', `alt', `hyper', `meta', +`super'. For example, `hyper' means use the Hyper_L and Hyper_R +keysyms. The default is nil, which is the same as `hyper'. */); Vx_hyper_keysym = Qnil; DEFVAR_LISP ("x-meta-keysym", Vx_meta_keysym, doc: /* Which keys Emacs uses for the meta modifier. -This should be one of the symbols `alt', `hyper', `meta', `super'. -For example, `meta' means use the Meta_L and Meta_R keysyms. The -default is nil, which is the same as `meta'. */); +This should be one of the symbols `ctrl', `alt', `hyper', `meta', +`super'. For example, `meta' means use the Meta_L and Meta_R keysyms. +The default is nil, which is the same as `meta'. */); Vx_meta_keysym = Qnil; DEFVAR_LISP ("x-super-keysym", Vx_super_keysym, doc: /* Which keys Emacs uses for the super modifier. -This should be one of the symbols `alt', `hyper', `meta', `super'. -For example, `super' means use the Super_L and Super_R keysyms. The -default is nil, which is the same as `super'. */); +This should be one of the symbols `ctrl', `alt', `hyper', `meta', +`super'. For example, `super' means use the Super_L and Super_R +keysyms. The default is nil, which is the same as `super'. */); Vx_super_keysym = Qnil; DEFVAR_LISP ("x-keysym-table", Vx_keysym_table, -- 2.10.1 --yEPQxsgoJgBvi8ip--