Mercurial > vim
comparison src/testdir/script_util.vim @ 30687:f936d46cc9c1 v9.0.0678
patch 9.0.0678: using exclamation marks on :function
Commit: https://github.com/vim/vim/commit/97f0eb169bf805c372b13c6bc9a03da2e75e3354
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Oct 6 19:49:13 2022 +0100
patch 9.0.0678: using exclamation marks on :function
Problem: Using exclamation marks on :function.
Solution: Use :func and :endfunc as usual.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 06 Oct 2022 21:00:04 +0200 |
parents | 792398a9fe39 |
children |
comparison
equal
deleted
inserted
replaced
30686:08d086d76489 | 30687:f936d46cc9c1 |
---|---|
46 " | 46 " |
47 " Make a temporary script file from the function a:funcname, ":source" it, and | 47 " Make a temporary script file from the function a:funcname, ":source" it, and |
48 " delete it afterwards. However, if an exception is thrown the file may remain, | 48 " delete it afterwards. However, if an exception is thrown the file may remain, |
49 " the caller should call DeleteTheScript() afterwards. | 49 " the caller should call DeleteTheScript() afterwards. |
50 let s:script_name = '' | 50 let s:script_name = '' |
51 function! ExecAsScript(funcname) | 51 func ExecAsScript(funcname) |
52 " Make a script from the function passed as argument. | 52 " Make a script from the function passed as argument. |
53 let s:script_name = MakeScript(a:funcname) | 53 let s:script_name = MakeScript(a:funcname) |
54 | 54 |
55 " Source and delete the script. | 55 " Source and delete the script. |
56 exec "source" s:script_name | 56 exec "source" s:script_name |
57 call delete(s:script_name) | 57 call delete(s:script_name) |
58 let s:script_name = '' | 58 let s:script_name = '' |
59 endfunction | 59 endfunc |
60 | 60 |
61 function! DeleteTheScript() | 61 func DeleteTheScript() |
62 if s:script_name | 62 if s:script_name |
63 call delete(s:script_name) | 63 call delete(s:script_name) |
64 let s:script_name = '' | 64 let s:script_name = '' |
65 endif | 65 endif |
66 endfunc | 66 endfunc |