diff runtime/doc/eval.txt @ 17221:a8fc7d97b54d v8.1.1610

patch 8.1.1610: there is no way to add or load a buffer without side effects commit https://github.com/vim/vim/commit/15e248e37f3925d430f96e945d52d3dc423cdc83 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Jun 30 20:21:37 2019 +0200 patch 8.1.1610: there is no way to add or load a buffer without side effects Problem: There is no way to add or load a buffer without side effects. Solution: Add the bufadd() and bufload() functions.
author Bram Moolenaar <Bram@vim.org>
date Sun, 30 Jun 2019 20:30:05 +0200
parents 6990c1160ea5
children 26e0352613ec
line wrap: on
line diff
--- a/runtime/doc/eval.txt
+++ b/runtime/doc/eval.txt
@@ -2272,8 +2272,10 @@ balloon_split({msg})		List	split {msg} a
 browse({save}, {title}, {initdir}, {default})
 				String	put up a file requester
 browsedir({title}, {initdir})	String	put up a directory requester
+bufadd({name})			Number	add a buffer to the buffer list
 bufexists({expr})		Number	|TRUE| if buffer {expr} exists
 buflisted({expr})		Number	|TRUE| if buffer {expr} is listed
+bufload({expr})			Number	load buffer {expr} if not loaded yet
 bufloaded({expr})		Number	|TRUE| if buffer {expr} is loaded
 bufname({expr})			String	Name of the buffer {expr}
 bufnr({expr} [, {create}])	Number	Number of the buffer {expr}
@@ -3132,6 +3134,14 @@ browsedir({title}, {initdir})
 		When the "Cancel" button is hit, something went wrong, or
 		browsing is not possible, an empty string is returned.
 
+bufadd({name})						*bufadd()*
+		Add a buffer to the buffer list with {name}.
+		If a buffer for file {name} already exists, return that buffer
+		number.  Otherwise return the buffer number of the newly
+		created buffer.  When {name} is an empty string then a new
+		buffer is always created.
+		The buffer will not have' 'buflisted' set.
+
 bufexists({expr})					*bufexists()*
 		The result is a Number, which is |TRUE| if a buffer called
 		{expr} exists.
@@ -3161,6 +3171,15 @@ buflisted({expr})					*buflisted()*
 		{expr} exists and is listed (has the 'buflisted' option set).
 		The {expr} argument is used like with |bufexists()|.
 
+bufload({expr})						*bufload()*
+		Ensure the buffer {expr} is loaded.  When the buffer name
+		refers to an existing file then the file is read.  Otherwise
+		the buffer will be empty.  If the buffer was already loaded
+		then there is no change.
+		If there is an existing swap file for the file of the buffer,
+		there will be no dialog, the buffer will be loaded anyway.
+		The {expr} argument is used like with |bufexists()|.
+
 bufloaded({expr})					*bufloaded()*
 		The result is a Number, which is |TRUE| if a buffer called
 		{expr} exists and is loaded (shown in a window or hidden).