comparison runtime/doc/builtin.txt @ 31004:eb145a4d6bf8 v9.0.0837

patch 9.0.0837: append() reports failure when not appending anything Commit: https://github.com/vim/vim/commit/cd9c8d400c1eb9cbb4ff6a33be02f91a30ab13b2 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Nov 5 23:46:43 2022 +0000 patch 9.0.0837: append() reports failure when not appending anything Problem: append() reports failure when not appending anything. Solution: Only report failure when appending something. (closes https://github.com/vim/vim/issues/11498)
author Bram Moolenaar <Bram@vim.org>
date Sun, 06 Nov 2022 01:00:04 +0100
parents eb2638f278bf
children 5acd6f02ea35
comparison
equal deleted inserted replaced
31003:bcf955fec2e1 31004:eb145a4d6bf8
804 the current buffer. 804 the current buffer.
805 Any type of item is accepted and converted to a String. 805 Any type of item is accepted and converted to a String.
806 {lnum} can be zero to insert a line before the first one. 806 {lnum} can be zero to insert a line before the first one.
807 {lnum} is used like with |getline()|. 807 {lnum} is used like with |getline()|.
808 Returns 1 for failure ({lnum} out of range or out of memory), 808 Returns 1 for failure ({lnum} out of range or out of memory),
809 0 for success. In |Vim9| script an invalid argument or 809 0 for success. When {text} is an empty list zero is returned,
810 negative number results in an error. Example: > 810 no matter the value of {lnum}.
811 In |Vim9| script an invalid argument or negative number
812 results in an error. Example: >
811 :let failed = append(line('$'), "# THE END") 813 :let failed = append(line('$'), "# THE END")
812 :let failed = append(0, ["Chapter 1", "the beginning"]) 814 :let failed = append(0, ["Chapter 1", "the beginning"])
813 815
814 < Can also be used as a |method| after a List, the base is 816 < Can also be used as a |method| after a List, the base is
815 passed as the second argument: > 817 passed as the second argument: >
833 In |Vim9| script an error is given for an invalid {lnum}. 835 In |Vim9| script an error is given for an invalid {lnum}.
834 836
835 If {buf} is not a valid buffer or {lnum} is not valid, an 837 If {buf} is not a valid buffer or {lnum} is not valid, an
836 error message is given. Example: > 838 error message is given. Example: >
837 :let failed = appendbufline(13, 0, "# THE START") 839 :let failed = appendbufline(13, 0, "# THE START")
838 < 840 < However, when {text} is an empty list then no error is given
841 for an invalid {lnum}, since {lnum} isn't actually used.
842
839 Can also be used as a |method| after a List, the base is 843 Can also be used as a |method| after a List, the base is
840 passed as the second argument: > 844 passed as the second argument: >
841 mylist->appendbufline(buf, lnum) 845 mylist->appendbufline(buf, lnum)
842 846
843 847
979 let acmd.group = 'MyGroup' 983 let acmd.group = 'MyGroup'
980 let acmd.event = 'BufEnter' 984 let acmd.event = 'BufEnter'
981 let acmd.bufnr = 5 985 let acmd.bufnr = 5
982 let acmd.cmd = 'call BufEnterFunc()' 986 let acmd.cmd = 'call BufEnterFunc()'
983 call autocmd_add([acmd]) 987 call autocmd_add([acmd])
984 988 <
985 Can also be used as a |method|: > 989 Can also be used as a |method|: >
986 GetAutocmdList()->autocmd_add() 990 GetAutocmdList()->autocmd_add()
987 < 991 <
988 autocmd_delete({acmds}) *autocmd_delete()* 992 autocmd_delete({acmds}) *autocmd_delete()*
989 Deletes a List of autocmds and autocmd groups. 993 Deletes a List of autocmds and autocmd groups.
7871 |bufload()| if needed. 7875 |bufload()| if needed.
7872 7876
7873 To insert lines use |appendbufline()|. 7877 To insert lines use |appendbufline()|.
7874 Any text properties in {lnum} are cleared. 7878 Any text properties in {lnum} are cleared.
7875 7879
7876 {text} can be a string to set one line, or a list of strings 7880 {text} can be a string to set one line, or a List of strings
7877 to set multiple lines. If the list extends below the last 7881 to set multiple lines. If the List extends below the last
7878 line then those lines are added. 7882 line then those lines are added. If the List is empty then
7883 nothing is changed and zero is returned.
7879 7884
7880 For the use of {buf}, see |bufname()| above. 7885 For the use of {buf}, see |bufname()| above.
7881 7886
7882 {lnum} is used like with |setline()|. 7887 {lnum} is used like with |setline()|.
7883 Use "$" to refer to the last line in buffer {buf}. 7888 Use "$" to refer to the last line in buffer {buf}.
8058 8063
8059 {lnum} is used like with |getline()|. 8064 {lnum} is used like with |getline()|.
8060 When {lnum} is just below the last line the {text} will be 8065 When {lnum} is just below the last line the {text} will be
8061 added below the last line. 8066 added below the last line.
8062 {text} can be any type or a List of any type, each item is 8067 {text} can be any type or a List of any type, each item is
8063 converted to a String. 8068 converted to a String. When {text} is an empty List then
8069 nothing is changed and FALSE is returned.
8064 8070
8065 If this succeeds, FALSE is returned. If this fails (most likely 8071 If this succeeds, FALSE is returned. If this fails (most likely
8066 because {lnum} is invalid) TRUE is returned. 8072 because {lnum} is invalid) TRUE is returned.
8067 In |Vim9| script an error is given if {lnum} is invalid. 8073 In |Vim9| script an error is given if {lnum} is invalid.
8068 8074