Re: [vim/vim] Feature Request: can use setbufvar() to set window options before buffer has a window (Issue #21089)

h_east (Vim Github Repository) <[email protected]>
Newsgroups gmane.editors.vim.devel
Message-ID <vim/vim/issues/21089/[email protected]>
h-east left a comment (vim/vim#21089)

> The docuement states that window "variable" can't be changed. 'number' is
> an "option".

You are right, my quote was misleading. The documentation of `setbufvar()` is
inaccurate here and I will fix it: setting a window option only works when a
window in the current tab page displays the buffer. Otherwise the temporary
autocommand window is used and the value is dropped. 'buftype' worked because
it is a buffer option, and replacing `curbuf` is enough for that. As for
`getbufvar()`, it returns the current window's value, so it does not show that
the buffer holds a window option.

What makes this more than a small addition is where the values live.
Window-local options are stored in wininfo entries per (window, buffer) pair,
not per buffer. A buffer that was never displayed has no entry and gets the
global window values on first display. So `setbufvar()` would need a new
per-buffer pending value, plus a rule for which one wins when a wininfo entry
also exists.

For the use case, a buffer-local autocommand applies the options at the moment
the buffer gets a window:

```vim
autocmd BufWinEnter <buffer=N> setlocal nonumber
```

Once the window exists, `setwinvar()` or `win_execute()` is the direct way.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/vim/vim/issues/21089#issuecomment-5352400045
You are receiving this because you are subscribed to this thread.

Message ID: <vim/vim/issues/21089/[email protected]>

-- 
-- 
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 visit https://groups.google.com/d/msgid/vim_dev/vim/vim/issues/21089/5352400045%40github.com.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.