Hi Bram,

On Thu, Nov 18, 2021 at 9:12 AM Bram Moolenaar <[email protected]> wrote:
>
>
> > 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'.
>
> Yeah, we used to do this in the past, but now that we have added more
> type checking it's probably better to stop doing it like this.
>
> Using a very large number works, although it's not the nicest.
> Perhaps we could use -1, as a negative number is relative to the end?
> So -2 would be last-but-one line.  Might be useful?
> It's at least existing, see :help list-index.
>

I have updated the PR to support negative numbers for end_lnum to refer
to a line from the end of the buffer.

- Yegappan

-- 
-- 
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/CAAW7x7ntKMtWAQRkeJnxieuwq2ppz3muT2b%2BR3ZnhMJJ65Fyew%40mail.gmail.com.

Raspunde prin e-mail lui