patch 9.0.0634: evaluating "expr" options has more overhead than needed

Problem:    Evaluating "expr" options has more overhead than needed.
Solution:   Use call_simple_func() for 'foldtext', 'includeexpr', 'printexpr',
            "expr" of 'spellsuggest', 'diffexpr', 'patchexpr', 'balloonexpr',
            'formatexpr', 'indentexpr' and 'charconvert'.
This commit is contained in:
Bram Moolenaar
2022-10-01 19:43:52 +01:00
parent b850c39676
commit a4e0b9785e
24 changed files with 174 additions and 74 deletions

View File

@ -158,13 +158,16 @@ currently specified printdevice: >
If you change this option, using a function is an easy way to avoid having to
escape all the spaces. Example: >
:set printexpr=PrintFile(v:fname_in)
:function PrintFile(fname)
: call system("ghostview " .. a:fname)
: call delete(a:fname)
:set printexpr=PrintFile()
:function PrintFile()
: call system("ghostview " .. v:fname_in)
: call delete(v:fname_in)
: return v:shell_error
:endfunc
It is more efficient if the option is set to just a function call,
see |expr-option-function|.
Be aware that some print programs return control before they have read the
file. If you delete the file too soon it will not be printed. These programs
usually offer an option to have them remove the file when printing is done.