On 24/07/11 09:41, ZyX wrote:
Reply to message «Re: Use and meaning of<plug>»,
sent 08:08:49 24 July 2011, Sunday
by Tony Mechelynck:

The whole<SID>  thing is meant to allow creating mappings and functions
which are only visible from within the script where they were created
(i.e., not in other scripts, not at the command-line, but can be used in
autocommands defined in that script).<SID>  can also be used in the
{rhs} of a mapping created in the same script, to allow some kind of
restricted access to script-local functions.
Wrong.<SID>  mappings are normally visible: check out :map<SNR>: for me it
shows two mappings from align and one from vimrc. Same for functions: they all
are global, even anonymous ones. s: for functions and<SID>  for functions and
mappings both only create prefix that should be unique. If you get somewhere a
script number and substitute<SID>  with<SNR>{SID}_ everything will work
normally:
     call<SNR>107_dosurround('"')
removes surrounding '"' in my vim. Same technique works for {lhs}, but if you
redefine script functions in this way it will be assigned that script context
where it was defined, not that mentioned after<SNR>. You can't redefine
anonymous functions, but you can use call() to call them without having a
reference.

The only script-local thing is s: dictionary: I do not know how to access it
without a debugger or without passing it somewhere.

By "visible", I actually meant "accessible". Since the script-number isn't known in advance, and mlay change between sessions, there is no easy way to access mappings etc. defined with <SID> at the command-line, and even less so from a different script (I'll concede that there are a few not-so-easy ways to do it). As I said, you can access them if another mapping defined in the same script, with <SID> in its {rhs}, intentionally makes them accessible in some way.


Best regards,
Tony.
--
If a listener nods his head when you're explaining your program, wake
him up.

--
You received this message from the "vim_use" 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

Reply via email to