On 12/31/2015 6:22 PM, Bram Moolenaar (Vim Github Repository) wrote:
No, the langmap and keymap options relate to the keyboard. Replaying a
register does not involve the keyboard. When replaying a register one
doesn't know where the characters came from, they might be typed or
the
result of something else, e.g. a yank operation.
I wonder how you managed to get characters into a register that
you want to
apply 'keymap' or 'langmap' to. This translation should have
already happened
when typing the characters.
- do ":help russian"
- use the keymap as described there
- insert some russian text
- record a macro @a that inserts some russian text
- play the macor @a
This is a bit vague... Perhaps the problem is that when recording into
a register the keymap/langmap is not applied, resulting in the wrong
characters in the register?
I look at keymap/langmap as a low level operation, which is applied
when
typing on the keyboard, before it goes to the rest of Vim, which is
unaware of this filtering.
It's possible that this interferes with other things, such as terminal
codes and other mappings. It's quite complicated. Many changes in this
area are not backwards compatible and break someone's carefully tuned
setup. I have thought of re-implementing this, but haven't found the
time to dive into it.
Dear Bram,
Of course a cleaner implementation would be desirable
and that could store to a register after applying keymap.
But as of now the typed chars are stored into the register before
applying keymap,
i.e.
//getchar.c:2515
if (keylen > typebuf.tb_maplen)
gotchars(typebuf.tb_buf + typebuf.tb_off
+ typebuf.tb_maplen,
keylen - typebuf.tb_maplen);
is before
//getchar.c:2610
i = ins_typebuf(s, noremap,
So my patch fits to the current implementation by applying the
keymap to
chars in the register.
I also added tests for keymap. There haven't been any so far.
Regarding applying langmap to ':'-CMDLINE
I've found that only patch v7.4.773 had removed the langmap mapping
from
CMDLINE.
For / and ? commands that is good. langmap shouldn't apply, because you
want to find text.
So it should be like for the insert mode, i.e keyboard layout should be
used.
But for :-commands, if langmap is intended to enable russians or greeks
to use vim without the need to switch to an english keyboard layout,
langmap should apply. Otherwise you cannot enter :q, :w, :e,...
commands.
To enter non-english letters in :-commands, e.g. for :s,
one can first search via / or yank and then do ^R/ or ^R".
So this pull request is a modification and not an undo of patch 773.
langmap now also is a better opposite to keymap.
keymap does not apply to :-commands, so langmap should.
I adapted the tests for langmap to fit the changes.
I have also updated the documentation to mention:
- langmap applies to ':'-CMDLINE mode (new)
- keymap applies to non-':'-CMDLINE mode (current)
From my side pull request
https://github.com/vim/vim/pull/543
is ready now.