diff options
| author | Vasilij Schneidermann | 2016-11-04 11:09:31 +0200 |
|---|---|---|
| committer | Eli Zaretskii | 2016-11-04 11:09:31 +0200 |
| commit | 0adefe7ef9f4c23a5c8fef1503bc2b02ea6db8f5 (patch) | |
| tree | ad43bcbb044bb1b50aa84771f2c90b78c2758691 | |
| parent | e5d0efe8fc4130593a899a9699ed8a95b953df3a (diff) | |
| download | emacs-0adefe7ef9f4c23a5c8fef1503bc2b02ea6db8f5.tar.gz emacs-0adefe7ef9f4c23a5c8fef1503bc2b02ea6db8f5.zip | |
Add 'x-ctrl-keysym' support on X window system
* 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'.
| -rw-r--r-- | doc/lispref/os.texi | 10 | ||||
| -rw-r--r-- | etc/NEWS | 5 | ||||
| -rw-r--r-- | src/xterm.c | 43 |
3 files changed, 40 insertions, 18 deletions
diff --git a/doc/lispref/os.texi b/doc/lispref/os.texi index 277abb1477d..97b086c0d37 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 | |||
| 2254 | buffer-local. @xref{Multiple Terminals}. | 2254 | buffer-local. @xref{Multiple Terminals}. |
| 2255 | @end defvar | 2255 | @end defvar |
| 2256 | 2256 | ||
| 2257 | You can specify which keysyms Emacs should use for the Meta, Alt, Hyper, and Super modifiers by setting these variables: | 2257 | You can specify which keysyms Emacs should use for the Control, Meta, |
| 2258 | Alt, Hyper, and Super modifiers by setting these variables: | ||
| 2258 | 2259 | ||
| 2259 | @defvar x-alt-keysym | 2260 | @defvar x-ctrl-keysym |
| 2261 | @defvarx x-alt-keysym | ||
| 2260 | @defvarx x-meta-keysym | 2262 | @defvarx x-meta-keysym |
| 2261 | @defvarx x-hyper-keysym | 2263 | @defvarx x-hyper-keysym |
| 2262 | @defvarx x-super-keysym | 2264 | @defvarx x-super-keysym |
| 2263 | The name of the keysym that should stand for the Alt modifier | 2265 | The name of the keysym that should stand for the Control modifier |
| 2264 | (respectively, for Meta, Hyper, and Super). For example, here is | 2266 | (respectively, for Alt, Meta, Hyper, and Super). For example, here is |
| 2265 | how to swap the Meta and Alt modifiers within Emacs: | 2267 | how to swap the Meta and Alt modifiers within Emacs: |
| 2266 | @lisp | 2268 | @lisp |
| 2267 | (setq x-alt-keysym 'meta) | 2269 | (setq x-alt-keysym 'meta) |
| @@ -233,6 +233,11 @@ questions, with a handy way to display help texts. | |||
| 233 | all call stack frames in a Lisp backtrace buffer as lists. Both | 233 | all call stack frames in a Lisp backtrace buffer as lists. Both |
| 234 | debug.el and edebug.el have been updated to heed to this variable. | 234 | debug.el and edebug.el have been updated to heed to this variable. |
| 235 | 235 | ||
| 236 | +++ | ||
| 237 | ** The new variable `x-ctrl-keysym` has been added to the existing | ||
| 238 | roster of X keysyms. It can be used in combination with another | ||
| 239 | variable of this kind to swap modifiers in Emacs. | ||
| 240 | |||
| 236 | 241 | ||
| 237 | * Editing Changes in Emacs 26.1 | 242 | * Editing Changes in Emacs 26.1 |
| 238 | 243 | ||
diff --git a/src/xterm.c b/src/xterm.c index f0dd0ca1dc1..d6e1fe2190c 100644 --- a/src/xterm.c +++ b/src/xterm.c | |||
| @@ -4701,12 +4701,15 @@ x_find_modifier_meanings (struct x_display_info *dpyinfo) | |||
| 4701 | int | 4701 | int |
| 4702 | x_x_to_emacs_modifiers (struct x_display_info *dpyinfo, int state) | 4702 | x_x_to_emacs_modifiers (struct x_display_info *dpyinfo, int state) |
| 4703 | { | 4703 | { |
| 4704 | int mod_ctrl = ctrl_modifier; | ||
| 4704 | int mod_meta = meta_modifier; | 4705 | int mod_meta = meta_modifier; |
| 4705 | int mod_alt = alt_modifier; | 4706 | int mod_alt = alt_modifier; |
| 4706 | int mod_hyper = hyper_modifier; | 4707 | int mod_hyper = hyper_modifier; |
| 4707 | int mod_super = super_modifier; | 4708 | int mod_super = super_modifier; |
| 4708 | Lisp_Object tem; | 4709 | Lisp_Object tem; |
| 4709 | 4710 | ||
| 4711 | tem = Fget (Vx_ctrl_keysym, Qmodifier_value); | ||
| 4712 | if (INTEGERP (tem)) mod_ctrl = XINT (tem) & INT_MAX; | ||
| 4710 | tem = Fget (Vx_alt_keysym, Qmodifier_value); | 4713 | tem = Fget (Vx_alt_keysym, Qmodifier_value); |
| 4711 | if (INTEGERP (tem)) mod_alt = XINT (tem) & INT_MAX; | 4714 | if (INTEGERP (tem)) mod_alt = XINT (tem) & INT_MAX; |
| 4712 | tem = Fget (Vx_meta_keysym, Qmodifier_value); | 4715 | tem = Fget (Vx_meta_keysym, Qmodifier_value); |
| @@ -4717,7 +4720,7 @@ x_x_to_emacs_modifiers (struct x_display_info *dpyinfo, int state) | |||
| 4717 | if (INTEGERP (tem)) mod_super = XINT (tem) & INT_MAX; | 4720 | if (INTEGERP (tem)) mod_super = XINT (tem) & INT_MAX; |
| 4718 | 4721 | ||
| 4719 | return ( ((state & (ShiftMask | dpyinfo->shift_lock_mask)) ? shift_modifier : 0) | 4722 | return ( ((state & (ShiftMask | dpyinfo->shift_lock_mask)) ? shift_modifier : 0) |
| 4720 | | ((state & ControlMask) ? ctrl_modifier : 0) | 4723 | | ((state & ControlMask) ? mod_ctrl : 0) |
| 4721 | | ((state & dpyinfo->meta_mod_mask) ? mod_meta : 0) | 4724 | | ((state & dpyinfo->meta_mod_mask) ? mod_meta : 0) |
| 4722 | | ((state & dpyinfo->alt_mod_mask) ? mod_alt : 0) | 4725 | | ((state & dpyinfo->alt_mod_mask) ? mod_alt : 0) |
| 4723 | | ((state & dpyinfo->super_mod_mask) ? mod_super : 0) | 4726 | | ((state & dpyinfo->super_mod_mask) ? mod_super : 0) |
| @@ -4727,6 +4730,7 @@ x_x_to_emacs_modifiers (struct x_display_info *dpyinfo, int state) | |||
| 4727 | static int | 4730 | static int |
| 4728 | x_emacs_to_x_modifiers (struct x_display_info *dpyinfo, EMACS_INT state) | 4731 | x_emacs_to_x_modifiers (struct x_display_info *dpyinfo, EMACS_INT state) |
| 4729 | { | 4732 | { |
| 4733 | EMACS_INT mod_ctrl = ctrl_modifier; | ||
| 4730 | EMACS_INT mod_meta = meta_modifier; | 4734 | EMACS_INT mod_meta = meta_modifier; |
| 4731 | EMACS_INT mod_alt = alt_modifier; | 4735 | EMACS_INT mod_alt = alt_modifier; |
| 4732 | EMACS_INT mod_hyper = hyper_modifier; | 4736 | EMACS_INT mod_hyper = hyper_modifier; |
| @@ -4734,6 +4738,8 @@ x_emacs_to_x_modifiers (struct x_display_info *dpyinfo, EMACS_INT state) | |||
| 4734 | 4738 | ||
| 4735 | Lisp_Object tem; | 4739 | Lisp_Object tem; |
| 4736 | 4740 | ||
| 4741 | tem = Fget (Vx_ctrl_keysym, Qmodifier_value); | ||
| 4742 | if (INTEGERP (tem)) mod_ctrl = XINT (tem); | ||
| 4737 | tem = Fget (Vx_alt_keysym, Qmodifier_value); | 4743 | tem = Fget (Vx_alt_keysym, Qmodifier_value); |
| 4738 | if (INTEGERP (tem)) mod_alt = XINT (tem); | 4744 | if (INTEGERP (tem)) mod_alt = XINT (tem); |
| 4739 | tem = Fget (Vx_meta_keysym, Qmodifier_value); | 4745 | tem = Fget (Vx_meta_keysym, Qmodifier_value); |
| @@ -4748,7 +4754,7 @@ x_emacs_to_x_modifiers (struct x_display_info *dpyinfo, EMACS_INT state) | |||
| 4748 | | ((state & mod_super) ? dpyinfo->super_mod_mask : 0) | 4754 | | ((state & mod_super) ? dpyinfo->super_mod_mask : 0) |
| 4749 | | ((state & mod_hyper) ? dpyinfo->hyper_mod_mask : 0) | 4755 | | ((state & mod_hyper) ? dpyinfo->hyper_mod_mask : 0) |
| 4750 | | ((state & shift_modifier) ? ShiftMask : 0) | 4756 | | ((state & shift_modifier) ? ShiftMask : 0) |
| 4751 | | ((state & ctrl_modifier) ? ControlMask : 0) | 4757 | | ((state & mod_ctrl) ? ControlMask : 0) |
| 4752 | | ((state & mod_meta) ? dpyinfo->meta_mod_mask : 0)); | 4758 | | ((state & mod_meta) ? dpyinfo->meta_mod_mask : 0)); |
| 4753 | } | 4759 | } |
| 4754 | 4760 | ||
| @@ -12863,6 +12869,8 @@ With MS Windows or Nextstep, the value is t. */); | |||
| 12863 | #endif | 12869 | #endif |
| 12864 | 12870 | ||
| 12865 | DEFSYM (Qmodifier_value, "modifier-value"); | 12871 | DEFSYM (Qmodifier_value, "modifier-value"); |
| 12872 | DEFSYM (Qctrl, "ctrl"); | ||
| 12873 | Fput (Qctrl, Qmodifier_value, make_number (ctrl_modifier)); | ||
| 12866 | DEFSYM (Qalt, "alt"); | 12874 | DEFSYM (Qalt, "alt"); |
| 12867 | Fput (Qalt, Qmodifier_value, make_number (alt_modifier)); | 12875 | Fput (Qalt, Qmodifier_value, make_number (alt_modifier)); |
| 12868 | DEFSYM (Qhyper, "hyper"); | 12876 | DEFSYM (Qhyper, "hyper"); |
| @@ -12872,32 +12880,39 @@ With MS Windows or Nextstep, the value is t. */); | |||
| 12872 | DEFSYM (Qsuper, "super"); | 12880 | DEFSYM (Qsuper, "super"); |
| 12873 | Fput (Qsuper, Qmodifier_value, make_number (super_modifier)); | 12881 | Fput (Qsuper, Qmodifier_value, make_number (super_modifier)); |
| 12874 | 12882 | ||
| 12883 | DEFVAR_LISP ("x-ctrl-keysym", Vx_ctrl_keysym, | ||
| 12884 | doc: /* Which keys Emacs uses for the ctrl modifier. | ||
| 12885 | This should be one of the symbols `ctrl', `alt', `hyper', `meta', | ||
| 12886 | `super'. For example, `ctrl' means use the Ctrl_L and Ctrl_R keysyms. | ||
| 12887 | The default is nil, which is the same as `ctrl'. */); | ||
| 12888 | Vx_ctrl_keysym = Qnil; | ||
| 12889 | |||
| 12875 | DEFVAR_LISP ("x-alt-keysym", Vx_alt_keysym, | 12890 | DEFVAR_LISP ("x-alt-keysym", Vx_alt_keysym, |
| 12876 | doc: /* Which keys Emacs uses for the alt modifier. | 12891 | doc: /* Which keys Emacs uses for the alt modifier. |
| 12877 | This should be one of the symbols `alt', `hyper', `meta', `super'. | 12892 | This should be one of the symbols `ctrl', `alt', `hyper', `meta', |
| 12878 | For example, `alt' means use the Alt_L and Alt_R keysyms. The default | 12893 | `super'. For example, `alt' means use the Alt_L and Alt_R keysyms. |
| 12879 | is nil, which is the same as `alt'. */); | 12894 | The default is nil, which is the same as `alt'. */); |
| 12880 | Vx_alt_keysym = Qnil; | 12895 | Vx_alt_keysym = Qnil; |
| 12881 | 12896 | ||
| 12882 | DEFVAR_LISP ("x-hyper-keysym", Vx_hyper_keysym, | 12897 | DEFVAR_LISP ("x-hyper-keysym", Vx_hyper_keysym, |
| 12883 | doc: /* Which keys Emacs uses for the hyper modifier. | 12898 | doc: /* Which keys Emacs uses for the hyper modifier. |
| 12884 | This should be one of the symbols `alt', `hyper', `meta', `super'. | 12899 | This should be one of the symbols `ctrl', `alt', `hyper', `meta', |
| 12885 | For example, `hyper' means use the Hyper_L and Hyper_R keysyms. The | 12900 | `super'. For example, `hyper' means use the Hyper_L and Hyper_R |
| 12886 | default is nil, which is the same as `hyper'. */); | 12901 | keysyms. The default is nil, which is the same as `hyper'. */); |
| 12887 | Vx_hyper_keysym = Qnil; | 12902 | Vx_hyper_keysym = Qnil; |
| 12888 | 12903 | ||
| 12889 | DEFVAR_LISP ("x-meta-keysym", Vx_meta_keysym, | 12904 | DEFVAR_LISP ("x-meta-keysym", Vx_meta_keysym, |
| 12890 | doc: /* Which keys Emacs uses for the meta modifier. | 12905 | doc: /* Which keys Emacs uses for the meta modifier. |
| 12891 | This should be one of the symbols `alt', `hyper', `meta', `super'. | 12906 | This should be one of the symbols `ctrl', `alt', `hyper', `meta', |
| 12892 | For example, `meta' means use the Meta_L and Meta_R keysyms. The | 12907 | `super'. For example, `meta' means use the Meta_L and Meta_R keysyms. |
| 12893 | default is nil, which is the same as `meta'. */); | 12908 | The default is nil, which is the same as `meta'. */); |
| 12894 | Vx_meta_keysym = Qnil; | 12909 | Vx_meta_keysym = Qnil; |
| 12895 | 12910 | ||
| 12896 | DEFVAR_LISP ("x-super-keysym", Vx_super_keysym, | 12911 | DEFVAR_LISP ("x-super-keysym", Vx_super_keysym, |
| 12897 | doc: /* Which keys Emacs uses for the super modifier. | 12912 | doc: /* Which keys Emacs uses for the super modifier. |
| 12898 | This should be one of the symbols `alt', `hyper', `meta', `super'. | 12913 | This should be one of the symbols `ctrl', `alt', `hyper', `meta', |
| 12899 | For example, `super' means use the Super_L and Super_R keysyms. The | 12914 | `super'. For example, `super' means use the Super_L and Super_R |
| 12900 | default is nil, which is the same as `super'. */); | 12915 | keysyms. The default is nil, which is the same as `super'. */); |
| 12901 | Vx_super_keysym = Qnil; | 12916 | Vx_super_keysym = Qnil; |
| 12902 | 12917 | ||
| 12903 | DEFVAR_LISP ("x-keysym-table", Vx_keysym_table, | 12918 | DEFVAR_LISP ("x-keysym-table", Vx_keysym_table, |