Loading ...
Sorry, an error occurred while loading the content.

Re: [vimdev] Proposal for defining mappings in plugins and other scripts

Expand Messages
  • Bram Moolenaar
    ... But private to what? is not a word that clearly defines what it s for. ... Hmm, I get the idea. However, the rhs= and lhs= make it a bit
    Message 1 of 18 , Oct 13, 2000
      Charles Campbell wrote:

      > Thus saith Bram Moolenaar:
      > > Would <private> work different from <SID> then? Or is it just the name?
      > Just the name; private refers to purpose, sid (presumably script identifier)
      > refers to method of implementation.

      But private to what? <private> is not a word that clearly defines what it's

      > Whew, my head was spinning after all that (map <buffer> , map <local>,
      > noremap <script>). What about
      > map|noremap|etc [<{lhs|rhs}={buffer,script,local,global}[,{lhs|rhs}={buffer,script,local,global}]>] lhsmap rhsmap
      > where [...] is optional
      > {...} pick one
      > lhs restrictions apply to where map is available to be used,
      > rhs restrictions apply to where maps will be expanded from.

      Hmm, I get the idea. However, the "rhs=" and "lhs=" make it a bit
      complicated. And I don't understand what "local" and "global" would stand
      for. what would they do?

      A variant that looks a bit nicer to me:

      :map [<buffer>|<script>] lhs [<buffer>|<script>] rhs

      Using <buffer> before lhs means the mapping is local to the current buffer.
      Using <script> before the lhs means the mapping is local to the script. Only
      items in the script will expand it.

      OK so far.

      <buffer> before the rhs means, eh, only remap mappings local to a buffer here?
      Doesn't sound too useful.
      <script> before the rhs means to only remap key sequences for a mapping local
      to the script.

      The problem here lies in the implementation. When looking for mappings to
      expand, how can Vim know from which script some key sequence came from? It
      would mean that for every mapped character, Vim would need to remember the ID
      of the script that expanded it. Complicated...

      I think the idea to use <SID> is in fact simpler: You can put it in mappings
      you want to keep local to the script. It also works in the rhs. It's easy to
      see which mapping is triggered where.

      Women are probably the main cause of free software starvation.

      /// Bram Moolenaar Bram@... http://www.moolenaar.net \\\
      \\\ Vim: http://www.vim.org ICCF Holland: http://iccf-holland.org ///
    Your message has been successfully submitted and would be delivered to recipients shortly.