all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Add a hook for color-theme switching
@ 2017-12-01 10:45 stardiviner
  2017-12-01 16:14 ` Drew Adams
  0 siblings, 1 reply; 6+ messages in thread
From: stardiviner @ 2017-12-01 10:45 UTC (permalink / raw)
  To: emacs-help

Here is a case:

I use package =hl-sexp= to highlight sexp in Lisp code:

#+begin_src emacs-lisp
(use-package hl-sexp
  :ensure t
  :config
  (set-face-attribute 'hl-sexp-face nil
                      :background (cl-case (alist-get 'background-mode
(frame-parameters))
                                    ('light
                                     (color-darken-name (face-background
'default) 7))
                                    ('dark
                                     (color-lighten-name
(face-background 'default) 4)))
                      )
  )
#+end_src

When I start Emacs, the face ~hl-sexp-face~ is been set by the Emacs
initialized
color-theme. Then I use package =circadian= to auto switch color-theme
or manually
switch color-theme with command =disable-theme= and =load-theme=. But
this face
~hl-sexp-face~ is defined already, usually not good for another switched
color-theme.

So I hope there is a hook for switching color-theme like
~color-theme-switch-hook~ etc.

This is useful for package =circadian=.




^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: Add a hook for color-theme switching
  2017-12-01 10:45 Add a hook for color-theme switching stardiviner
@ 2017-12-01 16:14 ` Drew Adams
  2017-12-02  5:09   ` stardiviner
  0 siblings, 1 reply; 6+ messages in thread
From: Drew Adams @ 2017-12-01 16:14 UTC (permalink / raw)
  To: stardiviner, emacs-help

> When I start Emacs, the face ~hl-sexp-face~ is been set
> by the Emacs initialized color-theme.

Vanilla Emacs doesn't use color themes.  It uses custom
themes - the user theme by default.  Color themes are
available through library `color-theme.el'.

Color themes:

https://www.emacswiki.org/emacs/ColorThemes

Custom themes:

https://www.emacswiki.org/emacs/CustomThemes

> Then I use package =circadian= to auto switch color-theme
> or manually switch color-theme with command `disable-theme'
> and `load-theme'. But this face `hl-sexp-face' is defined
> already, usually not good for another switched color-theme.

I don't understand the problem.  Are you saying that when
you switch to another theme (presumably a custom theme)
the appearance of face `hl-sexp-face' changes?

> So I hope there is a hook for switching color-theme like
> `color-theme-switch-hook' etc.

Do you mean that after you switch to another theme you
want to invoke some code?  What code would you invoke?
Is the idea just to make face `hl-sexp-face' have or
keep the appearance you want?



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Add a hook for color-theme switching
  2017-12-01 16:14 ` Drew Adams
@ 2017-12-02  5:09   ` stardiviner
  2017-12-02 15:38     ` Drew Adams
  0 siblings, 1 reply; 6+ messages in thread
From: stardiviner @ 2017-12-02  5:09 UTC (permalink / raw)
  To: Drew Adams, emacs-help



On 12/02/2017 12:14 AM, Drew Adams wrote:
> I don't understand the problem.  Are you saying that when
> you switch to another theme (presumably a custom theme)
> the appearance of face `hl-sexp-face' changes?
>
>> So I hope there is a hook for switching color-theme like
>> `color-theme-switch-hook' etc.
> Do you mean that after you switch to another theme you
> want to invoke some code?  What code would you invoke?
> Is the idea just to make face `hl-sexp-face' have or
> keep the appearance you want?
Here is an example showing what I want:

#+begin_src emacs-lisp
(add-hook 'color-theme-load-hook
          (lambda ()
            (set-face-attribute 'hl-sexp-face nil
                                :background (cl-case (alist-get
'background-mode (frame-parameters))
                                              ('light
                                               (color-darken-name
(face-background 'default) 7))
                                              ('dark
                                               (color-lighten-name
(face-background 'default) 4)))
                                )
            ))
#+end_src

Then the custom faces can be changed automatically according the
color-theme switching.



^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: Add a hook for color-theme switching
  2017-12-02  5:09   ` stardiviner
@ 2017-12-02 15:38     ` Drew Adams
  2017-12-03 12:12       ` numbchild
  0 siblings, 1 reply; 6+ messages in thread
From: Drew Adams @ 2017-12-02 15:38 UTC (permalink / raw)
  To: stardiviner, emacs-help

> Here is an example showing what I want:
> (add-hook 'color-theme-load-hook
>           (lambda ()
>             (set-face-attribute 'hl-sexp-face nil :background ...)
> Then the custom faces can be changed automatically according the
> color-theme switching.

If you really are using color themes (`color-theme.el')
then you have `color-theme-mode-hook', but that likely
won't help here.  There is no `color-theme-load-hook',
AFAIK.

On the other hand, if you are using custom themes then
there are `custom-new-theme-mode-hook' and
`custom-theme-choose-mode-hook'.

You have not yet made clear which kind of themes you are
using (though you keep saying "color theme"): custom
themes or color themes.



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Add a hook for color-theme switching
  2017-12-02 15:38     ` Drew Adams
@ 2017-12-03 12:12       ` numbchild
  2017-12-03 12:17         ` numbchild
  0 siblings, 1 reply; 6+ messages in thread
From: numbchild @ 2017-12-03 12:12 UTC (permalink / raw)
  To: Drew Adams; +Cc: emacs-help

Seems I'm using `color themes`. I only have `color-theme-mode-hook`, don't
have `custom-new-theme-mode-hook`, `custom-theme-choose-mode-hook`.

Thanks for your explaination.

[stardiviner]           <Hack this world!>      GPG key ID: 47C32433
IRC(freeenode): stardiviner                     Twitter:  @numbchild
Key fingerprint = 9BAA 92BC CDDD B9EF 3B36  CB99 B8C4 B8E5 47C3 2433
Blog: http://stardiviner.github.io/

On Sat, Dec 2, 2017 at 11:38 PM, Drew Adams <drew.adams@oracle.com> wrote:

> > Here is an example showing what I want:
> > (add-hook 'color-theme-load-hook
> >           (lambda ()
> >             (set-face-attribute 'hl-sexp-face nil :background ...)
> > Then the custom faces can be changed automatically according the
> > color-theme switching.
>
> If you really are using color themes (`color-theme.el')
> then you have `color-theme-mode-hook', but that likely
> won't help here.  There is no `color-theme-load-hook',
> AFAIK.
>
> On the other hand, if you are using custom themes then
> there are `custom-new-theme-mode-hook' and
> `custom-theme-choose-mode-hook'.
>
> You have not yet made clear which kind of themes you are
> using (though you keep saying "color theme"): custom
> themes or color themes.
>


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Add a hook for color-theme switching
  2017-12-03 12:12       ` numbchild
@ 2017-12-03 12:17         ` numbchild
  0 siblings, 0 replies; 6+ messages in thread
From: numbchild @ 2017-12-03 12:17 UTC (permalink / raw)
  To: Drew Adams; +Cc: emacs-help

You're right, `color-theme-mode-hook` does not work for my purpose. And I'm
not
using CustomThemes. Themes there is no existing way to do this.

[stardiviner]           <Hack this world!>      GPG key ID: 47C32433
IRC(freeenode): stardiviner                     Twitter:  @numbchild
Key fingerprint = 9BAA 92BC CDDD B9EF 3B36  CB99 B8C4 B8E5 47C3 2433
Blog: http://stardiviner.github.io/

On Sun, Dec 3, 2017 at 8:12 PM, numbchild@gmail.com <numbchild@gmail.com>
wrote:

> Seems I'm using `color themes`. I only have `color-theme-mode-hook`, don't
> have `custom-new-theme-mode-hook`, `custom-theme-choose-mode-hook`.
>
> Thanks for your explaination.
>
> [stardiviner]           <Hack this world!>      GPG key ID: 47C32433
> IRC(freeenode): stardiviner                     Twitter:  @numbchild
> Key fingerprint = 9BAA 92BC CDDD B9EF 3B36  CB99 B8C4 B8E5 47C3 2433
> Blog: http://stardiviner.github.io/
>
> On Sat, Dec 2, 2017 at 11:38 PM, Drew Adams <drew.adams@oracle.com> wrote:
>
>> > Here is an example showing what I want:
>> > (add-hook 'color-theme-load-hook
>> >           (lambda ()
>> >             (set-face-attribute 'hl-sexp-face nil :background ...)
>> > Then the custom faces can be changed automatically according the
>> > color-theme switching.
>>
>> If you really are using color themes (`color-theme.el')
>> then you have `color-theme-mode-hook', but that likely
>> won't help here.  There is no `color-theme-load-hook',
>> AFAIK.
>>
>> On the other hand, if you are using custom themes then
>> there are `custom-new-theme-mode-hook' and
>> `custom-theme-choose-mode-hook'.
>>
>> You have not yet made clear which kind of themes you are
>> using (though you keep saying "color theme"): custom
>> themes or color themes.
>>
>
>


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2017-12-03 12:17 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-12-01 10:45 Add a hook for color-theme switching stardiviner
2017-12-01 16:14 ` Drew Adams
2017-12-02  5:09   ` stardiviner
2017-12-02 15:38     ` Drew Adams
2017-12-03 12:12       ` numbchild
2017-12-03 12:17         ` numbchild

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.