emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Switch Meta and Alt modifiers


From: Kai Großjohann
Subject: Re: Switch Meta and Alt modifiers
Date: Wed, 30 Jan 2002 11:51:06 +0100
User-agent: Gnus/5.090006 (Oort Gnus v0.06) Emacs/21.2.50 (i686-pc-linux-gnu)

Richard Stallman <address@hidden> writes:

> The right approach is to test swap_meta_alt when *using* the
> values dpyinfo->alt_mod_mask and dpyinfo->meta_mod_mask.
> That way, swap_meta_alt can be a Lisp variable
> defined with DEFVAR_BOOL.

I see.  I also thought it might be useful to make it more general.  So
in this message you will find the current patch I'm using.  I use the
following in ~/.emacs:

(setq x-meta-keys 'alt)
(setq x-alt-keys 'meta)

So is this the right approach?  If so, I'll provide documentation and
stuff.

Index: src/xterm.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/xterm.c,v
retrieving revision 1.703
diff -u -r1.703 xterm.c
--- src/xterm.c 27 Jan 2002 16:43:36 -0000      1.703
+++ src/xterm.c 30 Jan 2002 10:50:38 -0000
@@ -381,6 +381,14 @@
 
 extern int extra_keyboard_modifiers;
 
+/* The keysyms to use for the various modifiers.  */
+
+unsigned int Vx_alt_keys;
+unsigned int Vx_hyper_keys;
+unsigned int Vx_meta_keys;
+unsigned int Vx_super_keys;
+
+
 static Lisp_Object Qvendor_specific_keysyms;
 
 extern XrmDatabase x_load_resources P_ ((Display *, char *, char *, char *));
@@ -6422,12 +6430,57 @@
      struct x_display_info *dpyinfo;
      unsigned int state;
 {
+  unsigned int mod_meta = meta_modifier;
+  unsigned int mod_alt  = alt_modifier;
+  unsigned int mod_hyper = hyper_modifier;
+  unsigned int mod_super = super_modifier;
+
+  if (EQ(Vx_alt_keys, intern("meta"))) {
+    mod_alt = meta_modifier;
+  } else if (EQ(Vx_meta_keys, intern("alt"))) {
+    mod_alt = alt_modifier;
+  } else if (EQ(Vx_meta_keys, intern("hyper"))) {
+    mod_alt = hyper_modifier;
+  } else if (EQ(Vx_meta_keys, intern("super"))) {
+    mod_alt = super_modifier;
+  }
+
+  if (EQ(Vx_hyper_keys, intern("meta"))) {
+    mod_hyper = meta_modifier;
+  } else if (EQ(Vx_hyper_keys, intern("alt"))) {
+    mod_hyper = alt_modifier;
+  } else if (EQ(Vx_hyper_keys, intern("hyper"))) {
+    mod_hyper = hyper_modifier;
+  } else if (EQ(Vx_hyper_keys, intern("super"))) {
+    mod_hyper = super_modifier;
+  }
+  
+  if (EQ(Vx_meta_keys, intern("meta"))) {
+    mod_meta = meta_modifier;
+  } else if (EQ(Vx_meta_keys, intern("alt"))) {
+    mod_meta = alt_modifier;
+  } else if (EQ(Vx_meta_keys, intern("hyper"))) {
+    mod_meta = hyper_modifier;
+  } else if (EQ(Vx_meta_keys, intern("super"))) {
+    mod_meta = super_modifier;
+  }
+
+  if (EQ(Vx_super_keys, intern("meta"))) {
+    mod_super = meta_modifier;
+  } else if (EQ(Vx_super_keys, intern("alt"))) {
+    mod_super = alt_modifier;
+  } else if (EQ(Vx_super_keys, intern("hyper"))) {
+    mod_super = hyper_modifier;
+  } else if (EQ(Vx_super_keys, intern("super"))) {
+    mod_super = super_modifier;
+  }
+
   return (  ((state & (ShiftMask | dpyinfo->shift_lock_mask)) ? shift_modifier 
: 0)
-         | ((state & ControlMask)             ? ctrl_modifier  : 0)
-         | ((state & dpyinfo->meta_mod_mask)  ? meta_modifier  : 0)
-         | ((state & dpyinfo->alt_mod_mask)   ? alt_modifier  : 0)
-         | ((state & dpyinfo->super_mod_mask) ? super_modifier  : 0)
-         | ((state & dpyinfo->hyper_mod_mask) ? hyper_modifier  : 0));
+            | ((state & ControlMask)                   ? ctrl_modifier : 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)
+            | ((state & dpyinfo->hyper_mod_mask)       ? mod_hyper     : 0));
 }
 
 static unsigned int
@@ -6435,12 +6488,57 @@
      struct x_display_info *dpyinfo;
      unsigned int state;
 {
-  return (  ((state & alt_modifier)    ? dpyinfo->alt_mod_mask   : 0)
-         | ((state & super_modifier)   ? dpyinfo->super_mod_mask : 0)
-         | ((state & hyper_modifier)   ? dpyinfo->hyper_mod_mask : 0)
-         | ((state & shift_modifier)   ? ShiftMask        : 0)
-         | ((state & ctrl_modifier)    ? ControlMask      : 0)
-         | ((state & meta_modifier)    ? dpyinfo->meta_mod_mask  : 0));
+  unsigned int mod_meta = meta_modifier;
+  unsigned int mod_alt  = alt_modifier;
+  unsigned int mod_hyper = hyper_modifier;
+  unsigned int mod_super = super_modifier;
+
+  if (EQ(Vx_alt_keys, intern("meta"))) {
+    mod_alt = meta_modifier;
+  } else if (EQ(Vx_meta_keys, intern("alt"))) {
+    mod_alt = alt_modifier;
+  } else if (EQ(Vx_meta_keys, intern("hyper"))) {
+    mod_alt = hyper_modifier;
+  } else if (EQ(Vx_meta_keys, intern("super"))) {
+    mod_alt = super_modifier;
+  }
+
+  if (EQ(Vx_hyper_keys, intern("meta"))) {
+    mod_hyper = meta_modifier;
+  } else if (EQ(Vx_hyper_keys, intern("alt"))) {
+    mod_hyper = alt_modifier;
+  } else if (EQ(Vx_hyper_keys, intern("hyper"))) {
+    mod_hyper = hyper_modifier;
+  } else if (EQ(Vx_hyper_keys, intern("super"))) {
+    mod_hyper = super_modifier;
+  }
+  
+  if (EQ(Vx_meta_keys, intern("meta"))) {
+    mod_meta = meta_modifier;
+  } else if (EQ(Vx_meta_keys, intern("alt"))) {
+    mod_meta = alt_modifier;
+  } else if (EQ(Vx_meta_keys, intern("hyper"))) {
+    mod_meta = hyper_modifier;
+  } else if (EQ(Vx_meta_keys, intern("super"))) {
+    mod_meta = super_modifier;
+  }
+
+  if (EQ(Vx_super_keys, intern("meta"))) {
+    mod_super = meta_modifier;
+  } else if (EQ(Vx_super_keys, intern("alt"))) {
+    mod_super = alt_modifier;
+  } else if (EQ(Vx_super_keys, intern("hyper"))) {
+    mod_super = hyper_modifier;
+  } else if (EQ(Vx_super_keys, intern("super"))) {
+    mod_super = super_modifier;
+  }
+
+  return (  ((state & mod_alt)         ? dpyinfo->alt_mod_mask   : 0)
+            | ((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_meta)      ? dpyinfo->meta_mod_mask  : 0));
 }
 
 /* Convert a keysym to its name.  */
@@ -15035,6 +15133,35 @@
 
   staticpro (&last_mouse_motion_frame);
   last_mouse_motion_frame = Qnil;
+  
+  DEFVAR_LISP ("x-alt-keys", &Vx_alt_keys,
+    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.  This
+is also the default.  */);
+  Vx_alt_keys = intern("alt");
+  
+  DEFVAR_LISP ("x-hyper-keys", &Vx_hyper_keys,
+    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.  This
+is also the default.  */);
+  Vx_hyper_keys = intern("hyper");
+  
+  DEFVAR_LISP ("x-meta-keys", &Vx_meta_keys,
+    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.  This
+is also the default.  */);
+  Vx_meta_keys = intern("meta");
+  
+  DEFVAR_LISP ("x-super-keys", &Vx_super_keys,
+    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.  This
+is also the default.  */);
+  Vx_super_keys = intern("super");
+
 }
 
 #endif /* HAVE_X_WINDOWS */


kai
-- 
~/.signature is: umop 3p!sdn    (Frank Nobis)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]