AnswerBun.com

Coloured active mode line only when many windows

Emacs Asked by Toothrot on December 14, 2020

I am reluctantly using a coloured active mode line to
distinguish it from inactive mode lines, but it occurred to me
that it might be possible to reserve its colouring for times
when there are more than one window in the frame (when there
could be some doubt as to which is the active window). Any tips
on how to do this would be appreciated.

One Answer

Here is a slight varation of a previous answer of mine:

https://emacs.stackexchange.com/a/26345/2287

CAVEAT:  In addition to the buffer-list-update-hook, it may be helpful to add the function ml-update-all to additional hooks; e.g., it is possible to change the mode-line(s) and the color of the mini-buffer text when entering/exiting the mini-buffer ....

(defvar ml-selected-window nil "Doc-string.")

(defun ml-record-selected-window ()
  (setq ml-selected-window (selected-window)))

(defun ml-update-all ()
  (force-mode-line-update t))

(add-hook 'post-command-hook 'ml-record-selected-window)

(add-hook 'buffer-list-update-hook 'ml-update-all)

(setq-default mode-line-format
  '(:eval
      (cond
        ((and (eq ml-selected-window (selected-window))
              (one-window-p))
          (propertize "ACTIVE -- ONE (1) WINDOW" 'face '(:foreground "red")))
        ((and (eq ml-selected-window (selected-window))
              (not (one-window-p)))
          (propertize "ACTIVE -- MANY WINDOWS" 'face '(:foreground "blue")))
        (t
          "INACTIVE"))))

Here is a link to the opening thread on the Emacs Devel mailing list from 10/26/2019 entitled "Let mode-line packages distinguish the selected-window", wherein some of the thread participants provide Lisp variations (examples) to programmatically distinguish the selected window when the mode-line is updated:

https://lists.gnu.org/archive/html/emacs-devel/2019-10/msg01041.html

Answered by lawlist on December 14, 2020

Add your own answers!

Related Questions

Blank menus with Athena / Lucid

1  Asked on December 31, 2020 by tastytea

   

How to clear the eshell

6  Asked on December 24, 2020 by startec

 

org-agenda not showing any todos

1  Asked on December 20, 2020 by stevenmurray

   

Configuring emacs gdb behavior

0  Asked on December 17, 2020 by onye

 

Where find good json formater and validation?

1  Asked on December 17, 2020 by a_subscriber

   

Enlarge pictures in image-dired

1  Asked on December 16, 2020 by calculus

 

Coloured active mode line only when many windows

1  Asked on December 14, 2020 by toothrot

   

Copy-text-to-clipboard-link

1  Asked on December 12, 2020 by jens-lange

   

How to get “:size” from font-spec

1  Asked on December 11, 2020 by enze-chi

 

Getting w3 to work

0  Asked on December 10, 2020 by 0x1a4

 

Wish to define specific defcustom entries

0  Asked on December 9, 2020 by jean-louis

   

Ask a Question

Get help from others!

© 2022 AnswerBun.com. All rights reserved. Sites we Love: PCI Database, MenuIva, UKBizDB, Menu Kuliner, Sharing RPP