Skip to content

Commit 69ff43e

Browse files
committed
👍 Add appendbufline() and deletebufline() to buffer-function
1 parent 73cbff8 commit 69ff43e

File tree

2 files changed

+62
-70
lines changed

2 files changed

+62
-70
lines changed

denops_std/function/_generated.ts

Lines changed: 0 additions & 70 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

denops_std/function/buffer.ts

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,41 @@ export interface GetBufInfoDictArg {
4949
bufmodified?: boolean;
5050
}
5151

52+
/**
53+
* Like `append()` but append the text in buffer **{buf}**.
54+
*
55+
* This function works only for loaded buffers. First call
56+
* `bufload()` if needed.
57+
*
58+
* For the use of **{buf}**, see `bufname()`.
59+
*
60+
* **{lnum}** is the line number to append below. Note that using
61+
* `line()` would use the current buffer, not the one appending
62+
* to. Use "$" to append at the end of the buffer. Other string
63+
* values are not supported.
64+
*
65+
* On success 0 is returned, on failure 1 is returned.
66+
* In `Vim9` script an error is given for an invalid **{lnum}**.
67+
*
68+
* If **{buf}** is not a valid buffer or **{lnum}** is not valid, an
69+
* error message is given. Example:
70+
*
71+
* :let failed = appendbufline(13, 0, "# THE START")
72+
*
73+
* Can also be used as a `method` after a List, the base is
74+
* passed as the second argument:
75+
*
76+
* mylist->appendbufline(buf, lnum)
77+
*/
78+
export async function appendbufline(
79+
denops: Denops,
80+
buf: BufNameArg,
81+
lnum: BufLnumArg,
82+
text: string | string[],
83+
): Promise<number> {
84+
return await denops.call("appendbufline", buf, lnum, text) as number;
85+
}
86+
5287
/**
5388
* Add a buffer to the buffer list with name **{name}** (must be a
5489
* String).
@@ -295,6 +330,33 @@ export async function bufwinnr(
295330
return await denops.call("bufwinnr", buf) as number;
296331
}
297332

333+
/**
334+
* Delete lines **{first}** to **{last}** (inclusive) from buffer **{buf}**.
335+
* If **{last}** is omitted then delete line **{first}** only.
336+
* On success 0 is returned, on failure 1 is returned.
337+
*
338+
* This function works only for loaded buffers. First call
339+
* `bufload()` if needed.
340+
*
341+
* For the use of **{buf}**, see `bufname()` above.
342+
*
343+
* **{first}** and **{last}** are used like with `getline()`. Note that
344+
* when using `line()` this refers to the current buffer. Use "$"
345+
* to refer to the last line in buffer **{buf}**.
346+
*
347+
* Can also be used as a `method`:
348+
*
349+
* GetBuffer()->deletebufline(1)
350+
*/
351+
export async function deletebufline(
352+
denops: Denops,
353+
buf: BufNameArg,
354+
first: BufLnumArg,
355+
last?: BufLnumArg,
356+
): Promise<number> {
357+
return await denops.call("deletebufline", buf, first, last) as number;
358+
}
359+
298360
/**
299361
* Get information about buffers as a List of Dictionaries.
300362
*

0 commit comments

Comments
 (0)