10

My Emacs always prompts me if it should trust selected colour theme or not. I always answer y and y to trust and remember my choice. I'm loading colour theme manually:

(load-theme 'my-favourite-theme)

I suppose this is because easy customizations are placed below colour theme loading. Is it some way to fix it? Or should I just delegate colour theme loading to easy customizations too?

  • 2
    load-theme has optional arguments: (load-theme THEME &optional NO-CONFIRM NO-ENABLE) -- If used directly in your init file, it should be called with a non-nil NO-CONFIRM argument . . . In other words, use: (load-theme 'my-favourite-theme t) – lawlist Mar 23 '15 at 19:30
  • 1
    so I need (load-theme 'name t nil) or just (load-theme 'name t)? – Geradlus_RU Mar 23 '15 at 19:31
  • 2
    Optional arguments that are nil need to be included ONLY if a subsequent optional argument is non-nil. For example, if you wanted the first optional argument to be nil and the second optional argument to be t, then nil would be needed for the first argument. Since the second optional argument is nil -- you may omit or include it -- it makes no difference. Sometimes I use nil for optional arguments when there is no subsequent non-nil optional argument just so that I know how many optional arguments are possible for a particular function -- i.e., a visual reminder. – lawlist Mar 23 '15 at 19:34
  • What @lawlist is suggesting is a workaround, not a solution. It's preferable to figure out why you're getting this problem as it can possibly cause other issues. In fact, I've seen this issue around a lot, so I'd very much like to know the reason. – Malabarba Mar 23 '15 at 23:43
  • @Geradlus_RU If you haven't specified the NO-CONFIRM argument to be t, emacs will ask you that question again each time after that theme package is updated (because its .el checksum changes). Is that the case? If you keep on getting those prompts each time you start emacs (even when the theme .el hasn't been updated), then make sure that the theme checksum is been saved by emacs and also being read by emacs during start-up. One possible scenario is that you have saved the custom.el as a separate file (emacs is memorizing the safe themes to those) but you are not loading that file in init. – Kaushal Modi Mar 24 '15 at 10:59
10

Your init.el file probably contains a snippet like this:

(custom-set-variables
 ;; custom-set-variables was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 ...)

Amongst many other things, this snippet is responsible for saving and restoring the custom-safe-themes variable. Therefore, if this happens to be at the end of your init file (as is usually the case) you probably added your (load-theme ...) line above it, which explains why Emacs doesn't know about your safe themes during startup.

Simply move that snippet to the top of your init-file, and that should solve your problem.

3

I'm using moe-them, and just

(require 'moe-theme)
(moe-dark)

will load the theme without error/warning/prompt, but if I M-x load-theme inside Emacs, it will prompt something like "treat the theme as safe", and I found out a solution for that:

(setq custom-safe-themes t)

I don't know if this will solve your problem, but you can give it a try.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.