LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   .Xmodmap and meta key (https://www.linuxquestions.org/questions/linux-software-2/xmodmap-and-meta-key-368626/)

jrdioko 09-30-2005 11:35 PM

.Xmodmap and meta key
 
I use xmodmap to set my right alt key as a mode_switch key that allows me to type international characters. However, that means I don't have a meta key to use with emacs. What do I need to put in my .Xmodmap file to set my right control key to whatever emacs sees as the meta key (keeping my left control as is)?

flower.Hercules 10-02-2005 09:26 AM

Code:

keycode #  =  Control_L
perhaps?

jrdioko 10-02-2005 09:46 AM

Isn't that setting some key to be control, not meta?

flower.Hercules 10-02-2005 10:06 AM

Yes, but would emacs see a difference? It is the default value of what your emacs currently sees, I don't know if it will work but it is worth a try.

Edit: Nevermind me, I'm just a little slow today.

Code:

xmodmap -e "keysym Control_R = Control_R Meta_L"
something to that effect...I wouldn't recommend trying that code, read this instead. That appears to work for me. I got that code from the xmodmap listing, just typing xmodmap. I don't know, though, I'm in over my head, I don't use emacs (I use vi) so I can't test it :(

Code:

      % cat ~/.Xmodmap
      !Right Alt key is used to Meta key
      keysym Mode_switch = Escape
      keysym Meta_R = Escape

Just another option, since it might be easier to migrate to Alt on the same side, rather than Control on the other side. HTH

jrdioko 10-02-2005 05:09 PM

Hmm, it gives errors when I try the lines above, but I looked through the documentation some more and tried something else. It looks like the key code for Control_R is 97. I put the following in .Xmodmap:

Code:

keycode 97 = Meta_L
However, Control_R continues to be treated as a control key. I tried playing with the values of mod1, mod4, etc., but nothing seemed to work. It seems like the problem is with what emacs will consider a Meta key, but I can't figure out anything that will make this work. Any other ideas?

flower.Hercules 10-02-2005 07:16 PM

Well, you got me very interested in this problem, as a result, I installed emacs and I believe I have your solution.

Code:

xmodmap -e "remove control = Control_R"
xmodmap -e "add mod1 = Control_R"

I also added the line
Code:

Option    "RightCtl"    "Meta"
to the keyboard InputDevice section of my xorg.conf, I don't know if that made a difference.


Edit: I just realized you might have set Control_R to Meta_L, in which case, just switch it back to Control_R with
Code:

xmodmap -e "keycode 97 = Control_R"
I learned a lot about xmodmap, I thank you:)

jrdioko 10-02-2005 07:50 PM

You're welcome, and I'm inviting you to learn more :)

That solution accomplished more than I'd done before, but still doesn't quite work. The problem is, I have Fluxbox set up to have mod1 be the modifier used in most key bindings. If I make your changes and then do Ctrl-t, it is interpreted as what I normally do as Alt-t (also bound to mod1), which opens a terminal window. The way I understood it from poking around online, emacs just needs a key to be designated Meta without having any modifier bindings to work, but it doesn't seem to for me.

flower.Hercules 10-02-2005 08:14 PM

Well, you could put the left alt key in mod3 (it is empty in my xmodmap) and replace all mod1's in your Fluxbox configuration with mod3, that shouldn't change any functionality, just how it works under the hood, it's a patch job; I haven't given up :) I will see what I can come up with.

Edit: However, you may like this solution better...I hope it doesn't bugger anything else, Emacs, when it came about, as you've probably read, heavily used meta-keys, some keyboards didn't have them, so the author added the ability to use the Escape key...so
Code:

xmodmap -e "remove mod1 = Control_R"
xmodmap -e "keysym Control_R = Escape"

Viola!

jrdioko 10-02-2005 08:23 PM

The problem with the escape solution is that, when using that method, you press and release escape, then press the key, rather than the normal method of doing keystrokes. I'll try rearranging all the modifiers though and see if that does the trick.

flower.Hercules 10-02-2005 08:29 PM

I knew it couldn't be that simple :( However, the binding of Control_R to Escape does seem to work as a Keystroke pressing Control_R and A returns me to the first line of the working paragraph; this is as far as my Emacs knowledge goes, do you have a specific keystroke that you are using that gives you faulty behavior?

jrdioko 10-02-2005 11:54 PM

I moved all the modifiers around and Control_R now acts as escape. If I just press Control_R, "ESC-" appears at the bottom of the screen. I've been trying C-v and M-v, but M-v won't work unless I release Control_R before pressing v (that is, it's acting as escape, not meta).

flower.Hercules 10-03-2005 07:09 AM

So as mod3 it is Escape or did you leave it as
Code:

xmodmap -e "keysym Control_R = Escape"
because, that would should be
Code:

xmodmap -e "keycode 97 = Control_R"


All times are GMT -5. The time now is 09:26 PM.