Hi!
[Don't worry, this is for post-1.5.0]
A few times in the past month or two, the issue of whether or not
keymaps should be used has come up. I would like to defend the position
which says: yes, keymaps are good! and suggest an improvement in how
they're used.
Let me just start out by saying that I do not feel we should *force*
keymaps on anyone. Whoever prefers to just switch their keyboard
language should certainly be able to do so.
I'll begin with the disadvantages of using keymaps:
1) It's more code for us to support.
2) The truth is, I can't think of any other disadvantages...
Here are the advantages, IMO:
1) Works everywhere: no need for setting up a keyboard in my esoteric
language every time I open up LyX in some Internet Cafe / foreign
University Lab / etc.
1b) OS-independent: how I switch the keyboard language does not depend
on which OS I'm working on (and indeed, does not depend on that OS's
support for my language).
3) With a keymap, we (the LyX programmers) are in control. Two examples:
(a) Almost always, a keymap switch should be accompanied by a language
switch, or vice-versa. If we use keymaps, we can do this. However, if we
rely on the keyboard switch to happen "outside of" LyX, there's no way
that we can do this: we won't know how to know that the keyboard has
been switched; or we won't know how to switch the keyboard if the
language has been switched. Certainly not in an OS-independent way, and
I'm not even sure that all OSes support these operations. This means
that the user has to do two operations every time she switches
languages: 1. Switch the language; 2. Switch the keyboard.
(b) Similar, but not identical: IMO (and other users on the list have
said as much), when moving the cursor over text, the current
font/language should set itself to the current position of the cursor:
if I have a document with two languages, I'm typing in language X, and
then I move to a different section in language Y, most likely I want to
type there in language Y. If we control the keyboard (as we do with
keymaps), then we can achieve this behavior. If we don't then we can
only half-achieve it (we can switch the language/font to match the local
language/font, but not the keyboard input).
4) Keyboard changes are local to LyX. At least on some systems,
switching the keyboard affects the entire system, not just the current
application. Now, the fact that I'm writing a document in Hebrew in LyX
does not at all mean that I want to type in a Hebrew URL for looking
something up on the web, or that I want the email I'm about to send to
be in Hebrew, etc. With a keymap, whatever language I'm using affects
only LyX, nothing else. You'd be surprised at how annoying the other
behavior could be: when I'm typing in LyX, especially when I'm doing the
final touches, I like to quickly generate the DVI output, see it in
xdvi, and then close it by typing 'Q'. If I switch the keyboard to
Hebrew (without using the keymap), then 'Q' doesn't work anymore!
5) Keyboard shortcuts (in LyX itself) don't change. If the keyboard is
changed at the system level, the usual shortcuts don't work, because the
keyboard has been changed (the combinations are okay, but independent
keys are not: "Alt-m f" the "Alt-m" registers, the "f" doesn't.)
So why am I raising this / what's my operative suggestion?
1) As I said, this issue has come up on a few separate occasions in the
past few months (mainly in connection with RTL languages), and each time
there have been voices dismissing the keymap as unimportant, or even
calling for abolishment of the keymap --- so I just want to explain why
in my opinion it is very necessary, and make sure that we keep support
for the keymap.
2) LyX currently has some problems with multiple languages --- mostly in
terms of the initial setup required by the user. One area where this is
apparent is the keymaps: (a) currently, a user planning to use languages
X and Y must (once) set up the keymaps manually; (b) LyX only supports
two keymaps at the moment. If I want to type English + Hebrew + Arabic,
and I want to use keymaps because keymaps are so great --- I'm stuck.
(c) currently, keymaps are bound quite strongly to RTL (as demonstrated
by the problem that Andrei, a.k.a. GoogleGuy, reported to the list a few
days ago); there's no reason why this should be the case.
So, I would like to (at some point, I may not get to it right away)
implement the following:
*) Every language can optionally have a keymap associated with it
(this would require one more column in lib/languages). If the "use
keyboard map" option in the preferences is on, then switching the
language will automatically switch to the associated keymap.
Specifically, the keymap will no longer have to be bound to the RTL
option. This will therefore solve all three problems mentioned in (2),
as well as achieve most of the advantages mentioned in advantage #3.
Users who do not want to use a keymap can just turn the option off (I
think that's the default). The only remaining issue would be if for any
reason (and I'm not sure there is one), someone wants to switch a keymap
*independently* of language switches. For that, if we decide it's
necessary, we could still keep around the commands / options / lfuns for
switching keymaps, and we could just give them the semantics of
"override language keymap until turned off", or something like that.
I don't think this would be too much work, either.
How does this sound?
Dov