2

I'd like to be able to see visually whether a window is dedicated. Is there a way that I could add this information to the mode line?

1
  • 1
    The question is too broad or is unclear, or else you need to accept a simple answer such as @lawlist offered. There are many ways one might want to show that - or any other bit of information - in the mode line. Unless you specify exactly what you're looking for, any answer that puts the info in the mode line is acceptable. Suggestion: read the Elisp manual about the mode-line, in particular mode-line variables. That will tell you how you can use one of the variables to add the info you want.
    – Drew
    Jun 24, 2017 at 21:58

1 Answer 1

2

Answering a mode-line question is like opening a Pandora's Box because there are a zillion ways to customize it and people use libraries such as Powerline, etc., and others use the built-in format. That being said, here is a minimal working example that will affect all windows without a subsequently defined mode-line-format. To affect only one buffer, use setq in the target buffer instead of setq-default. To test this, first evaluate the code below, and then evaluate (set-window-dedicated-p (selected-window) t) to turn dedication on and (set-window-dedicated-p (selected-window) nil) to turn dedication off.

(setq-default mode-line-format
  '(:eval
      (if (window-dedicated-p)
        "DEDICATED"
        "NOT-DEDICATED")))
4
  • This command removes all other information from the mode-line on my emacs, and I don't think I'm doing anything very special. I would like to insert this without overwriting the rest of the mode-line configuration.
    – Zorgoth
    Jun 24, 2017 at 21:39
  • Oddly, it doesn't work if I try to let it be only one part of mode-line-format by naively pasting it in. (setq-default mode-line-format '(default stuff custom code default stuff)). If I do that, it always says DEDICATED. If I do exactly what you said, it works, but it overwrites the rest of the mode-line, so it isn't exactly useful.
    – Zorgoth
    Jun 24, 2017 at 21:51
  • I will edit the question to ask something somewhat more specific.
    – Zorgoth
    Jun 25, 2017 at 15:25
  • I figured out how to do what I wanted. I'll accept the answer, but I'll mention that what was useful to me was "(setq mode-line-misc-info (cons '(:eval (if (window-dedicated-p) "DEDICATED" "NOT-DEDICATED")) mode-line-misc-info))"
    – Zorgoth
    Jun 25, 2017 at 15:40

Your Answer

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

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