Loading ...
Sorry, an error occurred while loading the content.

Buffer- or window-local function execution (like getbufvar())

Expand Messages
  • Kim Silkeb√¶kken
    Hi, I m the developer of Powerline, and I ve recently stumbled upon an issue which makes it hard to implement some kinds of functionality for statuslines.
    Message 1 of 1 , Nov 19, 2012

      I'm the developer of Powerline, and I've recently stumbled upon an issue which makes it hard to implement some kinds of functionality for statuslines. Here's a description of the issue:

      In the development version of Powerline I would like to be able to generate the entire statusline in an external function (i.e. the filename, encoding, fugitive branch, etc.). I'm currently using the %!...() statusline item which allows the statusline to be generated in a function.

      The problem with this is that anything evaluated in this function is evaluated in the *currently selected buffer*, instead of the buffer/window that the statusline actually belongs to. The side effect of this is that the statuslines for all the windows get the information for the current window (i.e. if you have a split window all statuslines will contain information from the currently selected window).

      It is possible to evaluate functions in the buffer/window that the statusline belongs to with %{...} statusline items, but these items take forever being evaluated if they contain Python code, and they don't allow colors or other options being returned from the external function. It is also possible using vim's statusline items (like %f, %h, etc.) but since the statusline is generated externally in order to trim away information if the statusline gets too long this doesn't work in my case.

      A solution to this problem could be to run the external function like this (pseudo-code): setl stl=%!Powerline(winnr(0))

      By passing the window number to the statusline function for each window, it is possible to get window-local information like the fileencoding and stuff using getwinvar() in the external function. But I haven't been able to find a solution that works for functions. So my question is: Is there any way of executing a function in the context of a specific window or buffer, like callbuffunction(<bufnr>, myfunction)?

      If not, do you guys have any suggestions to how I could circumvent this limitation and generate window-specific statuslines using the %!...() statusline item?

      You received this message from the "vim_use" 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
    Your message has been successfully submitted and would be delivered to recipients shortly.