2

I am developing a feature to adapt a mode-line to the width of the window. I have developped it so far using buffer-local variables to store the state of the mode-line, however, when I open the same buffer in several windows they all share the same mode-line state even if they have different window widths.

To solve that I would need window-local variables instead of buffer-local, but it seems that Emacs only provides make-variable-buffer-local and make-variable-frame-local.

  • Is there a way of emulating window-local variables for my use-case ?
  • Is there any thread in Emacs developpers mailing lists discussing this issue ?
  • More specifically, would Emacs maintainers be opened to this being implemented ?
4
  • Perhaps you could write mode-line constructs which utilise the window parameters you are interested in, rather than trying to maintain a desired state for your mode-line (and consequently needing to update it whenever the window configuration changes) ?
    – phils
    Commented Feb 7, 2017 at 9:08
  • 1
    "Is there any thread in Emacs developpers mailing lists discussing this issue ?" You should search the mailing list archives to find out for yourself. If you have already done so, you should indicate what you've tried.
    – phils
    Commented Feb 7, 2017 at 9:10
  • Would window parameters (essentially metadata) do what you need? Note that make-variable-frame-local is marked obsolete and will be removed in the next version of Emacs; the documentation encourages use of frame parameters instead. Commented Feb 8, 2017 at 0:06
  • Thanks phlis and Tianxiang Xiong for pointing me to window parameters ! If you can add a custom one, put anything you want in it and having it unique to each window then yes, this is definitely what I'm looking for :D Make an answer with it and I will validate it :)
    – deb0ch
    Commented Feb 9, 2017 at 8:21

1 Answer 1

3

Save your data as a window-parameter. It will force you to use :eval inside your mode-line, but that's not something to be afraid of.

If you want to discuss changes to the "core" Emacs features (like adding window-local variables), then the emacs-devel mailing-list is the place to do it. In this particular case I don't think there's much chance of success since the history points at a movemewnt in the other direction (we used to have frame-local variables, but these have been dropped in favor of frame-parameter).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.