Hello Bram,

Now I've changed the langmap implementation in this pull request, too (https://github.com/vim/vim/pull/543). Building and running make in testdir worked locally (on archlinux, apart from test87, but only because archlinux has python 3 as default (TypeError->ValueError)). I don't know wether the fact, that not all Travis CI builds succeeded, is related to my changes.
Please review and merge.

Thanks.
Roland.


On 1/5/2016 3:46 PM, Roland Puntaier wrote:
On 1/3/2016 3:35 PM, Bram Moolenaar wrote:
Roland Puntaier wrote:

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.
Sorry, but this is not the right solution.

Did you see the change that Christian Brabandt made, sent to the vim-dev
list on July 25 last year?  This also indicates what is wrong: need to
apply langmap before checking for matching mappings.

So, what needs to be done is in vgetorpeek() to apply langmap to the
head of the typeahead buffer and put the result in a copy-buffer.  Then
use this copy-buffer to check for mappings and otherwise get the
character from.  Then gotchars() will record the characters after
applying langmap and replaying the register will work.
The calls to LANGMAP_ADJUST() in other places of the code have to be
removed.
This also fixes the problem with multi-byte characters that Christian
solved.

This is not easy, but we need to do this properly, otherwise we'll get a
sequence of slightly incompatible changes that is annoying for users.
I've now looked into the vim-dev entry by Christian Brabandt you've mentioned.

https://groups.google.com/forum/#!topic/vim_dev/cqYj7seoEWg

It references

    https://github.com/vim/vim/issues/297
https://groups.google.com/forum/#!msg/vim_dev/5D1WSL2gj-A/OgCBNZQEHNEJ

I also browsed through langmap search results.

From this I have added some test to test_mapping.in. Changes are between
CHANGED_START and CHANGED_END
....

Correcting FAIL_keymap_register was the goal of this pull request.
I have an english keyboard layout. I'm interested in the keymap feature,
not in the langmap feature.

But since I'm at it I can also tackle the langmap issues.
It will probably take some time to finish, though,
depending on how much time I will have available for it.


--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- You received this message because you are subscribed to the Google Groups "vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui