On Tue, Sep 29, 2009 at 5:35 PM, Kana Natsuno <[email protected]> wrote:
>
> On Wed, 30 Sep 2009 09:23:56 +0900, Charles E Campbell Jr 
> <[email protected]> wrote:
>> You could see if cecutil's SaveUserMaps() and RestoreUserMaps()
>> functions that I wrote will help you.
>
> It uses maparg() to get information on existing key mapping,
> but with maparg(), it's impossible to cover all scenarios
> to use key mappings, as Hari Krishna Dara and I described.
>

I also noticed that map and maparg() fail to even give the right
<rhs>. E.g., try either of the the below maps:

:inoremap <buffer> <Tab> <Tab>
:inoremap <buffer> <Tab> <lt>Tab>

the later is equivalent to (in functionality):

:inoremap <buffer> <expr> <Tab> "<Tab>"

and try the below commands:

:echo maparg('<Tab>', 'i')
<Tab>
:imap <buffer> <Tab>
i  <Tab>       *@<Tab>

You get indistinguishable results.

Regarding the suggestion of reusing the code from the :mksession, this
code explicitly skips some maps, including those with <script> option,
so it is not a complete solution. If we can extend the :map command to
accept an optional scriptID as <script:SID>, then we could output map
commands with the original SID in place, but then there are two
issues:
- You are able to create fresh maps into script context, kind of like
meddling with its encapsulation. However Vim doesn't prevent calling
SID functions so you could argue that this is on the same lines. But
this could give a way to access SID variables which are otherwise not
accessible (not that there is such a need to break script
encapsulation).
- You can't persist such maps across sessions (as the SID may not be
the same across sessions), but this case might not even be useful, so
probably OK.

-- 
Hari

>
> --
> To Vim, or not to Vim.
> http://whileimautomaton.net/
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Raspunde prin e-mail lui