patch 8.2.1347: cannot easily get the script ID

Problem:    Cannot easily get the script ID.
Solution:   Support expand('<SID>').
This commit is contained in:
Bram Moolenaar
2020-08-01 20:45:11 +02:00
parent 491799be50
commit 909443028b
4 changed files with 38 additions and 7 deletions

View File

@ -1167,6 +1167,10 @@ When executing an autocommand or a user command, it will run in the context of
the script it was defined in. This makes it possible that the command calls a
local function or uses a local mapping.
In case the value is used in a context where <SID> cannot be correctly
expanded, use the expand() function: >
let &includexpr = expand('<SID>') .. 'My_includeexpr()'
Otherwise, using "<SID>" outside of a script context is an error.
If you need to get the script number to use in a complicated script, you can