From: "Pascal J. Bourguignon" <pjb@informatimago.com>
To: help-gnu-emacs@gnu.org
Subject: Re: Why the C-M-<keys> is invalid in my emacs?
Date: Sat, 08 Aug 2015 06:17:42 +0200 [thread overview]
Message-ID: <87egjejtw9.fsf@kuiper.lan.informatimago.com> (raw)
In-Reply-To: mailman.7970.1438999012.904.help-gnu-emacs@gnu.org
Navy Cheng <navych@126.com> 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
next prev parent reply other threads:[~2015-08-08 4:17 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <mailman.7970.1438999012.904.help-gnu-emacs@gnu.org>
2015-08-08 2:42 ` Why the C-M-<keys> is invalid in my emacs? Rusi
2015-08-08 3:10 ` Navy Cheng
2015-08-08 17:36 ` Robert Thorpe
[not found] ` <mailman.7971.1439003457.904.help-gnu-emacs@gnu.org>
2015-08-08 3:12 ` Rusi
2015-08-08 4:16 ` Navy Cheng
2015-08-08 4:17 ` Pascal J. Bourguignon [this message]
2015-08-08 1:56 Navy Cheng
2015-08-08 5:26 ` Ian Zimmerman
2015-08-08 5:57 ` Navy Cheng
2015-08-08 6:42 ` Ian Zimmerman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87egjejtw9.fsf@kuiper.lan.informatimago.com \
--to=pjb@informatimago.com \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).