Closed GoogleCodeExporter closed 9 years ago
The whole point of <SID> is that the corresponding name is not visible from
outside its defining script. IMHO using what you propose would defeat this
goal. To pass a name visible from outside the script, don't use <SID>, use
<Plug>MyScriptName_ — or even start your function, command, or global
variable name with just MyScriptName_ where MyScriptName is your script's name
and where the underscore is there to prevent name collision with a different
script whose name would start in the same way.
It is possible, however, to determine manually what <SID> means inside a given
script, as follows:
1. Make sure the script has been run at least once in the present Vim session.
2. Find that script in the output of :scriptnames — the line with that
script's name starts with a number, which is the "script number" of that script
for the duration of the present session.
3. If, for instance, that script's number is 25, then the <SID> of that script
is <SNR>25_ (with the underscore at the end) where <SNR> is a special code
which should not collide with anything that your keyboard can normally produce.
See ":help <SID>" for a ddetailed discussion. How to find back the current
script's number _in vimscript code_, rather than manually, has been discussed
in the past, and I think that a way of doing it was found, but I don't remember
the details. Maybe they've been written up as an article on
http://vim.wikia.com/ (or maybe not), maybe you could try searching that wiki.
Best regards,
Tony.
--
There's more than one way to skin a cat:
Way number 27 -- Use an electric sander.
Original comment by antoine....@gmail.com
on 8 Sep 2012 at 11:54
<SID> as it is should remain unchanged.
I am interested in the public interface for my plugin, that is the names meant
to be visible outside the script.
I am looking for a way to include "MyScriptName_..." prefix for such names
whithout hard-coding it. I would like to be able to use an expression in-place
of the prefix, that returns the script name (the same way <SID> returns the
script ID, which is why I first thought about it), and I would like to use such
a substitution expression in my:
- mapping definitions, after the <Plug> key
- command names
- :python commands (and maybe other interfaces too)
- global function names, if any,
- global variables for plugin user settings/configuration
- signs, even highlights, etc
An even better approach would be if Vim would allow script author to redefine
the value of the substitution expression, the same way a user can re-define
<Leader>. The script name would be only the default value.
In this way, if either the author or the user decides the file should be
renamed (perhaps to avoid a conflict, or just to start a fork for an existing
plug-in), all the public interface adjusts automatically with the new name.
PS:
Te get the current value of <SID> I would do:
:map <Plug>Some-UUID-here <SID>
:echo "Script ID: " . maparg('<Plug>Some-UUID-here')
:unmap <Plug>Some-UUID-here
Original comment by terminatorul@gmail.com
on 11 Sep 2012 at 12:55
> In this way, if either the author or the user decides the file should be
> renamed (perhaps to avoid a conflict, or just to start a fork for an existing
> plug-in), all the public interface adjusts automatically with the new name.
This is a one-time action that hardly ever occurs; and it can be already solved
via a simple :%s// command. Also, all existing plugins would need to be
modified before one could benefit from this.
I'm sorry, but I don't see how this could be useful in relation to the
implementation, testing, and documentation effort. Please provide additional
arguments or consider closing this request.
Original comment by sw...@ingo-karkat.de
on 11 Sep 2012 at 1:04
Ok
I have no more arguments...
Original comment by terminatorul@gmail.com
on 11 Sep 2012 at 2:15
Original comment by chrisbr...@googlemail.com
on 30 Sep 2014 at 6:16
Original issue reported on code.google.com by
terminatorul@gmail.com
on 8 Sep 2012 at 5:45