aboutsummaryrefslogtreecommitdiff
path: root/runtime
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2022-11-01 20:21:48 +0800
committerGitHub <noreply@github.com>2022-11-01 20:21:48 +0800
commitc46d46e9f11a9960fcf9c498ecc72be4c416cfa5 (patch)
tree914333828d1f082a3dcc12c00219c6117c7f4498 /runtime
parentc3aba403c6091a56c517e60beb73d9873d4bb8af (diff)
downloadrneovim-c46d46e9f11a9960fcf9c498ecc72be4c416cfa5.tar.gz
rneovim-c46d46e9f11a9960fcf9c498ecc72be4c416cfa5.tar.bz2
rneovim-c46d46e9f11a9960fcf9c498ecc72be4c416cfa5.zip
vim-patch:8.2.2343: Vim9: return type of readfile() is any (#20896)
Problem: Vim9: return type of readfile() is any. Solution: Add readblob() so that readfile() can be expected to always return a list of strings. (closes vim/vim#7671) https://github.com/vim/vim/commit/c423ad77ed763c11ba67729bbf63c1cf0915231f Co-authored-by: Bram Moolenaar <Bram@vim.org>
Diffstat (limited to 'runtime')
-rw-r--r--runtime/doc/builtin.txt22
-rw-r--r--runtime/doc/usr_41.txt1
2 files changed, 20 insertions, 3 deletions
diff --git a/runtime/doc/builtin.txt b/runtime/doc/builtin.txt
index 226ae80599..8ffe9d54a4 100644
--- a/runtime/doc/builtin.txt
+++ b/runtime/doc/builtin.txt
@@ -349,6 +349,7 @@ pyxeval({expr}) any evaluate |python_x| expression
rand([{expr}]) Number get pseudo-random number
range({expr} [, {max} [, {stride}]])
List items from {expr} to {max}
+readblob({fname}) Blob read a |Blob| from {fname}
readdir({dir} [, {expr}]) List file names in {dir} selected by {expr}
readfile({fname} [, {type} [, {max}]])
List get list of lines from file {fname}
@@ -6036,6 +6037,14 @@ rand([{expr}]) *rand()*
Can also be used as a |method|: >
seed->rand()
<
+
+readblob({fname}) *readblob()*
+ Read file {fname} in binary mode and return a |Blob|.
+ When the file can't be opened an error message is given and
+ the result is an empty |Blob|.
+ Also see |readfile()| and |writefile()|.
+
+
*readdir()*
readdir({directory} [, {expr}])
Return a list with file and directory names in {directory}.
@@ -6070,6 +6079,7 @@ readdir({directory} [, {expr}])
Can also be used as a |method|: >
GetDirName()->readdir()
<
+
*readfile()*
readfile({fname} [, {type} [, {max}]])
Read file {fname} and return a |List|, each line of the file
@@ -6081,8 +6091,6 @@ readfile({fname} [, {type} [, {max}]])
- When the last line ends in a NL an extra empty list item is
added.
- No CR characters are removed.
- When {type} contains "B" a |Blob| is returned with the binary
- data of the file unmodified.
Otherwise:
- CR characters that appear before a NL are removed.
- Whether the last line ends in a NL or not does not matter.
@@ -6099,6 +6107,9 @@ readfile({fname} [, {type} [, {max}]])
Note that without {max} the whole file is read into memory.
Also note that there is no recognition of encoding. Read a
file into a buffer if you need to.
+ Deprecated (use |readblob()| instead): When {type} contains
+ "B" a |Blob| is returned with the binary data of the file
+ unmodified.
When the file can't be opened an error message is given and
the result is an empty list.
Also see |writefile()|.
@@ -8907,7 +8918,12 @@ win_execute({id}, {command} [, {silent}]) *win_execute()*
have unexpected side effects. Use |:noautocmd| if needed.
Example: >
call win_execute(winid, 'syntax enable')
-<
+< Doing the same with `setwinvar()` would not trigger
+ autocommands and not actually show syntax highlighting.
+
+ When window {id} does not exist then no error is given and
+ an empty string is returned.
+
Can also be used as a |method|, the base is passed as the
second argument: >
GetCommand()->win_execute(winid)
diff --git a/runtime/doc/usr_41.txt b/runtime/doc/usr_41.txt
index 6d139643d6..8abc5bdf06 100644
--- a/runtime/doc/usr_41.txt
+++ b/runtime/doc/usr_41.txt
@@ -818,6 +818,7 @@ System functions and manipulation of files:
setenv() set an environment variable
hostname() name of the system
readfile() read a file into a List of lines
+ readblob() read a file into a Blob
readdir() get a List of file names in a directory
writefile() write a List of lines or Blob into a file