summaryrefslogtreecommitdiff
path: root/lisp/custom.el
diff options
context:
space:
mode:
authorChong Yidong <cyd@stupidchicken.com>2011-06-29 21:39:52 -0400
committerChong Yidong <cyd@stupidchicken.com>2011-06-29 21:39:52 -0400
commit658d8eb8fceb1d5f0f7a71c4f7145dd43b78081b (patch)
treefac3229b9f3f5ed01817341dfa23a295c0c0937d /lisp/custom.el
parent732b9594ceab70733e55dba8dec85e7def3824b0 (diff)
downloademacs-658d8eb8fceb1d5f0f7a71c4f7145dd43b78081b.tar.gz
Avoid calling customize-save-variable during startup (Bug#8720).
* lisp/cus-edit.el (customize-push-and-save): New function. * lisp/files.el (hack-local-variables-confirm): Use it. * lisp/custom.el (load-theme): New arg NO-CONFIRM. Use customize-push-and-save (Bug#8720). (custom-enabled-themes): Doc fix. * lisp/cus-theme.el (customize-create-theme) (custom-theme-merge-theme): Callers to load-theme changed.
Diffstat (limited to 'lisp/custom.el')
-rw-r--r--lisp/custom.el32
1 files changed, 21 insertions, 11 deletions
diff --git a/lisp/custom.el b/lisp/custom.el
index 8295777f1f1..2504b4f2cd9 100644
--- a/lisp/custom.el
+++ b/lisp/custom.el
@@ -1119,20 +1119,29 @@ Emacs theme directory (a directory named \"themes\" in
:risky t
:version "24.1")
-(defun load-theme (theme &optional no-enable)
+(defun load-theme (theme &optional no-confirm no-enable)
"Load Custom theme named THEME from its file.
-Normally, this also enables THEME. If optional arg NO-ENABLE is
-non-nil, load THEME but don't enable it.
-
The theme file is named THEME-theme.el, in one of the directories
specified by `custom-theme-load-path'.
+If THEME is not in `custom-safe-themes', prompt the user for
+confirmation, unless optional arg NO-CONFIRM is non-nil.
+
+Normally, this function also enables THEME; if optional arg
+NO-ENABLE is non-nil, load the theme but don't enable it.
+
+This function is normally called through Customize when setting
+`custom-enabled-themes'. If used directly in your init file, it
+should be called with a non-nil NO-CONFIRM argument, or after
+`custom-safe-themes' has been loaded.
+
Return t if THEME was successfully loaded, nil otherwise."
(interactive
(list
(intern (completing-read "Load custom theme: "
(mapcar 'symbol-name
- (custom-available-themes))))))
+ (custom-available-themes))))
+ nil nil))
(unless (custom-theme-name-valid-p theme)
(error "Invalid theme name `%s'" theme))
;; If reloading, clear out the old theme settings.
@@ -1152,7 +1161,8 @@ Return t if THEME was successfully loaded, nil otherwise."
(setq hash (sha1 (current-buffer)))
;; Check file safety with `custom-safe-themes', prompting the
;; user if necessary.
- (when (or (and (memq 'default custom-safe-themes)
+ (when (or no-confirm
+ (and (memq 'default custom-safe-themes)
(equal (file-name-directory fn)
(expand-file-name "themes/" data-directory)))
(member hash custom-safe-themes)
@@ -1211,10 +1221,7 @@ query also about adding HASH to `custom-safe-themes'."
;; Offer to save to `custom-safe-themes'.
(and (or custom-file user-init-file)
(y-or-n-p "Treat this theme as safe in future sessions? ")
- (let ((coding-system-for-read nil))
- (push hash custom-safe-themes)
- (customize-save-variable 'custom-safe-themes
- custom-safe-themes)))
+ (customize-push-and-save 'custom-safe-themes (list hash)))
t)))))
(defun custom-theme-name-valid-p (name)
@@ -1291,7 +1298,10 @@ This list does not include the `user' theme, which is set by
Customize and always takes precedence over other Custom Themes.
This variable cannot be defined inside a Custom theme; there, it
-is simply ignored."
+is simply ignored.
+
+Setting this variable through Customize calls `enable-theme' or
+`load-theme' for each theme in the list."
:group 'customize
:type '(repeat symbol)
:set-after '(custom-theme-directory custom-theme-load-path