buffer number and python interface

17 views
Skip to first unread message

Ernie Rael

unread,
Dec 29, 2019, 9:11:07 PM12/29/19
to vim...@googlegroups.com
From python, is it *always* true that "vim.buffer[i].number == i" ?

-ernie

Ernie Rael

unread,
Dec 30, 2019, 9:31:33 PM12/30/19
to vim...@googlegroups.com
On 12/29/2019 6:11 PM, Ernie Rael wrote:
> From python, is it *always* true that "vim.buffer[i].number == i" ?
>
> -ernie
>
I've convinced myself that this is true. The docs say

A mapping object providing access to the list of vim buffers.
...
b.number    Buffer number. Can be used as |python-buffers| key.

and the python interface code uses

b = buflist_findnr((int) bnr);

-ernie

Tony Mechelynck

unread,
Dec 30, 2019, 9:42:26 PM12/30/19
to vim_dev
On Tue, Dec 31, 2019 at 3:31 AM Ernie Rael <e...@raelity.com> wrote:
>
> On 12/29/2019 6:11 PM, Ernie Rael wrote:root
To test if it is really _always_ true, test it with invalid values,
for instance -1 or 9999.

Best regards,
Tony.

Tony Mechelynck

unread,
Dec 30, 2019, 10:05:23 PM12/30/19
to Ernie Rael, vim_dev
On Tue, Dec 31, 2019 at 3:48 AM Ernie Rael <e...@raelity.com> wrote:
> I used bwipe as well as some plain invalid numbers. Invalid numbers
> generate errors from vim, so the test couldn't complete; the function
> wouldn't collapse and I guess it's both true and false :-)
>
> -ernie
>
In that case I guess you could put that statement inside a Python
try..except construct and catch the appropriate vim.error

Best regards,
Tony.

Ernie Rael

unread,
Dec 30, 2019, 10:20:46 PM12/30/19
to vim...@googlegroups.com
It's true enough (much better than a politician) for my needs. I'm
working through a bug in some plugin code, Splice - it turns vim into a
great merge tool. There's a variety of stuff that can be simplified by
using the buffer.number for what it is.

Thanks Tony,
-ernie

Reply all
Reply to author
Forward
0 new messages