Hi Bram,

On Thu, Nov 18, 2021 at 5:57 AM Bram Moolenaar <[email protected]> wrote:
>
>
> > How do we get all text-properties of a specific buffer?
> >
> > In the examples you use `line('$')` but the function doesn't accept a
> > buffer number. Currently the only way to obtain the number of lines in
> > a buffer is through `getbufinfo(bufnr)[0].linecount` but this is a bit
> > heavy considering how much data `getbufinfo()` could return. So
> > wouldn't it be more efficient to accept `'$'` directly in `end_lnum`?
> >
> > For example: `prop_list(1, {'bufnr': 4, 'end_lnum': '$', 'id': [123]})`.
>
> We try to stay away from arguments with mixed types.  Accepting both a
> number and a string makes it harder to give good error messages.
>

The existing buffer related functions appendbufline(),
deletebufline(), getbufline()
and setbufline() already accept "$" to refer to the last line in a buffer.
I can modify prop_list() to also accept '$' for 'end_lnum'.

Regards,
Yegappan

>
> Getting the number of lines in a buffer is a generic thing.  line()
> already takes an optional window ID argument.  It's logical to also
> accept a buffer number.
>
>         line({expr}, {winid}, {bufnr})
>
> However, that is ambiguous, the {winid} would be ignored when using the
> {bufnr}.  Perhaps it's better to use:
>
>         line({expr}, {id}, {id-is-bufnr})
>
> When the third argument is omitted or FALSE, the {id} is used as the
> {winid} like before.  When it is TRUE then {id} is used as {bufnr}.
> So for your example you can use: line('$', bufnr, 1).
> How about that?
>
> An alternative would be to add a bufline() function. Advantage is that
> we can drop the window related items, since a buffer by itself does not
> have a cursor position or visible lines.
>

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/CAAW7x7m3wq7SUPkvUV3UWg3_QsxwYdugxJbO%3D2Hx7cJbByCtSg%40mail.gmail.com.

Raspunde prin e-mail lui