]> git.eshelyaron.com Git - emacs.git/commitdiff
Add 'x-ctrl-keysym' support on X window system
authorVasilij Schneidermann <v.schneidermann@gmail.com>
Fri, 4 Nov 2016 09:09:31 +0000 (11:09 +0200)
committerEli Zaretskii <eliz@gnu.org>
Fri, 4 Nov 2016 09:09:31 +0000 (11:09 +0200)
* src/xterm.c (x_x_to_emacs_modifiers, x_emacs_to_x_modifiers):
Support 'x-ctrl-keysym'.
(syms_of_xterm): DEFSYM "ctrl" and put a proper modifier-value
property on it.
<x-ctrl-keysym>: New DEFVAR_LISP.
<x-alt-keysym, x-hyper-keysym, x-meta-keysym, x-super-keysym>: Doc
fix.  (Bug#24822)

* etc/NEWS: Mention the addition of 'x-ctrl-keysym'.

* doc/lispref/os.texi (X11 Keysyms): Document 'x-ctrl-keysym'.

doc/lispref/os.texi
etc/NEWS
src/xterm.c

index 277abb1477d7b93c58c89ed56a63e460be43160b..97b086c0d373f6c2f6615db80938803d85c6c949 100644 (file)
@@ -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)
index 9a671f2ae53d8f18f0d1203332f389a85241cb5d..f34ee2d5799edb0b9ecf617d9c1897a71b2d823b 100644 (file)
--- 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
 
index f0dd0ca1dc12e0d07a11b919491dd9640fb89037..d6e1fe2190c83465b394f99c7f7bf3a9c0ad2287 100644 (file)
@@ -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,