Subject: Re: bug#53629: 27.1: add option to change face `mode-line-buffer-id` when mode-line is inactive

From: Lars Ingebrigtsen <[email-masked]>
Date: Thu, 03 Feb 2022 20:00:31 +0100

Juri Linkov <[email-masked]> writes:

> tab-line.el uses such trick:
>
>          (face (if (eq buffer (window-buffer))
>                    (if (eq (selected-window) (old-selected-window))
>                        'tab-line-tab-current
>                      'tab-line-tab)
>                  'tab-line-tab-inactive))

Oh, that's smart.

Then we can get the action requested by something like the following:

(progn
  (defun my-buffer-identification (fmt)
    (list (propertize fmt
		      'face (if (eq (selected-window)
				    (old-selected-window))
				'mode-line-buffer-id
			      'error)
		      'mouse-face 'mode-line-highlight
		      'local-map mode-line-buffer-identification-keymap)))
  (setq-default mode-line-buffer-identification
		'(:eval (my-buffer-identification "%12b"))))

(Adjust for the face you want to use.)  Seems to work well for me.

José, does this fix the issue for you, too?

We should probably document this better -- perhaps add some cross
referencing between the selected-window and old-selected-window doc
strings to allow discovery.  And perhaps mention this in the mode line
section, too.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no