diff options
author | Bram Moolenaar <Bram@vim.org> | 2019-08-24 22:14:58 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2019-08-24 22:14:58 +0200 |
commit | a8eee21e75324d199acb1663cb5009e03014a13a (patch) | |
tree | 7214b321e35fa081b9be19cd5373731bca478ca8 /runtime/doc | |
parent | 4119309d70c7fc32637e77f2e84c185ad1768892 (diff) | |
download | vim-git-a8eee21e75324d199acb1663cb5009e03014a13a.tar.gz |
patch 8.1.1924: using empty string for current buffer is unexpectedv8.1.1924
Problem: Using empty string for current buffer is unexpected.
Solution: Make the argument optional for bufname() and bufnr().
Diffstat (limited to 'runtime/doc')
-rw-r--r-- | runtime/doc/eval.txt | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index 12e4d0920..9a00dd329 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -2335,8 +2335,8 @@ 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} +bufname([{expr}]) String Name of the buffer {expr} +bufnr([{expr} [, {create}]]) Number Number of the buffer {expr} bufwinid({expr}) Number window ID of buffer {expr} bufwinnr({expr}) Number window number of buffer {expr} byte2line({byte}) Number line number at byte count {byte} @@ -3217,9 +3217,10 @@ bufloaded({expr}) *bufloaded()* Can also be used as a |method|: > let loaded = 'somename'->bufloaded() -bufname({expr}) *bufname()* +bufname([{expr}]) *bufname()* The result is the name of a buffer, as it is displayed by the ":ls" command. + If {expr} is omitted the current buffer is used. If {expr} is a Number, that buffer number's name is given. Number zero is the alternate buffer for the current window. If {expr} is a String, it is used as a |file-pattern| to match @@ -3251,7 +3252,7 @@ bufname({expr}) *bufname()* Obsolete name: buffer_name(). *bufnr()* -bufnr({expr} [, {create}]) +bufnr([{expr} [, {create}]]) The result is the number of a buffer, as it is displayed by the ":ls" command. For the use of {expr}, see |bufname()| above. @@ -3259,7 +3260,7 @@ bufnr({expr} [, {create}]) {create} argument is present and not zero, a new, unlisted, buffer is created and its number is returned. bufnr("$") is the last buffer: > - :let last_buffer = bufnr("$") + :let last_buffer = bufnr("$") < The result is a Number, which is the highest buffer number of existing buffers. Note that not all buffers with a smaller number necessarily exist, because ":bwipeout" may have removed @@ -7201,7 +7202,7 @@ prompt_setcallback({buf}, {expr}) *prompt_setcallback()* that was entered at the prompt. This can be an empty string if the user only typed Enter. Example: > - call prompt_setcallback(bufnr(''), function('s:TextEntered')) + call prompt_setcallback(bufnr(), function('s:TextEntered')) func s:TextEntered(text) if a:text == 'exit' || a:text == 'quit' stopinsert @@ -7227,7 +7228,7 @@ prompt_setprompt({buf}, {text}) *prompt_setprompt()* {text} to end in a space. The result is only visible if {buf} has 'buftype' set to "prompt". Example: > - call prompt_setprompt(bufnr(''), 'command: ') + call prompt_setprompt(bufnr(), 'command: ') < prop_ functions are documented here: |text-prop-functions|. |