GNU bug report logs - #77715
[PATCH] Add ring-bell functions for mode line and header line.

Previous Next

Package: emacs;

Reported by: Elijah Gabe Pérez <eg642616 <at> gmail.com>

Date: Thu, 10 Apr 2025 17:56:02 UTC

Severity: normal

Tags: patch

To reply to this bug, email your comments to 77715 AT debbugs.gnu.org.

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#77715; Package emacs. (Thu, 10 Apr 2025 17:56:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Elijah Gabe Pérez <eg642616 <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Thu, 10 Apr 2025 17:56:02 GMT) Full text and rfc822 format available.

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

From: Elijah Gabe Pérez <eg642616 <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: [PATCH] Add ring-bell functions for mode line and header line.
Date: Thu, 10 Apr 2025 11:55:20 -0600
[Message part 1 (text/plain, inline)]
Tags: patch

This feature flashes the current mode-line face (mode-line-active) once,
this is intended to be used in `ring-bell-function', but it can be used
for other purposes.

There have been third-party packages that make this, however many of
them diverge either in features or in faces.

I think Emacs should have had this built-in.

[0001-Add-ring-bell-functions-for-mode-line-and-header-lin.patch (text/patch, attachment)]
[Message part 3 (text/plain, inline)]
-- 
                                          - E.G via GNU Emacs and Org.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#77715; Package emacs. (Thu, 10 Apr 2025 18:07:02 GMT) Full text and rfc822 format available.

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

From: Ship Mints <shipmints <at> gmail.com>
To: Elijah Gabe Pérez <eg642616 <at> gmail.com>
Cc: 77715 <at> debbugs.gnu.org
Subject: Re: bug#77715: [PATCH] Add ring-bell functions for mode line and
 header line.
Date: Thu, 10 Apr 2025 14:06:09 -0400
[Message part 1 (text/plain, inline)]
On Thu, Apr 10, 2025 at 1:56 PM Elijah Gabe Pérez <eg642616 <at> gmail.com>
wrote:

> Tags: patch
>
> This feature flashes the current mode-line face (mode-line-active) once,
> this is intended to be used in `ring-bell-function', but it can be used
> for other purposes.
>
> There have been third-party packages that make this, however many of
> them diverge either in features or in faces.
>
> I think Emacs should have had this built-in.
>

An implementation like the one below protects from erroneously leaving
behind remapped faces:

  (defun my/flash-faces (interval faces &rest specs)
    (let ((cookies (mapcar
                    (lambda (face) (face-remap-add-relative face specs))
                    faces)))
      (unwind-protect
          (sit-for interval)
        (mapc #'face-remap-remove-relative cookies))))

  (defun my/ring-bell-function ()
    (my/flash-faces my:mode-line-ring-bell-interval ; I use 0.05
                    my:mode-line-ring-bell-faces ; I use '(internal-border
tab-bar mode-line-active mode-line-inactive)
                    :background my:mode-line-ring-bell-backround)) ; I use
"Firebrick" (I could have used the foreground from 'error)

  (setq ring-bell-function (if my:mode-line-ring-bell-interval ; I allow my
users to disable this
                               #'my/ring-bell-function
                             nil))
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#77715; Package emacs. (Thu, 10 Apr 2025 18:41:01 GMT) Full text and rfc822 format available.

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

From: Drew Adams <drew.adams <at> oracle.com>
To: Elijah Gabe Pérez <eg642616 <at> gmail.com>,
 "77715 <at> debbugs.gnu.org" <77715 <at> debbugs.gnu.org>
Subject: RE: [External] : bug#77715: [PATCH] Add ring-bell functions for mode
 line and header line.
Date: Thu, 10 Apr 2025 18:40:08 +0000
> There have been third-party packages that make this, however many of
> them diverge either in features or in faces.
> 
> I think Emacs should have had this built-in.

One alternative (it could be built-in):

https://www.emacswiki.org/emacs/download/echo-bell.el

It uses a defcustom instead of a defface, to define the background color for the string shown. The string is also a defcustom: "♪♪♪♪♪♪♪♪♪" by default. A third option is the number of seconds to show the string.


Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#77715; Package emacs. (Thu, 10 Apr 2025 18:54:02 GMT) Full text and rfc822 format available.

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

From: Elijah Gabe Pérez <eg642616 <at> gmail.com>
To: Drew Adams via "Bug reports for GNU Emacs, the Swiss army knife of text
 editors" <bug-gnu-emacs <at> gnu.org>
Cc: "77715 <at> debbugs.gnu.org" <77715 <at> debbugs.gnu.org>,
 Ship Mints <shipmints <at> gmail.com>, Drew Adams <drew.adams <at> oracle.com>
Subject: Re: bug#77715: [PATCH] Add ring-bell functions for mode line and
 header line.
Date: Thu, 10 Apr 2025 12:53:46 -0600
Drew Adams via "Bug reports for GNU Emacs, the Swiss army knife of text
editors" <bug-gnu-emacs <at> gnu.org> writes:

>> There have been third-party packages that make this, however many of
>> them diverge either in features or in faces.
>> 
>> I think Emacs should have had this built-in.
>
> One alternative (it could be built-in):
>
> https://www.emacswiki.org/emacs/download/echo-bell.el
>
> It uses a defcustom instead of a defface, to define the background color for the string shown. The string is also a defcustom: "♪♪♪♪♪♪♪♪♪" by default. A third option is the number of seconds to show the string.

I'm not sure about using the echo area, when working with multiple
windows (and on large screens), the eyes tend to be more focused on
where the cursor or window is.

Another alternative would be flash other faces too, such as Ship config
does.  I have it almost ready.

-- 
                                          - E.G via GNU Emacs and Org.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#77715; Package emacs. (Thu, 10 Apr 2025 18:54:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#77715; Package emacs. (Thu, 10 Apr 2025 21:48:01 GMT) Full text and rfc822 format available.

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

From: Drew Adams <drew.adams <at> oracle.com>
To: Elijah Gabe Pérez <eg642616 <at> gmail.com>, "Drew Adams via
 Bug reports for GNU Emacs, the Swiss army knife of text editors"
 <bug-gnu-emacs <at> gnu.org>
Cc: "77715 <at> debbugs.gnu.org" <77715 <at> debbugs.gnu.org>,
 Ship Mints <shipmints <at> gmail.com>
Subject: RE: [External] : Re: bug#77715: [PATCH] Add ring-bell functions for
 mode line and header line.
Date: Thu, 10 Apr 2025 21:46:52 +0000
> I'm not sure about using the echo area, when working with multiple
> windows (and on large screens), the eyes tend to be more focused on
> where the cursor or window is.

When Emacs dings it's typically due to a user error.

Where do you see the error message? In the echo area.

Putting the attention-grabbing "flash" or whatever
in the echo area draws your attention to it, where
you see the msg telling you what happened.

Why draw or keep the user's attention _away_ from
that message? The user error might have little or
nothing to do with the text at the cursor of the
selected window.

Draw the user's attention _from_ there to the helpful
message.


Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#77715; Package emacs. (Thu, 10 Apr 2025 21:48:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#77715; Package emacs. (Thu, 10 Apr 2025 21:58:02 GMT) Full text and rfc822 format available.

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

From: Drew Adams <drew.adams <at> oracle.com>
To: Drew Adams <drew.adams <at> oracle.com>, "eg642616 <at> gmail.com"
 <eg642616 <at> gmail.com>, "77715 <at> debbugs.gnu.org" <77715 <at> debbugs.gnu.org>
Cc: "shipmints <at> gmail.com" <shipmints <at> gmail.com>
Subject: RE: [External] : bug#77715: [PATCH] Add ring-bell functions for mode
 line and header line.
Date: Thu, 10 Apr 2025 21:57:37 +0000
I wrote:

> When Emacs dings it's typically due to a user error.
> 
> Where do you see the error message? In the echo area.
> 
> Putting the attention-grabbing "flash" or whatever
> in the echo area draws your attention to it, where
> you see the msg telling you what happened.
> 
> Why draw or keep the user's attention _away_ from
> that message? The user error might have little or
> nothing to do with the text at the cursor of the
> selected window.
> 
> Draw the user's attention _from_ there to the helpful
> message.

`visible-bell' has been around forever. Flashing
the entire frame (or as the Emacs manual says, "the
whole screen") is overkill, and it doesn't direct
your attention to the error message. Similar problem
with the alternatives I think you're considering,
even if they're less overkill than `visible-bell'
behavior.

A modest attention-grabber, out of the way in the 
echo area is better, IMO.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#77715; Package emacs. (Fri, 11 Apr 2025 03:02:02 GMT) Full text and rfc822 format available.

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

From: Elijah Gabe Pérez <eg642616 <at> gmail.com>
To: Drew Adams via "Bug reports for GNU Emacs, the Swiss army knife of text
 editors" <bug-gnu-emacs <at> gnu.org>
Cc: "77715 <at> debbugs.gnu.org" <77715 <at> debbugs.gnu.org>,
 "shipmints <at> gmail.com" <shipmints <at> gmail.com>,
 Drew Adams <drew.adams <at> oracle.com>
Subject: Re: bug#77715: [PATCH] Add ring-bell functions for mode line and
 header line.
Date: Thu, 10 Apr 2025 21:01:33 -0600
[Message part 1 (text/plain, inline)]
Drew Adams via "Bug reports for GNU Emacs, the Swiss army knife of text
editors" <bug-gnu-emacs <at> gnu.org> writes:

> I wrote:
>
>> When Emacs dings it's typically due to a user error.
>> 
>> Where do you see the error message? In the echo area.
>> 
>> Putting the attention-grabbing "flash" or whatever
>> in the echo area draws your attention to it, where
>> you see the msg telling you what happened.
>> 
>> Why draw or keep the user's attention _away_ from
>> that message? The user error might have little or
>> nothing to do with the text at the cursor of the
>> selected window.
>> 
>> Draw the user's attention _from_ there to the helpful
>> message.
>
> `visible-bell' has been around forever. Flashing
> the entire frame (or as the Emacs manual says, "the
> whole screen") is overkill, and it doesn't direct
> your attention to the error message. Similar problem
> with the alternatives I think you're considering,
> even if they're less overkill than `visible-bell'
> behavior.
>
> A modest attention-grabber, out of the way in the 
> echo area is better, IMO.

I think these features could coexist together, it wouldn't hurt.

Flash the mode (or header) line for bell it is something that people
have wanted to have, see packages such as mode-line-bell, doom-themes
(both in MELPA), and nano-bell.

I made my own implementation of echo-bell:
[0001-Add-ring-bell-function-for-flash-faces.-bug-77715.patch (text/x-patch, attachment)]
[Message part 3 (text/plain, inline)]
-- 
                                          - E.G via GNU Emacs and Org.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#77715; Package emacs. (Fri, 11 Apr 2025 03:02:03 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#77715; Package emacs. (Fri, 11 Apr 2025 12:02:01 GMT) Full text and rfc822 format available.

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

From: Ship Mints <shipmints <at> gmail.com>
To: Elijah Gabe Pérez <eg642616 <at> gmail.com>
Cc: "Drew Adams via Bug reports for GNU Emacs,
 the Swiss army knife of text editors" <bug-gnu-emacs <at> gnu.org>,
 "77715 <at> debbugs.gnu.org" <77715 <at> debbugs.gnu.org>,
 Drew Adams <drew.adams <at> oracle.com>
Subject: Re: bug#77715: [PATCH] Add ring-bell functions for mode line and
 header line.
Date: Fri, 11 Apr 2025 08:00:43 -0400
[Message part 1 (text/plain, inline)]
On Thu, Apr 10, 2025 at 11:01 PM Elijah Gabe Pérez <eg642616 <at> gmail.com>
wrote:

> Drew Adams via "Bug reports for GNU Emacs, the Swiss army knife of text
> editors" <bug-gnu-emacs <at> gnu.org> writes:
>
> > I wrote:
> >
> >> When Emacs dings it's typically due to a user error.
> >>
> >> Where do you see the error message? In the echo area.
> >>
> >> Putting the attention-grabbing "flash" or whatever
> >> in the echo area draws your attention to it, where
> >> you see the msg telling you what happened.
> >>
> >> Why draw or keep the user's attention _away_ from
> >> that message? The user error might have little or
> >> nothing to do with the text at the cursor of the
> >> selected window.
> >>
> >> Draw the user's attention _from_ there to the helpful
> >> message.
> >
> > `visible-bell' has been around forever. Flashing
> > the entire frame (or as the Emacs manual says, "the
> > whole screen") is overkill, and it doesn't direct
> > your attention to the error message. Similar problem
> > with the alternatives I think you're considering,
> > even if they're less overkill than `visible-bell'
> > behavior.
> >
> > A modest attention-grabber, out of the way in the
> > echo area is better, IMO.
>
> I think these features could coexist together, it wouldn't hurt.
>
> Flash the mode (or header) line for bell it is something that people
> have wanted to have, see packages such as mode-line-bell, doom-themes
> (both in MELPA), and nano-bell.
>
> I made my own implementation of echo-bell:


I think the term duration is better than length when describing time
intervals.

I still prefer the unwind-protected sit-for method that guarantees the
remaps are removed to the one with the timer where I've experienced errors
intervening with a race condition creating new cookies that are not
removed.  Try mashing C-g with your timer implementation and you'll see it.

I also prefer the implementation that I proposed that takes a list of faces
to flash rather than hard-code an assumption about what users want to
flash.  Then this isn't tied to the mode line if that's not what people
want.  Is a new face really necessary just to implement a flash?  The
implementation I proposed allows the user to specify any face attributes to
define what they want for a flash.  I wouldn't use this feature without it
being more reliable and flexible.
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#77715; Package emacs. (Fri, 11 Apr 2025 12:02:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#77715; Package emacs. (Fri, 11 Apr 2025 18:19:02 GMT) Full text and rfc822 format available.

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

From: Elijah Gabe Pérez <eg642616 <at> gmail.com>
To: Ship Mints <shipmints <at> gmail.com>
Cc: 77715 <at> debbugs.gnu.org, drew.adams <at> oracle.com
Subject: Re: bug#77715: [PATCH] Add ring-bell functions for mode line and
 header line.
Date: Fri, 11 Apr 2025 12:18:14 -0600
[Message part 1 (text/plain, inline)]
Ship Mints <shipmints <at> gmail.com> writes:
> I think the term duration is better than length when describing time intervals.

I agree.

> I still prefer the unwind-protected sit-for method that guarantees the remaps are removed to the one with
> the timer where I've experienced errors intervening with a race condition creating new cookies that are
> not removed.  Try mashing C-g with your timer implementation and you'll see it.

The problem with using sit-for is that it delays the message displayed
(usually "Quit") until timer stops (or if there is an input), it look
like Emacs froze.

Anyway, it changed it for use sit-for instead.

> Is a new face really necessary just to implement a flash?  The implementation I proposed
> allows the user to specify any face attributes to define what they want for a flash.  I wouldn't use this
> feature without it being more reliable and flexible.

I think that adding a new face for this would be better, it makes custom
themes set it and change it dynamically; of course, the user can change
face attributes freely.

[0001-Add-ring-bell-function-for-flash-faces.-bug-77715.patch (text/x-patch, attachment)]
[Message part 3 (text/plain, inline)]

-- 
                                          - E.G via GNU Emacs and Org.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#77715; Package emacs. (Fri, 11 Apr 2025 18:24:01 GMT) Full text and rfc822 format available.

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

From: Ship Mints <shipmints <at> gmail.com>
To: Elijah Gabe Pérez <eg642616 <at> gmail.com>
Cc: 77715 <at> debbugs.gnu.org, drew.adams <at> oracle.com
Subject: Re: bug#77715: [PATCH] Add ring-bell functions for mode line and
 header line.
Date: Fri, 11 Apr 2025 14:22:43 -0400
[Message part 1 (text/plain, inline)]
On Fri, Apr 11, 2025 at 2:18 PM Elijah Gabe Pérez <eg642616 <at> gmail.com>
wrote:

> Ship Mints <shipmints <at> gmail.com> writes:
> > I think the term duration is better than length when describing time
> intervals.
>
> I agree.
>
> > I still prefer the unwind-protected sit-for method that guarantees the
> remaps are removed to the one with
> > the timer where I've experienced errors intervening with a race
> condition creating new cookies that are
> > not removed.  Try mashing C-g with your timer implementation and you'll
> see it.
>
> The problem with using sit-for is that it delays the message displayed
> (usually "Quit") until timer stops (or if there is an input), it look
> like Emacs froze.
>

At 0.05 seconds, that's not likely.

Anyway, it changed it for use sit-for instead.
>

Cool.  You wrapped it with unwind-protect, yes?

> Is a new face really necessary just to implement a flash?  The
> implementation I proposed
> > allows the user to specify any face attributes to define what they want
> for a flash.  I wouldn't use this
> > feature without it being more reliable and flexible.
>
> I think that adding a new face for this would be better, it makes custom
> themes set it and change it dynamically; of course, the user can change
> face attributes freely.
>

As long as the implementation accepts a list of faces to flash as mine
does, that sounds good.  I'd just ignore the new face in my use.
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#77715; Package emacs. (Fri, 11 Apr 2025 18:48:02 GMT) Full text and rfc822 format available.

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

From: Elijah Gabe Pérez <eg642616 <at> gmail.com>
To: Ship Mints <shipmints <at> gmail.com>
Cc: 77715 <at> debbugs.gnu.org, drew.adams <at> oracle.com
Subject: Re: bug#77715: [PATCH] Add ring-bell functions for mode line and
 header line.
Date: Fri, 11 Apr 2025 12:47:40 -0600
Ship Mints <shipmints <at> gmail.com> writes:
>  Anyway, it changed it for use sit-for instead.
>
> Cool.  You wrapped it with unwind-protect, yes?

Yes.

>>> Is a new face really necessary just to implement a flash?  The implementation I proposed
>>> allows the user to specify any face attributes to define what they want for a flash.  I wouldn't use this
>>> feature without it being more reliable and flexible.
>>  I think that adding a new face for this would be better, it makes custom
>>  themes set it and change it dynamically; of course, the user can change
>>  face attributes freely.
> As long as the implementation accepts a list of faces to flash as mine does, that sounds good.  I'd just
> ignore the new face in my use.

Yeah it does:

+(defcustom flash-face-faces
+  '(mode-line-active)

By default it is set to `mode-line-active'.

-- 
                                          - E.G via GNU Emacs and Org.




This bug report was last modified 1 day ago.

Previous Next


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