Re: xmodmap, readline, and ye olde meta key
Re: xmodmap, readline, and ye olde meta key
- Subject: Re: xmodmap, readline, and ye olde meta key
- From: Jeremy Huddleston <email@hidden>
- Date: Sat, 8 Jan 2011 18:19:14 -0800
>>> 1. move-by-word to work by pressing alt-f and alt-b
>>
>> That's not really an X11 issue. That's a bash issue. You should
>> create/edit /etc/inputrc or ~/.inputrc
>
> I now know I cannot solve this with .inputrc alone. Why? Because neither
> command-b nor option-b emit anything! Only command-option-b does.
Weird... I just verified that alt-left and alt-right work in xterm to change by-word with the attached /etc/inputrc (note that I can't take credit from it. I got it from somewhere, which got it from somewhere, ... and made my own changes to it... some of which I understand, some of which I don't).
It should work with no ~/.Xmodmap and the checkbox enabled to use Alt rather than Mode_switch.
Attachment:
inputrc
Description: Binary data
I believe the key points are:
set meta-flag on
set input-meta on
set convert-meta off
set output-meta on
"\e[1;3C": forward-word
"\e[1;3D": backward-word
I'm using it fine with my ~/.Xmodmap which allows use of both Alt and Mode_switch:
keycode 66 = Alt_L
keycode 69 = Mode_switch
clear mod1
clear mod3
add mod1 = Mode_switch
add mod3 = Alt_L
(obviously it will work with the left option since it is Alt_L and not the right option since it is Mode_switch)
> Part of my confusion stems from the many layers of software a keystroke
> passes through on its way to the application, bash in this case. I think
> it looks something like this:
>
> 0. hardware generates an interrupt
> 1. a kernel device generates a keycode
You're a few steps here:
IOKit sends the keycode to AppKit
AppKit sends an NSEvent to X11
> 2. X generates a keysym
This is really three steps:
X11 translates the NSEvent into an XEvent with an X11 keycode
The X11 server translates the keycode into a keysym and sends that as an xEvent (or XEvent, I forget which is which) and also sends an XInput event corresponding to the keypress.
> 3. xterm generates an escape sequence, such that the left-arrow key
> becomes 1b 4f 44
Right, xterm gets notified of either/both the xEvent and the XI event depending on what it prefers and then "handles it" by either doing something internal or sending it to the terminal to be handled by the terminal (readline -> bash).
> 4. application receives 1b 4f 44
>
> That's my mental framework. Question #1 is, what does bash see?
I believe (I'm not too familiar with this step) that bash gets the escaped sequence and hands it to readline which tells it "<back one word>"
> With an xterm open running bash, if I type the following,
What is "option" ? Are you mapping it to Alt or Mode_switch? If it's mapped to Mode_switch, then
> ...
>
> Just couple more general questions and observations, if I may:
>>> I find no
>>> reliable information on whether or no ${HOME}/.xinitrc is supposed to
>>> work.
>
>> As with all recent distributions, ~/.xinitrc is deprecated in favor of >
>> ~/.xinitrc.d, but it will work ... chances are your ~/.xinitrc as why
>> xmodmap wasn't being run.
>
> I think the Internet dropped a word or two on you? ;-)
Weird. But yes, please don't use ~/.xinitrc.
> Thanks. I wasn't aware of xinitrc.d. My xinit(1) man page doesn't
> mention it.
We should update that. Xorg's man pages are a bit dated.
> One last question: can you recommend an X11 book? I learned C from K&R,
> C++ from Stroustrup, Unix IPC from Stevens, and SQL from Date. I don't
> want to program X, but I find it hard to understand all the knobs. I did
> find http://www.sbin.org/doc/Xlib/chapt_09.html helpful.
Honestly, it's best to let someone else deal with the "X11 mess" ... if you want to write GUI apps for X11, I'd focus at a higher level like GTK or QT. X11 itself is a bit messy and is evolving quite a bit.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
X11-users mailing list (email@hidden)
This email sent to email@hidden