From 0680b5218e29f2ebb947d61210d8775ff720f8bb Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Mon, 3 Aug 2020 16:25:12 -0400 Subject: vim-patch:8.1.2341: not so easy to interrupt a script programatically Problem: Not so easy to interrupt a script programatically. Solution: Add the interrupt() function. (Yasuhiro Matsumoto, closes vim/vim#2834) https://github.com/vim/vim/commit/67a2deb9cb4ac2224cb1e4d240a5d0659f036264 --- runtime/doc/eval.txt | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'runtime/doc') diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index efb6272e58..448885296d 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -2224,6 +2224,7 @@ inputsecret({prompt} [, {text}]) String like input() but hiding the text insert({list}, {item} [, {idx}]) List insert {item} in {list} [before {idx}] +interrupt() none interrupt script execution invert({expr}) Number bitwise invert isdirectory({directory}) Number |TRUE| if {directory} is a directory isinf({expr}) Number determine if {expr} is infinity value @@ -5412,6 +5413,19 @@ insert({list}, {item} [, {idx}]) *insert()* Note that when {item} is a |List| it is inserted as a single item. Use |extend()| to concatenate |Lists|. +interrupt() *interrupt()* + Interrupt script execution. It works more or less like the + user typing CTRL-C, most commands won't execute and control + returns to the user. This is useful to abort execution + from lower down, e.g. in an autocommand. Example: > + :function s:check_typoname(file) + : if fnamemodify(a:file, ':t') == '[' + : echomsg 'Maybe typo' + : call interrupt() + : endif + :endfunction + :au BufWritePre * call s:check_typoname(expand('')) + invert({expr}) *invert()* Bitwise invert. The argument is converted to a number. A List, Dict or Float argument causes an error. Example: > -- cgit