Re: Can I switch CapsLock and Ctrl_L just for emacs sessions?



Jerry Fleming <jerry@xxxxxxx> writes:
I was wondering if I can swtich CapsLock and Ctrl_L just for emacs
sessions, while in other applications (gnome-terminal, firefox, vim,
etc.) everything remains the same, simultaneously?

I am using a modified keymap to do this right now; it is very
inconvenient because not all applications have so many key bindings.

Is there a way to do this with some lisp code in my .emacs?

First question you should ask yourself is whether you need CapsLock at
all? I have turned CapsLock into yet another Control key and live happy
with that!


But if you decide you want CapsLock to be active, the only solution
I can think of is groups in X server. With proper configuration,
pressing by Shifts (for instance) will switch to another group. In one
group you may have Control and CapsLock switch and in another on the
same position. Here is part of my own xorg.conf (I assume you're using
X):

#v+
Section "InputDevice"
Identifier "Keyboard"
Driver "kbd"

Option "XkbModel" "pc105"
Option "XkbLayout" "pl,pl,pl"
Option "XkbVariant" ",dvorak,dvp"
Option "XkbOptions" "grp:shifts_toggle,grp_led:scroll,ctrl:nocaps"
EndSection
#v-

What you'll need to do is create a variant with those keys switched and
set it in XkbVariant modifying the rest to fit your layout (you may
configure up to four groups).


The same or similar can be achieved with some desktop managers if you
configure them to switch keyboard map by pressing some keys. Moreover,
you may prepare two scripts which feed xmodmap with proper data and run
them on command.


Unfortunately, none of those methods works the way you'd like it to:
they are not automatic -- you need to perform some action (ie. press
keys). On the other hand, some window managers allow running some code
when a window gains focus and that could be a way to go if you use such
a window manager (but that needs some coding of course).


I'm unaware of any better solution.

--
Best regards, _ _
.o. | Liege of Serenly Enlightened Majesty of o' \,=./ `o
..o | Computer Science, Michal "mina86" Nazarewicz (o o)
ooo +--<mina86*tlen.pl>--<jid:mina86*jabber.org>--ooO--(_)--Ooo--
.



Relevant Pages

  • Re: Great SWT Program
    ... there the arrow keys *sometimes* did something useful, ... both about how vim works and about ... called by all applications -- except that with the Unix model you ... for their putative purpose due to the clumsy interface that makes ...
    (comp.lang.java.programmer)
  • Fw: [FreeBSD-Announce] FreeBSD Security Advisory FreeBSD-SA-06:23.openssl
    ... The above patch reduces the functionality of libcryptoby ... prohibiting the use of exceptionally large public keys. ... For general information regarding FreeBSD Security Advisories, ... many applications using OpenSSL do not perform any validation ...
    (freebsd-questions)
  • Re: Newsreader: Best of the bunch?
    ... I'm talking about COMMON functions such as ... which gives me that, I'll switch to it. ... When I use another editor, I constantly hit wrong keys, ...
    (Debian-User)
  • Re: OT Reptitive Strain Injury
    ... So far the doctors have offered nothing ... are reprogrammable and they have a cluster of keys under each thumb. ... Switch and don't look back. ... layouts) but if you already have problems you don't want to be tensing ...
    (comp.lang.lisp)
  • Re: rebinding keys to functions
    ... The function keys for ... switch that switched off the internal speakers when you inserted ... a 3,5mm jack. ...
    (freebsd-questions)