Docs for <SID>

13 views
Skip to first unread message

gi1...@gmail.com

unread,
Nov 18, 2020, 8:57:41 PM11/18/20
to vim...@googlegroups.com
Hi All,

Looks like the full expansion of the format of expand("<sfile>") changed
sometime between vim 8.1 and 8.2, and as a result it breaks the way some
scripts (LaTeX-Box, in particular) get the SID.

While tracing this down I realized that docs (Vim 8.2) say:

If you need to get the script number to use in a complicated script,
you can use this function:
function s:SID()
return matchstr(expand('<sfile>'), '<SNR>\zs\d\+\ze_SID$')
endfun

Given that expand('<SID>') does the same thing, perhaps you can
replace/remove the above paragraph?

GI

--
Teacher confiscated a rubber band pistol from his algebra class.
It was weapon of math disruption.

Bram Moolenaar

unread,
Nov 19, 2020, 12:47:27 PM11/19/20
to vim...@googlegroups.com, gi1...@gmail.com

> Looks like the full expansion of the format of expand("<sfile>") changed
> sometime between vim 8.1 and 8.2, and as a result it breaks the way some
> scripts (LaTeX-Box, in particular) get the SID.
>
> While tracing this down I realized that docs (Vim 8.2) say:
>
> If you need to get the script number to use in a complicated script,
> you can use this function:
> function s:SID()
> return matchstr(expand('<sfile>'), '<SNR>\zs\d\+\ze_SID$')
> endfun
>
> Given that expand('<SID>') does the same thing, perhaps you can
> replace/remove the above paragraph?

It's not exactly the same thing, and the example can be clearer. I have
changed it to:

func s:ScriptNumber()
return matchstr(expand('<SID>'), '<SNR>\zs\d\+\ze_')
endfunc

--
Bravely bold Sir Robin, rode forth from Camelot,
He was not afraid to die, Oh Brave Sir Robin,
He was not at all afraid to be killed in nasty ways
Brave, brave, brave, brave Sir Robin.
"Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
Reply all
Reply to author
Forward
0 new messages