patch 8.2.3900: it is not easy to use a script-local function for an option
Problem: It is not easy to use a script-local function for an option.
Solution: recognize s: and <SID> at the start of the expression. (Yegappan
Lakshmanan, closes #9401)
diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt
index 845351d..f0939e6 100644
--- a/runtime/doc/options.txt
+++ b/runtime/doc/options.txt
@@ -1225,6 +1225,11 @@
Vim does not try to send a message to an external debugger (Netbeans
or Sun Workshop).
+ If the expression starts with s: or |<SID>|, then it is replaced with
+ the script ID (|local-function|). Example: >
+ set bexpr=s:MyBalloonExpr()
+ set bexpr=<SID>SomeBalloonExpr()
+<
The expression will be evaluated in the |sandbox| when set from a
modeline, see |sandbox-option|.
This option cannot be set in a modeline when 'modelineexpr' is off.
@@ -3596,6 +3601,11 @@
When the expression evaluates to non-zero Vim will fall back to using
the internal format mechanism.
+ If the expression starts with s: or |<SID>|, then it is replaced with
+ the script ID (|local-function|). Example: >
+ set formatexpr=s:MyFormatExpr()
+ set formatexpr=<SID>SomeFormatExpr()
+<
The expression will be evaluated in the |sandbox| when set from a
modeline, see |sandbox-option|. That stops the option from working,
since changing the buffer text is not allowed.
@@ -4438,6 +4448,11 @@
found. Allows doing "gf" on the name after an 'include' statement.
Also used for |<cfile>|.
+ If the expression starts with s: or |<SID>|, then it is replaced with
+ the script ID (|local-function|). Example: >
+ set includeexpr=s:MyIncludeExpr(v:fname)
+ set includeexpr=<SID>SomeIncludeExpr(v:fname)
+<
The expression will be evaluated in the |sandbox| when set from a
modeline, see |sandbox-option|.
This option cannot be set in a modeline when 'modelineexpr' is off.
@@ -4511,6 +4526,11 @@
The expression is evaluated with |v:lnum| set to the line number for
which the indent is to be computed. The cursor is also in this line
when the expression is evaluated (but it may be moved around).
+ If the expression starts with s: or |<SID>|, then it is replaced with
+ the script ID (|local-function|). Example: >
+ set indentexpr=s:MyIndentExpr()
+ set indentexpr=<SID>SomeIndentExpr()
+<
The expression must return the number of spaces worth of indent. It
can return "-1" to keep the current indent (this means 'autoindent' is
used for the indent).