help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: Why the C-M-<keys> is invalid in my emacs?


From: Pascal J. Bourguignon
Subject: Re: Why the C-M-<keys> is invalid in my emacs?
Date: Sat, 08 Aug 2015 06:17:42 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux)

Navy Cheng <address@hidden> writes:

> Hi,
>
> I find I can't use *C-M-<keys>* combined key in my emacs. I have to use
> *Esc C-<keys>* to instead. However, when I close X-server in my OS and
> use emacs in the console, *C-M-<keys>* is OK.
>
> Why? How can I use *C-M-<keys>*, such as *C-M-h* in X?

That would depend on your window manager, that probably preempt C-M- or
just M- for its own purposes.  Configure your window manager to use
another combination, or change the window manager.

Also, you may edit your ~/.xmodmap

You can bind the X symbols: Super_L Super_R Hyper_L Hyper_R Control_L
Control_R Shift_L Shift_R Alt_L Alt_R Meta_L Meta_R to keycodes.

You can also bind Multi_key and Mode_switch which have special X
keyboard functions.

For example, I have (codes depend on your keyboard):

    keycode 127 = Super_R
    keycode  66 = Control_L
    keycode  50 = Shift_L
    keycode  62 = Shift_R         
    keycode 133 = Alt_L
    keycode  64 = Meta_L
    keycode 108 = Meta_R
    keycode 135 = Hyper_R
    keycode 105 = Control_R
    keycode  90 = Super_R

    keycode  37 = Multi_key       
    keycode 134 = Mode_switch


But now as you can see, there are more key symbols above than mode bits
in an X event.  There are only 8 mode bits (which means that you can
only generate 256 different symbols from a single keycode.  Theorically,
you could have 256 symbols on the keycode lines (not in practice, there
are implementation restrictions on reading the xmodmap, but internally,
the tables would allow it AFAIK).

Anyways, the 8 mode bits are:

    clear Shift
    clear Lock
    clear Control
    clear Mod1
    clear Mod2
    clear Mod3
    clear Mod4
    clear Mod5

And you can map the key syms you wish to those mode bits as you want:

    !!! In order of bits (for order of keysyms on keycode lines):
    add    Shift   = Shift_L     Shift_R
    add    Lock    = Caps_Lock
    add    Control = Control_L   Control_R
    add    Mod1    = Num_Lock
    add    Mod2    = Alt_L       Alt_R       Mode_switch
    add    Mod3    = Meta_L      Meta_R
    add    Mod4    = Super_L     Super_R
    add    Mod5    = Hyper_L     Hyper_R     

And the point here, is that window managers often use the mode bit to
activate their functions. I've used window managers that used Mod2;
therefore you assigning Meta_L and Meta_R to a different mode bit, you
can let it pass free thru the window manager to emacs.


So:

1. type a key on the keyboard -> produces a keycode

2. X dispatches the keycode x current mode bits -> produce a keysym
   (as per keycode lines).

3. X processes Mode_switch, Multi_key

4. X maps keysym to mode bits

5. X send event with keycode, keysym and mode bits

6. window manager processes event, filters it out, pass it to the
   application; most often uses a given mode bit.

7. application gets the event and processes it as it wishes

8. then you get emacs event processing (key-translations, chord sequence
   aggregation, command dispatching), so you can also make your own
   transformations at the key-translation level, or by finally binding a
   command to do the thing you want on the final key chord you get.
   emacs translates ESC x to M-x in the chord sequence aggregation step.

   More details can be found in documentation and sources of emacs.
   But the solution to your problem is probably in the configuration of
   your window manager or editing your .xmodmap

-- 
__Pascal Bourguignon__                 http://www.informatimago.com/
“The factory of the future will have only two employees, a man and a
dog. The man will be there to feed the dog. The dog will be there to
keep the man from touching the equipment.” -- Carl Bass CEO Autodesk


reply via email to

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