Enable/disable theme while using desktop-save-mode

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Enable/disable theme while using desktop-save-mode

Pankaj Jangid
Hi,

I have (desktop-save-mode 1) and then enabled one dark mode theme. After
a few days, now I want to disable the theme. Even after I comment out
the theme related code from init.el, some of the theme settings don't go
away. This is because of the way themes are thought out in Emacs.

In Emacs, a theme is not just one setting. It is a collection of
settings that we configure. This allows us to set multiple themes in
sequence. Later settings will prevail finally.

Now, even when I disable all themes, the settings are still saved in
desktop session. Restarting Emacs, loads those settings from saved
desktop. This is where I am stuck.

Is there a way to remove all those settings which were configured by the
theme previously set?

Regards,
--
Pankaj Jangid

Reply | Threaded
Open this post in threaded view
|

Re: Enable/disable theme while using desktop-save-mode

Stefan Monnier
> Is there a way to remove all those settings which were configured by the
> theme previously set?

I'd recommend you give more details.  Such as *how* you "disable" your
themes and what settings you have noticed are still affected by the
(now disabled) themes.


        Stefan


Reply | Threaded
Open this post in threaded view
|

Re: Enable/disable theme while using desktop-save-mode

Pankaj Jangid
> I'd recommend you give more details.  Such as *how* you "disable" your
> themes and what settings you have noticed are still affected by the
> (now disabled) themes.

Okay. Here is my configuration,

#+BEGIN_SRC emacs-lisp
(setq-default custom-enabled-themes '(sanityinc-tomorrow-bright))

;; Ensure that themes will be applied even if they have not been customized
(defun reapply-themes ()
  "Forcibly load the themes listed in `custom-enabled-themes'."
  (dolist (theme custom-enabled-themes)
    (unless (custom-theme-p theme)
      (load-theme theme))))

(add-hook 'after-init-hook 'reapply-themes)
#+END_SRC

Now, to disable the theme I just commented these lines and restarted
Emacs. This should start Emacs with default theme with white
background. But the application starts with dark background although
some of the settings are gone. The font colours etc are different.

I am suspecting that this is because I have desktop-save-mode
enabled. If I start with '-Q' option then everything is ok. Because then
it doesn't read the desktop file.

I want to understand how to completely wipe out theme settings even from
saved-desktop. (If that is the reason).

Regards,
--
Pankaj Jangid

Reply | Threaded
Open this post in threaded view
|

Re: Enable/disable theme while using desktop-save-mode

YUE Daian
On 2019-11-06 10:38, Pankaj Jangid <[hidden email]> wrote:

>> I'd recommend you give more details.  Such as *how* you "disable" your
>> themes and what settings you have noticed are still affected by the
>> (now disabled) themes.
>
> Okay. Here is my configuration,
>
> #+BEGIN_SRC emacs-lisp
> (setq-default custom-enabled-themes '(sanityinc-tomorrow-bright))
>
> ;; Ensure that themes will be applied even if they have not been customized
> (defun reapply-themes ()
>   "Forcibly load the themes listed in `custom-enabled-themes'."
>   (dolist (theme custom-enabled-themes)
>     (unless (custom-theme-p theme)
>       (load-theme theme))))
>
> (add-hook 'after-init-hook 'reapply-themes)
> #+END_SRC
>
> Now, to disable the theme I just commented these lines and restarted
> Emacs. This should start Emacs with default theme with white
> background. But the application starts with dark background although
> some of the settings are gone. The font colours etc are different.
>
> I am suspecting that this is because I have desktop-save-mode
> enabled. If I start with '-Q' option then everything is ok. Because then
> it doesn't read the desktop file.
>
> I want to understand how to completely wipe out theme settings even from
> saved-desktop. (If that is the reason).
>
> Regards,
> --
> Pankaj Jangid

I came across this problem before.

I do not know ~sanityinc-tomorrow-bright~, but some themes will modify
some settings once loaded.

Could you please try to load ~whiteboard~ theme (the default one) after
package initialization?

Loading it should really "initializing" the theme.

Reply | Threaded
Open this post in threaded view
|

Re: Enable/disable theme while using desktop-save-mode

Pankaj Jangid
> Could you please try to load ~whiteboard~ theme (the default one) after
> package initialization?

This worked a bit. But some portions of editor are still having old
style. For example, the column displaying line numbers is still in dark
mode.

Regards,
--
Pankaj Jangid

Reply | Threaded
Open this post in threaded view
|

Re: Enable/disable theme while using desktop-save-mode

Eli Zaretskii
In reply to this post by Pankaj Jangid
> From: Pankaj Jangid <[hidden email]>
> Date: Wed, 06 Nov 2019 10:38:30 +0530
>
> I want to understand how to completely wipe out theme settings even from
> saved-desktop. (If that is the reason).

I suggest to carefully review your .emacs.desktop file, and find which
settings are being saved in it that cause this.

Reply | Threaded
Open this post in threaded view
|

Re: Enable/disable theme while using desktop-save-mode

Pankaj Jangid
>> I want to understand how to completely wipe out theme settings even from
>> saved-desktop. (If that is the reason).
>
> I suggest to carefully review your .emacs.desktop file, and find which
> settings are being saved in it that cause this.

Yes. Doing this now to find out which settings are persistent even after
the theme is disabled. Thanks for the pointers.

Regards,
--
Pankaj Jangid