unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#24822: 25.1; [PATCH] Support remapping control X keysym
@ 2016-10-29 23:53 Vasilij Schneidermann
  2016-10-30  0:10 ` Daniel Colascione
  2016-10-30  5:14 ` Alex
  0 siblings, 2 replies; 11+ messages in thread
From: Vasilij Schneidermann @ 2016-10-29 23:53 UTC (permalink / raw)
  To: 24822

[-- Attachment #1: Type: text/plain, Size: 360 bytes --]

There is a number of X keysyms that can be remapped inside Emacs, namely
alt, hyper, meta and super.  I found it odd that control is not on the
list (and to a lesser degree, shift), so I wrote a patch to offer it as
additional remappable X keysym.  This way one can swap the control and
meta key in Emacs with `(setq x-meta-keysym 'ctrl x-ctrl-keysym 'meta)`.

[-- Attachment #2: 0001-Support-remapping-control-X-keysym.patch --]
[-- Type: text/x-patch, Size: 5738 bytes --]

From f78f3f8e946dc869c7981b2030e408aeafde647b Mon Sep 17 00:00:00 2001
From: Vasilij Schneidermann <v.schneidermann@gmail.com>
Date: Sun, 30 Oct 2016 01:29:18 +0200
Subject: [PATCH] Support remapping control X keysym

---
 src/xterm.c | 43 +++++++++++++++++++++++++++++--------------
 1 file changed, 29 insertions(+), 14 deletions(-)

diff --git a/src/xterm.c b/src/xterm.c
index f0dd0ca..7f5350f 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, `alt' means use the Alt_L and Alt_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 `ctrl'.  */);
   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, `alt' means use the Alt_L and Alt_R keysyms.
+The default is nil, which is the same as `ctrl'.  */);
   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, `alt' means use the Alt_L and Alt_R keysyms.
+The default is nil, which is the same as `ctrl'.  */);
   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, `alt' means use the Alt_L and Alt_R keysyms.
+The default is nil, which is the same as `ctrl'.  */);
   Vx_super_keysym = Qnil;
 
   DEFVAR_LISP ("x-keysym-table", Vx_keysym_table,
-- 
2.10.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* bug#24822: 25.1; [PATCH] Support remapping control X keysym
  2016-10-29 23:53 bug#24822: 25.1; [PATCH] Support remapping control X keysym Vasilij Schneidermann
@ 2016-10-30  0:10 ` Daniel Colascione
  2016-10-30  0:27   ` Vasilij Schneidermann
  2016-10-30  5:14 ` Alex
  1 sibling, 1 reply; 11+ messages in thread
From: Daniel Colascione @ 2016-10-30  0:10 UTC (permalink / raw)
  To: Vasilij Schneidermann, 24822

On 10/29/2016 04:53 PM, Vasilij Schneidermann wrote:
> There is a number of X keysyms that can be remapped inside Emacs, namely
> alt, hyper, meta and super.  I found it odd that control is not on the
> list (and to a lesser degree, shift), so I wrote a patch to offer it as
> additional remappable X keysym.  This way one can swap the control and
> meta key in Emacs with `(setq x-meta-keysym 'ctrl x-ctrl-keysym 'meta)`.
>

Don't forget the NEWS entry.





^ permalink raw reply	[flat|nested] 11+ messages in thread

* bug#24822: 25.1; [PATCH] Support remapping control X keysym
  2016-10-30  0:10 ` Daniel Colascione
@ 2016-10-30  0:27   ` Vasilij Schneidermann
  2016-10-30  3:37     ` Eli Zaretskii
  0 siblings, 1 reply; 11+ messages in thread
From: Vasilij Schneidermann @ 2016-10-30  0:27 UTC (permalink / raw)
  To: Daniel Colascione; +Cc: 24822

> Don't forget the NEWS entry.

Thanks, I've considered doing this, but wasn't sure whether this would
go into etc/NEWS or etc/NEWS.25.  Another thing I'm wondering about is
whether there is any reason to not do this.





^ permalink raw reply	[flat|nested] 11+ messages in thread

* bug#24822: 25.1; [PATCH] Support remapping control X keysym
  2016-10-30  0:27   ` Vasilij Schneidermann
@ 2016-10-30  3:37     ` Eli Zaretskii
  2016-10-30 10:33       ` Vasilij Schneidermann
  0 siblings, 1 reply; 11+ messages in thread
From: Eli Zaretskii @ 2016-10-30  3:37 UTC (permalink / raw)
  To: Vasilij Schneidermann; +Cc: 24822

> Date: Sun, 30 Oct 2016 02:27:00 +0200
> From: Vasilij Schneidermann <v.schneidermann@gmail.com>
> Cc: 24822@debbugs.gnu.org
> 
> > Don't forget the NEWS entry.
> 
> Thanks, I've considered doing this, but wasn't sure whether this would
> go into etc/NEWS or etc/NEWS.25.

Changes should always be documented in NEWS.  NEWS.25 describes
changes in Emacs 25.x for Emacs 26 and higher, so it's never relevant.

> Another thing I'm wondering about is whether there is any reason to
> not do this.

In general, any user-visible changes should be in NEWS, unless they
are too insignificant to mention.

Did you look into the Emacs manual, to see if it also needs an update?

Thanks.





^ permalink raw reply	[flat|nested] 11+ messages in thread

* bug#24822: 25.1; [PATCH] Support remapping control X keysym
  2016-10-29 23:53 bug#24822: 25.1; [PATCH] Support remapping control X keysym Vasilij Schneidermann
  2016-10-30  0:10 ` Daniel Colascione
@ 2016-10-30  5:14 ` Alex
  2016-10-30 10:02   ` Vasilij Schneidermann
  1 sibling, 1 reply; 11+ messages in thread
From: Alex @ 2016-10-30  5:14 UTC (permalink / raw)
  To: Vasilij Schneidermann; +Cc: 24822

Vasilij Schneidermann <v.schneidermann@gmail.com> writes:

> There is a number of X keysyms that can be remapped inside Emacs, namely
> alt, hyper, meta and super.  I found it odd that control is not on the
> list (and to a lesser degree, shift), so I wrote a patch to offer it as
> additional remappable X keysym.  This way one can swap the control and
> meta key in Emacs with `(setq x-meta-keysym 'ctrl x-ctrl-keysym 'meta)`.

In the patch, all of the x-*-keysyms have the same docstring (including
the same examples and default). Is that intentional?





^ permalink raw reply	[flat|nested] 11+ messages in thread

* bug#24822: 25.1; [PATCH] Support remapping control X keysym
  2016-10-30  5:14 ` Alex
@ 2016-10-30 10:02   ` Vasilij Schneidermann
  2016-10-30 18:22     ` Alex
  0 siblings, 1 reply; 11+ messages in thread
From: Vasilij Schneidermann @ 2016-10-30 10:02 UTC (permalink / raw)
  To: Alex; +Cc: 24822

> In the patch, all of the x-*-keysyms have the same docstring (including
> the same examples and default). Is that intentional?

Previously, their docstrings were the same except for the first line
(naming the remapped modifier) and the last line (naming the default).
Thank you for pointing that out, I've fixed the latter case.





^ permalink raw reply	[flat|nested] 11+ messages in thread

* bug#24822: 25.1; [PATCH] Support remapping control X keysym
  2016-10-30  3:37     ` Eli Zaretskii
@ 2016-10-30 10:33       ` Vasilij Schneidermann
  0 siblings, 0 replies; 11+ messages in thread
From: Vasilij Schneidermann @ 2016-10-30 10:33 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 24822

[-- Attachment #1: Type: text/plain, Size: 330 bytes --]

> Changes should always be documented in NEWS.  NEWS.25 describes
> changes in Emacs 25.x for Emacs 26 and higher, so it's never relevant.

Thanks, I've added it to the "Changes in Emacs 26.1" section.
 
> Did you look into the Emacs manual, to see if it also needs an update?

I've updated the existing manual entry now as well.

[-- Attachment #2: 0001-Support-remapping-control-X-keysym.patch --]
[-- Type: text/x-diff, Size: 7390 bytes --]

From 1533124a83c82e60418669d3dcc83c38adfe3fa7 Mon Sep 17 00:00:00 2001
From: Vasilij Schneidermann <v.schneidermann@gmail.com>
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.
+
 \f
 * Editing Changes in Emacs 26.1
 
diff --git a/src/xterm.c b/src/xterm.c
index f0dd0ca..0a420cd 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, `alt' means use the Alt_L and Alt_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, `alt' means use the Alt_L and Alt_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, `alt' means use the Alt_L and Alt_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, `alt' means use the Alt_L and Alt_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


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* bug#24822: 25.1; [PATCH] Support remapping control X keysym
  2016-10-30 10:02   ` Vasilij Schneidermann
@ 2016-10-30 18:22     ` Alex
  2016-10-30 19:29       ` Vasilij Schneidermann
  2016-10-30 19:38       ` Vasilij Schneidermann
  0 siblings, 2 replies; 11+ messages in thread
From: Alex @ 2016-10-30 18:22 UTC (permalink / raw)
  To: Vasilij Schneidermann; +Cc: 24822

Vasilij Schneidermann <v.schneidermann@gmail.com> writes:

>> In the patch, all of the x-*-keysyms have the same docstring (including
>> the same examples and default). Is that intentional?
>
> Previously, their docstrings were the same except for the first line
> (naming the remapped modifier) and the last line (naming the default).
> Thank you for pointing that out, I've fixed the latter case.

What about this line?

  +`super'.  For example, `alt' means use the Alt_L and Alt_R keysyms.

For example, in x-hyper-keysym it mentioned Hyper_L and Hyper_R instead.





^ permalink raw reply	[flat|nested] 11+ messages in thread

* bug#24822: 25.1; [PATCH] Support remapping control X keysym
  2016-10-30 18:22     ` Alex
@ 2016-10-30 19:29       ` Vasilij Schneidermann
  2016-10-30 19:38       ` Vasilij Schneidermann
  1 sibling, 0 replies; 11+ messages in thread
From: Vasilij Schneidermann @ 2016-10-30 19:29 UTC (permalink / raw)
  To: Alex; +Cc: 24822

> What about this line?
> 
>   +`super'.  For example, `alt' means use the Alt_L and Alt_R keysyms.
> 
> For example, in x-hyper-keysym it mentioned Hyper_L and Hyper_R instead.

That line explains the keysyms for the value `alt`, so that should be
fine.  If someone wants the docstring to explain different values
depending on what keysym remapping it supports, fine by me.





^ permalink raw reply	[flat|nested] 11+ messages in thread

* bug#24822: 25.1; [PATCH] Support remapping control X keysym
  2016-10-30 18:22     ` Alex
  2016-10-30 19:29       ` Vasilij Schneidermann
@ 2016-10-30 19:38       ` Vasilij Schneidermann
  2016-11-04  9:11         ` Eli Zaretskii
  1 sibling, 1 reply; 11+ messages in thread
From: Vasilij Schneidermann @ 2016-10-30 19:38 UTC (permalink / raw)
  To: Alex; +Cc: 24822

[-- Attachment #1: Type: text/plain, Size: 90 bytes --]

Sorry, I've looked at my version instead of the original one.

I've attached a fixed one.

[-- Attachment #2: 0001-Support-remapping-control-X-keysym.patch --]
[-- Type: text/x-diff, Size: 7410 bytes --]

From 6e26cf40ce1138ac2739492d8da01dcca1d14371 Mon Sep 17 00:00:00 2001
From: Vasilij Schneidermann <v.schneidermann@gmail.com>
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.
+
 \f
 * 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


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* bug#24822: 25.1; [PATCH] Support remapping control X keysym
  2016-10-30 19:38       ` Vasilij Schneidermann
@ 2016-11-04  9:11         ` Eli Zaretskii
  0 siblings, 0 replies; 11+ messages in thread
From: Eli Zaretskii @ 2016-11-04  9:11 UTC (permalink / raw)
  To: Vasilij Schneidermann; +Cc: agrambot, 24822-done

> Date: Sun, 30 Oct 2016 20:38:10 +0100
> From: Vasilij Schneidermann <v.schneidermann@gmail.com>
> Cc: 24822@debbugs.gnu.org
> 
> Sorry, I've looked at my version instead of the original one.
> 
> I've attached a fixed one.

Thanks, pushed to master.

Please in the future include ChangeLog-style commit log message for
your changes.





^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2016-11-04  9:11 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-29 23:53 bug#24822: 25.1; [PATCH] Support remapping control X keysym Vasilij Schneidermann
2016-10-30  0:10 ` Daniel Colascione
2016-10-30  0:27   ` Vasilij Schneidermann
2016-10-30  3:37     ` Eli Zaretskii
2016-10-30 10:33       ` Vasilij Schneidermann
2016-10-30  5:14 ` Alex
2016-10-30 10:02   ` Vasilij Schneidermann
2016-10-30 18:22     ` Alex
2016-10-30 19:29       ` Vasilij Schneidermann
2016-10-30 19:38       ` Vasilij Schneidermann
2016-11-04  9:11         ` Eli Zaretskii

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).