Emacs: how to get the default theme?

强颜欢笑 提交于 2019-12-21 07:38:58

问题


I've been using the default theme with about 10 faces changed via custom-set-faces for a while now. But from time to time I want to try out a couple of the custom themes out there. The problem is that they set much more than 10 faces and there's no way to get back to my previous setup once I've loaded a custom theme.

Just to clarify:

  1. I start Emacs with my customization of the default theme (load "faces"). All is good.
  2. load-theme wombat. All is good.
  3. (load "faces") again: everything is a mess, because a lot of the faces still remain in the wombat state.

Sometimes separate themes aren't compatible with each other, e.g. second one sets more faces than the first one and when returning to the first one everything becomes a mess.

So I wonder if there's something like load-theme default that would reset every face imaginable to the default emacs -q state.

I could then just tweak it with my 10 custom faces and have my own theme that would not have the problem that I described.


回答1:


It seems that disable-theme does what you want.

UPDATE

Here is one way to get the 'default theme template'

1) Disable any additional theme (using disable-theme)

2) Invoke the command customize-create-theme it will open a customize interface, which lists all the default faces, which you can customize and create your own theme

If the customize-create-theme is called with theme name it will list all the faces that are set by the theme.




回答2:


Others have mentioned ways to try to work around the problem. I'll just point out that there is, so far, an inherent problem with Emacs custom themes, in terms of trying to "undo" them and get back to a previous, possibly customized but not custom-themed state.

Particularly if you want to do this non-interactively, e.g., in the code for a command that lets users try themes out but also lets them cancel (e.g. C-g) and return to the previous state, before theming.

You can disable all themes that were ever enabled in the session, but that will not return your session to its state before the themes were enabled. Disabling a theme is, in effect, only relative to other themes, not to an uncustomized state or (especially) to other, non-theme customizations.

See also:

  • http://lists.gnu.org/archive/html/help-gnu-emacs/2014-02/msg00334.html
  • http://debbugs.gnu.org/cgi/bugreport.cgi?bug=15687

(Oh, and FWIW, color themes, which were presumably the inspiration for Emacs custom themes, do not have this problem. And they work fine with all Emacs versions, including the latest. They have different limitations from custom themes, however. It would be good for the custom theme implementation to be fixed/completed, so custom themes can completely replace color themes.)




回答3:


I have something like this in my emacs config to change themes:

(defun zenburn ()
"Activate zenburn theme."
(interactive)
(setq dark-theme t)
;; disable other themes before setting this theme
(disable-theme 'soft-stone)
(disable-theme 'leuven)
(load-theme 'zenburn t))



回答4:


This is like a year after the original, but just solved a similar problem by M-x customize-face then entering default.

Customize Face: Default will give you a GUI with options for things like font, foreground and background colors, etc.

Go to the top area marked Operate on all settings in this buffer: and click on Revert and in the dropdown, Erase Customizations.

Finally, reload/evaluate your .emacs or init.el file.

This worked for me, while trying to manually disable (almost all) themes and float around .el files hadn't.



来源:https://stackoverflow.com/questions/22127337/emacs-how-to-get-the-default-theme

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!