GNU bug report logs - #37802
27.0.50; Feature request: hook for theme enabling/disabling

Previous Next

Package: emacs;

Reported by: Óscar Fuentes <ofv <at> wanadoo.es>

Date: Fri, 18 Oct 2019 00:30:02 UTC

Severity: wishlist

Tags: moreinfo

Found in version 27.0.50

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 37802 in the body.
You can then email your comments to 37802 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#37802; Package emacs. (Fri, 18 Oct 2019 00:30:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Óscar Fuentes <ofv <at> wanadoo.es>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Fri, 18 Oct 2019 00:30:02 GMT) Full text and rfc822 format available.

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

From: Óscar Fuentes <ofv <at> wanadoo.es>
To: bug-gnu-emacs <at> gnu.org
Subject: 27.0.50; Feature request: hook for theme enabling/disabling
Date: Fri, 18 Oct 2019 02:29:23 +0200
I'm experimenting with some code that uses face-remap-add-relative to
modify colors on specific windows. It takes the attribute of an existing
face, alters it and uses :filtered to apply the change conditionally. On
my specific case I use that technique for darkening the default
background of the windows that have no keyboard focus.

However, when I switch themes I have to manually force the recalculation
of the "darked" background to adapt it to the new theme. If I had a hook
that fires *after* a theme is enabled or disabled, I could automatize
the recalculation.

I looked at custom.el and the change seems simple enough so I wonder if
there is any reason for not implementing such hook.


In GNU Emacs 27.0.50 (build 1, x86_64-pc-linux-gnu, X toolkit)
 of 2019-09-12 built on sky
Repository revision: 421084d2cb160261b259bddb687bb2c234f8f1ef
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12004000
System Description: Debian GNU/Linux bullseye/sid




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#37802; Package emacs. (Fri, 20 May 2022 10:59:02 GMT) Full text and rfc822 format available.

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

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Óscar Fuentes <ofv <at> wanadoo.es>
Cc: 37802 <at> debbugs.gnu.org
Subject: Re: bug#37802: 27.0.50; Feature request: hook for theme
 enabling/disabling
Date: Fri, 20 May 2022 12:58:09 +0200
Óscar Fuentes <ofv <at> wanadoo.es> writes:

> I'm experimenting with some code that uses face-remap-add-relative to
> modify colors on specific windows. It takes the attribute of an existing
> face, alters it and uses :filtered to apply the change conditionally. On
> my specific case I use that technique for darkening the default
> background of the windows that have no keyboard focus.
>
> However, when I switch themes I have to manually force the recalculation
> of the "darked" background to adapt it to the new theme. If I had a hook
> that fires *after* a theme is enabled or disabled, I could automatize
> the recalculation.
>
> I looked at custom.el and the change seems simple enough so I wonder if
> there is any reason for not implementing such hook.

(I'm going through old bug reports that unfortunately weren't resolved
at the time.)

If this is for a package, I think it might make more sense to use
`advice-add' on `enable-theme'?  But I wouldn't mind adding a an
`enable-theme-hook' here, if that makes things substantially easier for
your use case.


-- 
(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. (Fri, 20 May 2022 10:59:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#37802; Package emacs. (Fri, 20 May 2022 14:52:02 GMT) Full text and rfc822 format available.

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

From: Óscar Fuentes <ofv <at> wanadoo.es>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 37802 <at> debbugs.gnu.org
Subject: Re: bug#37802: 27.0.50; Feature request: hook for theme
 enabling/disabling
Date: Fri, 20 May 2022 16:51:35 +0200
Lars Ingebrigtsen <larsi <at> gnus.org> writes:

> Óscar Fuentes <ofv <at> wanadoo.es> writes:
>
>> I'm experimenting with some code that uses face-remap-add-relative to
>> modify colors on specific windows. It takes the attribute of an existing
>> face, alters it and uses :filtered to apply the change conditionally. On
>> my specific case I use that technique for darkening the default
>> background of the windows that have no keyboard focus.
>>
>> However, when I switch themes I have to manually force the recalculation
>> of the "darked" background to adapt it to the new theme. If I had a hook
>> that fires *after* a theme is enabled or disabled, I could automatize
>> the recalculation.
>>
>> I looked at custom.el and the change seems simple enough so I wonder if
>> there is any reason for not implementing such hook.
>
> (I'm going through old bug reports that unfortunately weren't resolved
> at the time.)
>
> If this is for a package, I think it might make more sense to use
> `advice-add' on `enable-theme'?  But I wouldn't mind adding a an
> `enable-theme-hook' here, if that makes things substantially easier for
> your use case.

Currently I've solved my requirement by using defadvice on enable-theme
*and* disable-theme for adapting my custom faces to changes on the
active theme(s). Using a hook would be a little bit cleaner. I'm also
surprised that no hook was implemented for this case, as most changes on
user-visible state has an associated hook.

Whatever you decide, it is fine with me.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#37802; Package emacs. (Sat, 21 May 2022 12:57:02 GMT) Full text and rfc822 format available.

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

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Óscar Fuentes <ofv <at> wanadoo.es>
Cc: 37802 <at> debbugs.gnu.org
Subject: Re: bug#37802: 27.0.50; Feature request: hook for theme
 enabling/disabling
Date: Sat, 21 May 2022 14:56:34 +0200
Óscar Fuentes <ofv <at> wanadoo.es> writes:

> Currently I've solved my requirement by using defadvice on enable-theme
> *and* disable-theme for adapting my custom faces to changes on the
> active theme(s). Using a hook would be a little bit cleaner. I'm also
> surprised that no hook was implemented for this case, as most changes on
> user-visible state has an associated hook.

Yes, true.  So I've now added these two hooks to Emacs 29.

-- 
(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 37802 <at> debbugs.gnu.org and Óscar Fuentes <ofv <at> wanadoo.es> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Sat, 21 May 2022 12:57:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#37802; Package emacs. (Sat, 21 May 2022 13:08:02 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: ofv <at> wanadoo.es, 37802 <at> debbugs.gnu.org
Subject: Re: bug#37802: 27.0.50;
 Feature request: hook for theme enabling/disabling
Date: Sat, 21 May 2022 16:07:00 +0300
> Resent-From: Lars Ingebrigtsen <larsi <at> gnus.org>
> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
> Resent-CC: bug-gnu-emacs <at> gnu.org
> Resent-Sender: help-debbugs <at> gnu.org
> Cc: 37802 <at> debbugs.gnu.org
> From: Lars Ingebrigtsen <larsi <at> gnus.org>
> Date: Sat, 21 May 2022 14:56:34 +0200
> 
> Óscar Fuentes <ofv <at> wanadoo.es> writes:
> 
> > Currently I've solved my requirement by using defadvice on enable-theme
> > *and* disable-theme for adapting my custom faces to changes on the
> > active theme(s). Using a hook would be a little bit cleaner. I'm also
> > surprised that no hook was implemented for this case, as most changes on
> > user-visible state has an associated hook.
> 
> Yes, true.  So I've now added these two hooks to Emacs 29.

Thanks, but is there any reason these hooks aren't called
enable-theme-function and disable-theme-function?  Hooks by such
names are already documented as "abnormal hooks", which would avoid
the need of saying these new hooks are "atypical", something that we
never had in our terminology.




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

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

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: ofv <at> wanadoo.es, 37802 <at> debbugs.gnu.org
Subject: Re: bug#37802: 27.0.50; Feature request: hook for theme
 enabling/disabling
Date: Sat, 21 May 2022 15:21:29 +0200
Eli Zaretskii <eliz <at> gnu.org> writes:

> Thanks, but is there any reason these hooks aren't called
> enable-theme-function and disable-theme-function?  Hooks by such
> names are already documented as "abnormal hooks", which would avoid
> the need of saying these new hooks are "atypical", something that we
> never had in our terminology.

"Abnormal" was the word I was looking for.

As for the name, I don't really have much of an opinion -- we have more
of these abnormal hooks called -hook than -function(s), a short grepping
for run-hook-with-args shows.

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




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#37802; Package emacs. (Sat, 21 May 2022 13:26:02 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: ofv <at> wanadoo.es, 37802 <at> debbugs.gnu.org
Subject: Re: bug#37802: 27.0.50; Feature request: hook for theme
 enabling/disabling
Date: Sat, 21 May 2022 16:25:09 +0300
> From: Lars Ingebrigtsen <larsi <at> gnus.org>
> Cc: ofv <at> wanadoo.es,  37802 <at> debbugs.gnu.org
> Date: Sat, 21 May 2022 15:21:29 +0200
> 
> Eli Zaretskii <eliz <at> gnu.org> writes:
> 
> > Thanks, but is there any reason these hooks aren't called
> > enable-theme-function and disable-theme-function?  Hooks by such
> > names are already documented as "abnormal hooks", which would avoid
> > the need of saying these new hooks are "atypical", something that we
> > never had in our terminology.
> 
> "Abnormal" was the word I was looking for.
> 
> As for the name, I don't really have much of an opinion -- we have more
> of these abnormal hooks called -hook than -function(s), a short grepping
> for run-hook-with-args shows.

Maybe so, and we cannot do much about bad names that are already in
the wild.  But why not use the documented names for new hooks we
introduce now?

I can rename them myself, I just wanted to make sure you didn't have
any particular reason for using those names.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#37802; Package emacs. (Sat, 21 May 2022 13:27:02 GMT) Full text and rfc822 format available.

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

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: ofv <at> wanadoo.es, 37802 <at> debbugs.gnu.org
Subject: Re: bug#37802: 27.0.50; Feature request: hook for theme
 enabling/disabling
Date: Sat, 21 May 2022 15:26:09 +0200
Eli Zaretskii <eliz <at> gnu.org> writes:

> I can rename them myself, I just wanted to make sure you didn't have
> any particular reason for using those names.

Nope.  Please go ahead.

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




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#37802; Package emacs. (Sat, 21 May 2022 16:51:01 GMT) Full text and rfc822 format available.

Message #33 received at 37802-done <at> debbugs.gnu.org (full text, mbox):

From: Óscar Fuentes <ofv <at> wanadoo.es>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 37802-done <at> debbugs.gnu.org
Subject: Re: bug#37802: 27.0.50; Feature request: hook for theme
 enabling/disabling
Date: Sat, 21 May 2022 18:49:50 +0200
Lars Ingebrigtsen <larsi <at> gnus.org> writes:

> Yes, true.  So I've now added these two hooks to Emacs 29.

Thank you.

As it seems that the discussion about the hook's name is resolved, I'm
closing the bug report.




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

This bug report was last modified 1 year and 311 days ago.

Previous Next


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