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 ?
  • 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 Feb 7 '17 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 Feb 7 '17 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. – Tianxiang Xiong Feb 8 '17 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 Feb 9 '17 at 8:21
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, privacy policy and cookie policy

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