On Thu, Oct 1, 2009 at 4:32 PM, Kana Natsuno <[email protected]> wrote:
>
> On Fri, 02 Oct 2009 06:46:13 +0900, Hari Krishna Dara <[email protected]> 
> wrote:
>> I went ahead and did a POC for this feature and am attaching the
>> patch. This adds a new set of commands such as :dupmap (for "duplicate
>> mapping") and it seems to work nicely for a few simple cases that I
>> tried. The same do_map() function also handles abbreviations, so in
>> theory we could easily extend this to take care of abbreviations (by
>> adding commands such as :dupabbr) also, though not sure how useful
>> that would be.
>
> It sounds great, but I have two suggestions.
>
>> Here is a list of all the new commands:
>>
>> :dupmap           {lhs} {rhs}         |mapmode-nvo|           *:dup*  
>> *:dupmap*
>> :ndup[map]  {lhs} {rhs}               |mapmode-n|             *:ndup* 
>> *:nupmap*
>> :vdup[map]  {lhs} {rhs}               |mapmode-v|             *:vdup* 
>> *:vupmap*
>> :xdup[map]  {lhs} {rhs}               |mapmode-x|             *:xdup* 
>> *:xupmap*
>> :sdup[map]  {lhs} {rhs}               |mapmode-s|             *:snor* 
>> *:supmap*
>> :odup[map]  {lhs} {rhs}               |mapmode-o|             *:odup* 
>> *:oupmap*
>> :dup[map]!  {lhs} {rhs}               |mapmode-ic|            *:dup!* 
>> *:dupmap!*
>> :idup[map]  {lhs} {rhs}               |mapmode-i|             *:idup* 
>> *:iupmap*
>> :ldup[map]  {lhs} {rhs}               |mapmode-l|             *:ldup* 
>> *:lupmap*
>> :cdup[map]  {lhs} {rhs}               |mapmode-c|             *:cdup* 
>> *:cupmap*
>
> It seems to be confusing because the meaning of {rhs} is completely different
> from other :map commands.  It should be named {newlhs}.

Yes, I realized that while I was typing the message and did mention
this (you didn't quote that part, so can't see it above), but I didn't
just want to go back to recreate the patch at that time.

>
> And IMHO, functions are better than Ex commands for this functionality.
> Because the main usage of copying a key mapping is for scripts to process many
> key mappings which are given dynamically, so functions are easy to use for the
> purpose.  Even it's possible to process with the following command
> ":execute 'dupmap' a:lhs a:newlhs", it's a bit troublesome to deal with 
> special
> characters such as <Space> (not escaped by <> notation) in a:lhs and a:newlhs.
>
> So I prefer "mapcopy({lhs}, {newlhs}, {modes})" to ":dupmap {lhs} {newlhs}".
>

How is this different from existing scenarios in which :map needs to
be done created using :exec (there is no equivalent function for :map
either). Regarding <Space>, are you saying that using physical space
(" ") instead of <Space> causes the issue? A physical space would need
to be escaped anyway, so it is always better to use <Space>. Can you
give an example where using :exec is really a problem?

BTW, in case someone wants to try this patch out without having to
apply it and rebuild, I uploaded my windows gvimd.exe here (about 4M
in size): http://haridara.googlepages.com/gvimd.exe

-- 
Thanks,
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