On Sun, Sep 27, 2009 at 3:04 PM, Kana Natsuno <[email protected]> wrote:
>
> On Sun, 27 Sep 2009 14:58:25 +0900, Hari Krishna Dara <[email protected]>
> wrote:
>> I need to be able to create an imap for <Tab> when my plugin is
>> toggled on, and unmap it when it is toggled off. What I would prefer
>> is to restore the previous map of <Tab> rather than simply unmap it,
>> but there is no straight-forward way to capture the existing map such
>> that it can be restored later. I first ventured into capturing the
>> output of :imap command and extract the <rhs>, but this won't work for
>> many scenarios (including the case of <script>). Even if Vim has a
>> command or function to output a script to recreate the map, it won't
>> work for all scenarios (e.g., the <script>), so I think what I need is
>> a command to create a "copy" of an existing map.
>
> I agree with you on the idea. It's not possible to perfectly copy
> existing key mapping as far as I know - we can get the rhs of a key
> mapping with maparg() or mpcheck() but it's not possible to determine
> whether <buffer>/<expr>/<script>/<silent> were given for the key
> mapping. Alternative way is to parse output of :map commands, but it's
> messy and it's not possible to determine whether <expr>/<silent> were
> given. Even if we can get the information on <expr>/<script>, it's not
> possible to recreate the same key mapping for <script> one.
Very well said and accurate to the point. I didn't realize that
|map-listing| has no information to indicate that a mapping involves
<expr> option. Not surprisingly, the below two appear the same in the
listing:
:map <expr> XX "XX"
:map XX
:map XX "XX"
:map XX
I think this was an oversight on the part of <expr> feature implementation.
>
> Recently I need to copy a key mapping to enhance my plugin. It defines
> another kind of key mappings which is expanded when multiple keys are
> simultaneously pressed. These key mappings can coexist with ordinary
> key mappings even if both {lhs}es conflict with each other, but it's
> a bit difficult or troublesome to resolve conflicts manually. I want to
> resolve conflicts automatically, but it's not possible to realize
> without the way to copy existing key mappings.
I am not clear on your use case. Were you going to backup some maps
and unmap them to help resolve conflicts? Is the functionality of this
plugin somehow similar to my execmap plugin
(http://www.vim.org/scripts/script.php?script_id=598)?
> (I also want a function
> version of :map_l to get the information of a series of key mappings to
> realize the feature.)
>
That would be nice.
--
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
-~----------~----~----~----~------~----~------~--~---