GNU bug report logs - #53629
27.1: add option to change face `mode-line-buffer-id` when mode-line is inactive

Previous Next

Package: emacs;

Reported by: José Júnior <jjnilton <at> gmail.com>

Date: Sat, 29 Jan 2022 23:07:02 UTC

Severity: normal

Tags: moreinfo

Found in version 27.1

Fixed in version 29.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 53629 in the body.
You can then email your comments to 53629 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#53629; Package emacs. (Sat, 29 Jan 2022 23:07:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to José Júnior <jjnilton <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sat, 29 Jan 2022 23:07:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: José Júnior <jjnilton <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 27.1: add option to change face `mode-line-buffer-id` when mode-line
 is inactive
Date: Sat, 29 Jan 2022 17:19:39 -0300
[Message part 1 (text/plain, inline)]
Mode-line has face options for when it's active and inactive but
`mode-line-buffer-id` just allows customization on the active form, please
consider adding the option to allow customizing the face of the
`mode-line-buffer-id` when the mode-line is inactive too.

Thanks.
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#53629; Package emacs. (Sun, 30 Jan 2022 00:26:02 GMT) Full text and rfc822 format available.

Message #8 received at 53629 <at> debbugs.gnu.org (full text, mbox):

From: Drew Adams <drew.adams <at> oracle.com>
To: José Júnior <jjnilton <at> gmail.com>,
 "53629 <at> debbugs.gnu.org" <53629 <at> debbugs.gnu.org>
Subject: RE: [External] : bug#53629: 27.1: add option to change face
 `mode-line-buffer-id` when mode-line is inactive
Date: Sun, 30 Jan 2022 00:24:57 +0000
> Mode-line has face options for when it's
> active and inactive but `mode-line-buffer-id`
> just allows customization on the active form,
> please consider adding the option to allow
> customizing the face of the `mode-line-buffer-id`
> when the mode-line is inactive too.

See library `modeline-win.el'.
Does it do what you're looking for?

It highlights the buffer name in the
mode-line for the selected window.

That is, whichever window is currently
selected, its buffer name in the mode
line is highlighted (using face
`mlw-mode-line-buffer-id-selected-window').

The code is here:

https://www.emacswiki.org/emacs/download/modeline-win.el

It's just a few lines of code.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#53629; Package emacs. (Sun, 30 Jan 2022 16:20:02 GMT) Full text and rfc822 format available.

Message #11 received at 53629 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: José Júnior <jjnilton <at> gmail.com>
Cc: 53629 <at> debbugs.gnu.org
Subject: Re: bug#53629: 27.1: add option to change face
 `mode-line-buffer-id` when mode-line is inactive
Date: Sun, 30 Jan 2022 17:18:51 +0100
José Júnior <jjnilton <at> gmail.com> writes:

> Mode-line has face options for when it's active and inactive but
> `mode-line-buffer-id` just allows customization on the active form,
> please consider adding the option to allow customizing the face of the
> `mode-line-buffer-id` when the mode-line is inactive too.

I'm not quite sure I understand the request.  Do you want to add a new
face for the buffer identification part of the mode line when it's
inactive?

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




Added tag(s) moreinfo. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Sun, 30 Jan 2022 16:20:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#53629; Package emacs. (Sun, 30 Jan 2022 17:11:02 GMT) Full text and rfc822 format available.

Message #16 received at 53629 <at> debbugs.gnu.org (full text, mbox):

From: José Júnior <jjnilton <at> gmail.com>
To: Drew Adams <drew.adams <at> oracle.com>
Cc: "53629 <at> debbugs.gnu.org" <53629 <at> debbugs.gnu.org>
Subject: Re: [External] : bug#53629: 27.1: add option to change face
 `mode-line-buffer-id` when mode-line is inactive
Date: Sun, 30 Jan 2022 13:46:27 -0300
[Message part 1 (text/plain, inline)]
Thanks, I think it helps as the default `mode-line-buffer-id` face of the
active buffer is overridden, and it becomes the "inactive face". I think it
solves this problem, but maybe a custom face in the mode-line faces group
itself would be more accessible.

Another workaround I found was to use the `inverse-video` face option in
the `mode-line-inactive` face. It doesn't give me too much freedom to
customize the face.

On Sat, Jan 29, 2022 at 9:25 PM Drew Adams <drew.adams <at> oracle.com> wrote:

> > Mode-line has face options for when it's
> > active and inactive but `mode-line-buffer-id`
> > just allows customization on the active form,
> > please consider adding the option to allow
> > customizing the face of the `mode-line-buffer-id`
> > when the mode-line is inactive too.
>
> See library `modeline-win.el'.
> Does it do what you're looking for?
>
> It highlights the buffer name in the
> mode-line for the selected window.
>
> That is, whichever window is currently
> selected, its buffer name in the mode
> line is highlighted (using face
> `mlw-mode-line-buffer-id-selected-window').
>
> The code is here:
>
> https://www.emacswiki.org/emacs/download/modeline-win.el
>
> It's just a few lines of code.
>
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#53629; Package emacs. (Sun, 30 Jan 2022 17:11:02 GMT) Full text and rfc822 format available.

Message #19 received at 53629 <at> debbugs.gnu.org (full text, mbox):

From: José Júnior <jjnilton <at> gmail.com>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 53629 <at> debbugs.gnu.org
Subject: Re: bug#53629: 27.1: add option to change face `mode-line-buffer-id`
 when mode-line is inactive
Date: Sun, 30 Jan 2022 13:48:09 -0300
[Message part 1 (text/plain, inline)]
Yes, it's exactly that. If I want to set a different background color for
the `mode-line-buffer-id` when the buffer is inactive, I can't do it with
the faces options of the `mode-line` group.

On Sun, Jan 30, 2022 at 1:18 PM Lars Ingebrigtsen <larsi <at> gnus.org> wrote:

> José Júnior <jjnilton <at> gmail.com> writes:
>
> > Mode-line has face options for when it's active and inactive but
> > `mode-line-buffer-id` just allows customization on the active form,
> > please consider adding the option to allow customizing the face of the
> > `mode-line-buffer-id` when the mode-line is inactive too.
>
> I'm not quite sure I understand the request.  Do you want to add a new
> face for the buffer identification part of the mode line when it's
> inactive?
>
> --
> (domestic pets only, the antidote for overdose, milk.)
>    bloggy blog: http://lars.ingebrigtsen.no
>
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#53629; Package emacs. (Sun, 30 Jan 2022 20:34:02 GMT) Full text and rfc822 format available.

Message #22 received at 53629 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: José Júnior <jjnilton <at> gmail.com>
Cc: 53629 <at> debbugs.gnu.org
Subject: Re: bug#53629: 27.1: add option to change face
 `mode-line-buffer-id` when mode-line is inactive
Date: Sun, 30 Jan 2022 21:33:32 +0100
José Júnior <jjnilton <at> gmail.com> writes:

> Yes, it's exactly that. If I want to set a different background color
> for the `mode-line-buffer-id` when the buffer is inactive, I can't do
> it with the faces options of the `mode-line` group.

Can't you achieve that by redefining `mode-line-buffer-id' to inherit
from mode-line-inactive with the proper shadowings?

If that's not sufficient, you can alter
`mode-line-buffer-identification' to return whatever you wish, so I
don't think another face here is necessary.

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




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#53629; Package emacs. (Mon, 31 Jan 2022 20:09:01 GMT) Full text and rfc822 format available.

Message #25 received at 53629 <at> debbugs.gnu.org (full text, mbox):

From: José Júnior <jjnilton <at> gmail.com>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 53629 <at> debbugs.gnu.org
Subject: Re: bug#53629: 27.1: add option to change face `mode-line-buffer-id`
 when mode-line is inactive
Date: Mon, 31 Jan 2022 17:07:25 -0300
[Message part 1 (text/plain, inline)]
I don't think I can. I've tried changing the face options, but I didn't
find a way to customize it the way I want, with different backgrounds or
font-weight. For example, I can't set the `mode-line-buffer-id` of
`mode-line` face to have bold font and the `mode-line-inactive` to have a
font without bold.

I'm not sure how I can customize the way I want with
`mode-line-buffer-identification` yet, so maybe that's why having another
face to customize the inactive state still makes sense. I also found this
discussion:
https://emacs.stackexchange.com/questions/10033/change-mode-line-buffer-id-face-for-inactive-windows
- but I don't think there's a solution there.

On Sun, Jan 30, 2022 at 5:33 PM Lars Ingebrigtsen <larsi <at> gnus.org> wrote:

> José Júnior <jjnilton <at> gmail.com> writes:
>
> > Yes, it's exactly that. If I want to set a different background color
> > for the `mode-line-buffer-id` when the buffer is inactive, I can't do
> > it with the faces options of the `mode-line` group.
>
> Can't you achieve that by redefining `mode-line-buffer-id' to inherit
> from mode-line-inactive with the proper shadowings?
>
> If that's not sufficient, you can alter
> `mode-line-buffer-identification' to return whatever you wish, so I
> don't think another face here is necessary.
>
> --
> (domestic pets only, the antidote for overdose, milk.)
>    bloggy blog: http://lars.ingebrigtsen.no
>
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#53629; Package emacs. (Mon, 31 Jan 2022 20:10:02 GMT) Full text and rfc822 format available.

Message #28 received at 53629 <at> debbugs.gnu.org (full text, mbox):

From: José Júnior <jjnilton <at> gmail.com>
To: Drew Adams <drew.adams <at> oracle.com>
Cc: "53629 <at> debbugs.gnu.org" <53629 <at> debbugs.gnu.org>
Subject: Re: [External] : bug#53629: 27.1: add option to change face
 `mode-line-buffer-id` when mode-line is inactive
Date: Mon, 31 Jan 2022 17:09:11 -0300
[Message part 1 (text/plain, inline)]
I just noticed that the library doesn't seem to work on the dired buffer,
on other buffers it does seem to work well. Do you know what could be the
cause?

On Sun, Jan 30, 2022 at 1:46 PM José Júnior <jjnilton <at> gmail.com> wrote:

> Thanks, I think it helps as the default `mode-line-buffer-id` face of the
> active buffer is overridden, and it becomes the "inactive face". I think it
> solves this problem, but maybe a custom face in the mode-line faces group
> itself would be more accessible.
>
> Another workaround I found was to use the `inverse-video` face option in
> the `mode-line-inactive` face. It doesn't give me too much freedom to
> customize the face.
>
> On Sat, Jan 29, 2022 at 9:25 PM Drew Adams <drew.adams <at> oracle.com> wrote:
>
>> > Mode-line has face options for when it's
>> > active and inactive but `mode-line-buffer-id`
>> > just allows customization on the active form,
>> > please consider adding the option to allow
>> > customizing the face of the `mode-line-buffer-id`
>> > when the mode-line is inactive too.
>>
>> See library `modeline-win.el'.
>> Does it do what you're looking for?
>>
>> It highlights the buffer name in the
>> mode-line for the selected window.
>>
>> That is, whichever window is currently
>> selected, its buffer name in the mode
>> line is highlighted (using face
>> `mlw-mode-line-buffer-id-selected-window').
>>
>> The code is here:
>>
>> https://www.emacswiki.org/emacs/download/modeline-win.el
>>
>> It's just a few lines of code.
>>
>
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#53629; Package emacs. (Mon, 31 Jan 2022 20:39:02 GMT) Full text and rfc822 format available.

Message #31 received at 53629 <at> debbugs.gnu.org (full text, mbox):

From: Drew Adams <drew.adams <at> oracle.com>
To: José Júnior <jjnilton <at> gmail.com>
Cc: "53629 <at> debbugs.gnu.org" <53629 <at> debbugs.gnu.org>
Subject: RE: [External] : bug#53629: 27.1: add option to change face
 `mode-line-buffer-id` when mode-line is inactive
Date: Mon, 31 Jan 2022 20:38:14 +0000
[Message part 1 (text/plain, inline)]
Hi José. No, I don't know why. I'll take a look (later). I confirm that I see the same thing. Dunno why Dired windows would be an exception.

I just noticed that the library doesn't seem to work on the dired buffer, on other buffers it does seem to work well. Do you know what could be the cause?

See library `modeline-win.el'.
Does it do what you're looking for?

It highlights the buffer name in the
mode-line for the selected window.

That is, whichever window is currently
selected, its buffer name in the mode
line is highlighted (using face
`mlw-mode-line-buffer-id-selected-window').

The code is here:
https://www.emacswiki.org/emacs/download/modeline-win.el<https://urldefense.com/v3/__https:/www.emacswiki.org/emacs/download/modeline-win.el__;!!ACWV5N9M2RV99hQ!fhaUnMpb2nBbq8z6sp8VIKwMVw95_ydxBOJpl_m_pSJiap2TsvVjfpOn0qMCjA_0$>
It's just a few lines of code.
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#53629; Package emacs. (Mon, 31 Jan 2022 20:50:01 GMT) Full text and rfc822 format available.

Message #34 received at 53629 <at> debbugs.gnu.org (full text, mbox):

From: Drew Adams <drew.adams <at> oracle.com>
To: José Júnior <jjnilton <at> gmail.com>
Cc: "53629 <at> debbugs.gnu.org" <53629 <at> debbugs.gnu.org>
Subject: RE: [External] : bug#53629: 27.1: add option to change face
 `mode-line-buffer-id` when mode-line is inactive
Date: Mon, 31 Jan 2022 20:49:09 +0000
[Message part 1 (text/plain, inline)]
Same thing with *info* windows.
I think it has to do with this (from `C-h v mode-line-buffer-identification'):

Mode line construct for identifying the buffer being displayed.
Its default value is ("%12b") with some text properties added.
Major modes that edit things other than ordinary files may change this
(e.g. Info, Dired,...)

I'll take a look later, when I get some time. Thanks for the report.

Hi José. No, I don't know why. I'll take a look (later). I confirm that I see the same thing. Dunno why Dired windows would be an exception.

I just noticed that the library doesn't seem to work on the dired buffer, on other buffers it does seem to work well. Do you know what could be the cause?

See library `modeline-win.el'.
Does it do what you're looking for?

It highlights the buffer name in the
mode-line for the selected window.

That is, whichever window is currently
selected, its buffer name in the mode
line is highlighted (using face
`mlw-mode-line-buffer-id-selected-window').

The code is here:
https://www.emacswiki.org/emacs/download/modeline-win.el<https://urldefense.com/v3/__https:/www.emacswiki.org/emacs/download/modeline-win.el__;!!ACWV5N9M2RV99hQ!fhaUnMpb2nBbq8z6sp8VIKwMVw95_ydxBOJpl_m_pSJiap2TsvVjfpOn0qMCjA_0$>
It's just a few lines of code.
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#53629; Package emacs. (Mon, 31 Jan 2022 20:56:01 GMT) Full text and rfc822 format available.

Message #37 received at 53629 <at> debbugs.gnu.org (full text, mbox):

From: Drew Adams <drew.adams <at> oracle.com>
To: José Júnior <jjnilton <at> gmail.com>
Cc: "53629 <at> debbugs.gnu.org" <53629 <at> debbugs.gnu.org>
Subject: RE: [External] : bug#53629: 27.1: add option to change face
 `mode-line-buffer-id` when mode-line is inactive
Date: Mon, 31 Jan 2022 20:55:23 +0000
[Message part 1 (text/plain, inline)]
Yeah, that's the problem. If I change the setq-default to setq, and if you turn on the mode when a Dired window is selected, then the highlighting works there. I'll have to find a general fix. Thx.

Same thing with *info* windows.
I think it has to do with this (from `C-h v mode-line-buffer-identification'):

Mode line construct for identifying the buffer being displayed.
Its default value is ("%12b") with some text properties added.
Major modes that edit things other than ordinary files may change this
(e.g. Info, Dired,...)

I'll take a look later, when I get some time. Thanks for the report.

Hi José. No, I don't know why. I'll take a look (later). I confirm that I see the same thing. Dunno why Dired windows would be an exception.

I just noticed that the library doesn't seem to work on the dired buffer, on other buffers it does seem to work well. Do you know what could be the cause?

See library `modeline-win.el'.
Does it do what you're looking for?

It highlights the buffer name in the
mode-line for the selected window.

That is, whichever window is currently
selected, its buffer name in the mode
line is highlighted (using face
`mlw-mode-line-buffer-id-selected-window').

The code is here:
https://www.emacswiki.org/emacs/download/modeline-win.el<https://urldefense.com/v3/__https:/www.emacswiki.org/emacs/download/modeline-win.el__;!!ACWV5N9M2RV99hQ!fhaUnMpb2nBbq8z6sp8VIKwMVw95_ydxBOJpl_m_pSJiap2TsvVjfpOn0qMCjA_0$>
It's just a few lines of code.
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#53629; Package emacs. (Wed, 02 Feb 2022 17:17:01 GMT) Full text and rfc822 format available.

Message #40 received at 53629 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: José Júnior <jjnilton <at> gmail.com>
Cc: 53629 <at> debbugs.gnu.org
Subject: Re: bug#53629: 27.1: add option to change face
 `mode-line-buffer-id` when mode-line is inactive
Date: Wed, 02 Feb 2022 18:16:15 +0100
José Júnior <jjnilton <at> gmail.com> writes:

> I'm not sure how I can customize the way I want with
> `mode-line-buffer-identification` yet, so maybe that's why having another face to
> customize the inactive state still makes sense. I also found this discussion:
> https://emacs.stackexchange.com/questions/10033/change-mode-line-buffer-id-face-for-inactive-windows
> - but I don't think there's a solution there.

No, there doesn't seem to be.  I really thought there was a way to get
at whether the window we're making the buffer line for is selected or
not, but there doesn't seem to be?  Anybody know?

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




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#53629; Package emacs. (Wed, 02 Feb 2022 20:05:02 GMT) Full text and rfc822 format available.

Message #43 received at 53629 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 53629 <at> debbugs.gnu.org,
 José Júnior <jjnilton <at> gmail.com>
Subject: Re: bug#53629: 27.1: add option to change face
 `mode-line-buffer-id` when mode-line is inactive
Date: Wed, 02 Feb 2022 22:00:41 +0200
>> I'm not sure how I can customize the way I want with
>> `mode-line-buffer-identification` yet, so maybe that's why having another face to
>> customize the inactive state still makes sense. I also found this discussion:
>> https://emacs.stackexchange.com/questions/10033/change-mode-line-buffer-id-face-for-inactive-windows
>> - but I don't think there's a solution there.
>
> No, there doesn't seem to be.  I really thought there was a way to get
> at whether the window we're making the buffer line for is selected or
> not, but there doesn't seem to be?  Anybody know?

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))




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#53629; Package emacs. (Thu, 03 Feb 2022 19:01:01 GMT) Full text and rfc822 format available.

Message #46 received at 53629 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Juri Linkov <juri <at> linkov.net>
Cc: 53629 <at> debbugs.gnu.org,
 José Júnior <jjnilton <at> gmail.com>
Subject: Re: bug#53629: 27.1: add option to change face
 `mode-line-buffer-id` when mode-line is inactive
Date: Thu, 03 Feb 2022 20:00:31 +0100
Juri Linkov <juri <at> linkov.net> 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




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#53629; Package emacs. (Fri, 04 Feb 2022 03:16:02 GMT) Full text and rfc822 format available.

Message #49 received at 53629 <at> debbugs.gnu.org (full text, mbox):

From: José Júnior <jjnilton <at> gmail.com>
To: Lars Ingebrigtsen <larsi <at> gnus.org>, Drew Adams <drew.adams <at> oracle.com>
Cc: 53629 <at> debbugs.gnu.org, Juri Linkov <juri <at> linkov.net>
Subject: Re: bug#53629: 27.1: add option to change face `mode-line-buffer-id`
 when mode-line is inactive
Date: Fri, 4 Feb 2022 00:15:00 -0300
[Message part 1 (text/plain, inline)]
Thanks, Lars. I tried this approach and it's almost perfect. The only thing
I noticed is that when I use M-x or C-s, and the focus is on the echo area,
the last active buffer (the one I was before pressing M-x or C-s) doesn't
use the `mode-line-buffer-id-active` face.

Example: https://0x0.st/oH5O.png - see that the `mode-line-buffer-id` face
on the right is raised, and I'm not sure where that's coming from, since I
didn't set either to be like that.

```
 '(mode-line ((t (:background "#000000" :foreground "#ffffff"))))
 '(mode-line-buffer-id ((t (:background "white" :foreground "black" :weight
normal))))
 '(mode-line-highlight ((t (:background "yellow" :box nil))))
 '(mode-line-id-inactive ((t (:background "gray10" :foreground "dim
gray"))))
 '(mode-line-inactive ((t (:inherit nil :background "black" :foreground
"dim gray" :inverse-video nil))))
```

Seems the default behavior of emacs is not to change the `mode-line` or
`mode-line-buffer-id` on the buffer that M-x or C-s used, so I think that's
what's missing from this solution.

@Drew Adams <drew.adams <at> oracle.com> might want to check this too. (not sure
if this is the right way to mention people)

On Thu, Feb 3, 2022 at 4:00 PM Lars Ingebrigtsen <larsi <at> gnus.org> wrote:

> Juri Linkov <juri <at> linkov.net> 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
>
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#53629; Package emacs. (Fri, 04 Feb 2022 09:59:01 GMT) Full text and rfc822 format available.

Message #52 received at 53629 <at> debbugs.gnu.org (full text, mbox):

From: martin rudalics <rudalics <at> gmx.at>
To: José Júnior <jjnilton <at> gmail.com>,
 Lars Ingebrigtsen <larsi <at> gnus.org>, Drew Adams <drew.adams <at> oracle.com>
Cc: 53629 <at> debbugs.gnu.org, Juri Linkov <juri <at> linkov.net>
Subject: Re: bug#53629: 27.1: add option to change face `mode-line-buffer-id`
 when mode-line is inactive
Date: Fri, 4 Feb 2022 10:58:08 +0100
> Thanks, Lars. I tried this approach and it's almost perfect. The only thing
> I noticed is that when I use M-x or C-s, and the focus is on the echo area,
> the last active buffer (the one I was before pressing M-x or C-s) doesn't
> use the `mode-line-buffer-id-active` face.

Instead of

>>                        (if (eq (selected-window)
>>                                      (old-selected-window))

try

(if (memq (selected-window) `(,(old-selected-window) ,(minibuffer-selected-window)))

martin




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#53629; Package emacs. (Sat, 05 Feb 2022 02:04:02 GMT) Full text and rfc822 format available.

Message #55 received at 53629 <at> debbugs.gnu.org (full text, mbox):

From: José Júnior <jjnilton <at> gmail.com>
To: martin rudalics <rudalics <at> gmx.at>
Cc: Lars Ingebrigtsen <larsi <at> gnus.org>, 53629 <at> debbugs.gnu.org,
 Drew Adams <drew.adams <at> oracle.com>, Juri Linkov <juri <at> linkov.net>
Subject: Re: bug#53629: 27.1: add option to change face `mode-line-buffer-id`
 when mode-line is inactive
Date: Fri, 4 Feb 2022 23:03:01 -0300
[Message part 1 (text/plain, inline)]
Thanks martin, but it seems that the behavior did not change. Any ideas?

On Fri, Feb 4, 2022 at 6:58 AM martin rudalics <rudalics <at> gmx.at> wrote:

>  > Thanks, Lars. I tried this approach and it's almost perfect. The only
> thing
>  > I noticed is that when I use M-x or C-s, and the focus is on the echo
> area,
>  > the last active buffer (the one I was before pressing M-x or C-s)
> doesn't
>  > use the `mode-line-buffer-id-active` face.
>
> Instead of
>
>  >>                        (if (eq (selected-window)
>  >>                                      (old-selected-window))
>
> try
>
> (if (memq (selected-window) `(,(old-selected-window)
> ,(minibuffer-selected-window)))
>
> martin
>
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#53629; Package emacs. (Sat, 05 Feb 2022 07:48:01 GMT) Full text and rfc822 format available.

Message #58 received at 53629 <at> debbugs.gnu.org (full text, mbox):

From: martin rudalics <rudalics <at> gmx.at>
To: José Júnior <jjnilton <at> gmail.com>
Cc: Lars Ingebrigtsen <larsi <at> gnus.org>, 53629 <at> debbugs.gnu.org,
 Drew Adams <drew.adams <at> oracle.com>, Juri Linkov <juri <at> linkov.net>
Subject: Re: bug#53629: 27.1: add option to change face `mode-line-buffer-id`
 when mode-line is inactive
Date: Sat, 5 Feb 2022 08:47:13 +0100
> Thanks martin, but it seems that the behavior did not change. Any ideas?

I disregarded the useless complication that 'minibuffer-selected-window'
returns nil when the selected window is not a minibuffer window.  Please
try the below.

martin


(defun my-buffer-identification (fmt)
  (list (propertize
	 fmt
	 'face (if (let ((window (selected-window)))
		     (or (eq window (old-selected-window))
			 (and (minibuffer-window-active-p (minibuffer-window))
			      (with-selected-window (minibuffer-window)
				(eq window (minibuffer-selected-window))))))
		   'error
		 'mode-line-buffer-id)
	 'mouse-face 'mode-line-highlight
	 'local-map mode-line-buffer-identification-keymap)))

(setq-default mode-line-buffer-identification
	      '(:eval (my-buffer-identification "%12b")))





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#53629; Package emacs. (Sat, 05 Feb 2022 07:53:02 GMT) Full text and rfc822 format available.

Message #61 received at 53629 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: martin rudalics <rudalics <at> gmx.at>
Cc: 53629 <at> debbugs.gnu.org,
 José Júnior <jjnilton <at> gmail.com>,
 Drew Adams <drew.adams <at> oracle.com>, Juri Linkov <juri <at> linkov.net>
Subject: Re: bug#53629: 27.1: add option to change face
 `mode-line-buffer-id` when mode-line is inactive
Date: Sat, 05 Feb 2022 08:52:46 +0100
martin rudalics <rudalics <at> gmx.at> writes:

> I disregarded the useless complication that 'minibuffer-selected-window'
> returns nil when the selected window is not a minibuffer window.  Please
> try the below.
>
> martin
>
> (defun my-buffer-identification (fmt)
>   (list (propertize
> 	 fmt
> 	 'face (if (let ((window (selected-window)))
> 		     (or (eq window (old-selected-window))
> 			 (and (minibuffer-window-active-p (minibuffer-window))
> 			      (with-selected-window (minibuffer-window)
> 				(eq window (minibuffer-selected-window))))))

Thanks; seems to work fine.  Perhaps we should make this into a utility
function and then document this technique in the manual in the mode line
section?

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




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#53629; Package emacs. (Sat, 05 Feb 2022 12:12:01 GMT) Full text and rfc822 format available.

Message #64 received at 53629 <at> debbugs.gnu.org (full text, mbox):

From: José Júnior <jjnilton <at> gmail.com>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: martin rudalics <rudalics <at> gmx.at>, 53629 <at> debbugs.gnu.org,
 Drew Adams <drew.adams <at> oracle.com>, Juri Linkov <juri <at> linkov.net>
Subject: Re: bug#53629: 27.1: add option to change face `mode-line-buffer-id`
 when mode-line is inactive
Date: Sat, 5 Feb 2022 09:10:44 -0300
[Message part 1 (text/plain, inline)]
Thanks, I think it's perfect now. It would be good to have it documented,
indeed.

On Sat, Feb 5, 2022 at 4:52 AM Lars Ingebrigtsen <larsi <at> gnus.org> wrote:

> martin rudalics <rudalics <at> gmx.at> writes:
>
> > I disregarded the useless complication that 'minibuffer-selected-window'
> > returns nil when the selected window is not a minibuffer window.  Please
> > try the below.
> >
> > martin
> >
> > (defun my-buffer-identification (fmt)
> >   (list (propertize
> >        fmt
> >        'face (if (let ((window (selected-window)))
> >                    (or (eq window (old-selected-window))
> >                        (and (minibuffer-window-active-p
> (minibuffer-window))
> >                             (with-selected-window (minibuffer-window)
> >                               (eq window
> (minibuffer-selected-window))))))
>
> Thanks; seems to work fine.  Perhaps we should make this into a utility
> function and then document this technique in the manual in the mode line
> section?
>
> --
> (domestic pets only, the antidote for overdose, milk.)
>    bloggy blog: http://lars.ingebrigtsen.no
>
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#53629; Package emacs. (Sat, 05 Feb 2022 21:48:01 GMT) Full text and rfc822 format available.

Message #67 received at 53629 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: José Júnior <jjnilton <at> gmail.com>
Cc: martin rudalics <rudalics <at> gmx.at>, 53629 <at> debbugs.gnu.org,
 Drew Adams <drew.adams <at> oracle.com>, Juri Linkov <juri <at> linkov.net>
Subject: Re: bug#53629: 27.1: add option to change face
 `mode-line-buffer-id` when mode-line is inactive
Date: Sat, 05 Feb 2022 22:46:51 +0100
José Júnior <jjnilton <at> gmail.com> writes:

> Thanks, I think it's perfect now. It would be good to have it
> documented, indeed.

I've now added this as mode-line-window-selected-p to Emacs 29 and
documented it in the mode line section of the manual.

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




bug marked as fixed in version 29.1, send any further explanations to 53629 <at> debbugs.gnu.org and José Júnior <jjnilton <at> gmail.com> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Sat, 05 Feb 2022 21:48:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#53629; Package emacs. (Sat, 05 Feb 2022 22:13:01 GMT) Full text and rfc822 format available.

Message #72 received at 53629 <at> debbugs.gnu.org (full text, mbox):

From: José Júnior <jjnilton <at> gmail.com>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: martin rudalics <rudalics <at> gmx.at>, 53629 <at> debbugs.gnu.org,
 Drew Adams <drew.adams <at> oracle.com>, Juri Linkov <juri <at> linkov.net>
Subject: Re: bug#53629: 27.1: add option to change face `mode-line-buffer-id`
 when mode-line is inactive
Date: Sat, 5 Feb 2022 19:11:32 -0300
[Message part 1 (text/plain, inline)]
Thanks!

On Sat, Feb 5, 2022 at 6:47 PM Lars Ingebrigtsen <larsi <at> gnus.org> wrote:

> José Júnior <jjnilton <at> gmail.com> writes:
>
> > Thanks, I think it's perfect now. It would be good to have it
> > documented, indeed.
>
> I've now added this as mode-line-window-selected-p to Emacs 29 and
> documented it in the mode line section of the manual.
>
> --
> (domestic pets only, the antidote for overdose, milk.)
>    bloggy blog: http://lars.ingebrigtsen.no
>
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#53629; Package emacs. (Sun, 06 Feb 2022 18:02:01 GMT) Full text and rfc822 format available.

Message #75 received at 53629 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: martin rudalics <rudalics <at> gmx.at>, 53629 <at> debbugs.gnu.org,
 José Júnior <jjnilton <at> gmail.com>,
 Drew Adams <drew.adams <at> oracle.com>
Subject: Re: bug#53629: 27.1: add option to change face
 `mode-line-buffer-id` when mode-line is inactive
Date: Sun, 06 Feb 2022 19:59:15 +0200
>> Thanks, I think it's perfect now. It would be good to have it
>> documented, indeed.
>
> I've now added this as mode-line-window-selected-p to Emacs 29 and
> documented it in the mode line section of the manual.

Nice!  Now it's used in tab-line.el.  (I'm not sure if it can continue
using the name prefix mode-line- ?)




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#53629; Package emacs. (Sun, 06 Feb 2022 22:49:02 GMT) Full text and rfc822 format available.

Message #78 received at 53629 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Juri Linkov <juri <at> linkov.net>
Cc: martin rudalics <rudalics <at> gmx.at>, 53629 <at> debbugs.gnu.org,
 José Júnior <jjnilton <at> gmail.com>,
 Drew Adams <drew.adams <at> oracle.com>
Subject: Re: bug#53629: 27.1: add option to change face
 `mode-line-buffer-id` when mode-line is inactive
Date: Sun, 06 Feb 2022 23:48:33 +0100
Juri Linkov <juri <at> linkov.net> writes:

> Nice!  Now it's used in tab-line.el.  (I'm not sure if it can continue
> using the name prefix mode-line- ?)

Feel free to rename it to something more general (but not so general
that people start using it instead of `selected-window' 🙃).

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




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#53629; Package emacs. (Tue, 08 Feb 2022 11:50:02 GMT) Full text and rfc822 format available.

Message #81 received at 53629 <at> debbugs.gnu.org (full text, mbox):

From: José Júnior <jjnilton <at> gmail.com>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: martin rudalics <rudalics <at> gmx.at>, 53629 <at> debbugs.gnu.org,
 Drew Adams <drew.adams <at> oracle.com>, Juri Linkov <juri <at> linkov.net>
Subject: Re: bug#53629: 27.1: add option to change face `mode-line-buffer-id`
 when mode-line is inactive
Date: Tue, 8 Feb 2022 08:48:41 -0300
[Message part 1 (text/plain, inline)]
I just noticed that it doesn't seem to work in the `dired` and `info`
windows. Any ideas?

On Sun, Feb 6, 2022 at 7:48 PM Lars Ingebrigtsen <larsi <at> gnus.org> wrote:

> Juri Linkov <juri <at> linkov.net> writes:
>
> > Nice!  Now it's used in tab-line.el.  (I'm not sure if it can continue
> > using the name prefix mode-line- ?)
>
> Feel free to rename it to something more general (but not so general
> that people start using it instead of `selected-window' 🙃).
>
> --
> (domestic pets only, the antidote for overdose, milk.)
>    bloggy blog: http://lars.ingebrigtsen.no
>
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#53629; Package emacs. (Tue, 08 Feb 2022 18:24:02 GMT) Full text and rfc822 format available.

Message #84 received at 53629 <at> debbugs.gnu.org (full text, mbox):

From: martin rudalics <rudalics <at> gmx.at>
To: José Júnior <jjnilton <at> gmail.com>,
 Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 53629 <at> debbugs.gnu.org, Drew Adams <drew.adams <at> oracle.com>,
 Juri Linkov <juri <at> linkov.net>
Subject: Re: bug#53629: 27.1: add option to change face `mode-line-buffer-id`
 when mode-line is inactive
Date: Tue, 8 Feb 2022 19:22:54 +0100
> I just noticed that it doesn't seem to work in the `dired` and `info`
> windows. Any ideas?

'dired' has

  (setq ...
	mode-line-buffer-identification
	(propertized-buffer-identification "%17b"))

and 'info' uses 'Info-set-mode-line'.  You would have to override
these somehow.

martin




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Wed, 09 Mar 2022 12:24:05 GMT) Full text and rfc822 format available.

This bug report was last modified 3 years and 107 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.