summaryrefslogtreecommitdiff
path: root/lisp/custom.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/custom.el')
-rw-r--r--lisp/custom.el65
1 files changed, 58 insertions, 7 deletions
diff --git a/lisp/custom.el b/lisp/custom.el
index 885c486c5e4..3f1e8cacb28 100644
--- a/lisp/custom.el
+++ b/lisp/custom.el
@@ -758,6 +758,9 @@ Return non-nil if the `customized-value' property actually changed."
(progn (put symbol 'customized-value (list (custom-quote value)))
(custom-push-theme 'theme-value symbol 'user 'set
(custom-quote value)))
+ (custom-push-theme 'theme-value symbol 'user
+ (if (get symbol 'saved-value) 'set 'reset)
+ (custom-quote value))
(put symbol 'customized-value nil))
;; Changed?
(not (equal customized (get symbol 'customized-value)))))
@@ -904,7 +907,15 @@ See `custom-known-themes' for a list of known themes."
(boundp symbol))
(let ((sv (get symbol 'standard-value))
(val (symbol-value symbol)))
- (unless (and sv (equal (eval (car sv)) val))
+ (unless (or
+ ;; We only do this trick if the current value
+ ;; is different from the standard value.
+ (and sv (equal (eval (car sv)) val))
+ ;; And we don't do it if we would end up recording
+ ;; the same value for the user theme. This way we avoid
+ ;; having ((user VALUE) (changed VALUE)). That would be
+ ;; useless, because we don't disable the user theme.
+ (and (eq theme 'user) (equal (custom-quote val) value)))
(setq old `((changed ,(custom-quote val))))))))
(put symbol prop (cons (list theme value) old)))
(put theme 'theme-settings
@@ -999,7 +1010,10 @@ COMMENT is a comment string about SYMBOL."
set)
(when requests
(put symbol 'custom-requests requests)
- (mapc #'require requests))
+ ;; Load any libraries that the setting has specified as
+ ;; being required, but don't error out if the package has
+ ;; been removed.
+ (mapc (lambda (lib) (require lib nil t)) requests))
(setq set (or (get symbol 'custom-set) #'custom-set-default))
(put symbol 'saved-value (list value))
(put symbol 'saved-variable-comment comment)
@@ -1365,13 +1379,36 @@ function runs. To disable other themes, use `disable-theme'."
obarray (lambda (sym) (get sym 'theme-settings)) t))))
(unless (custom-theme-p theme)
(error "Undefined Custom theme %s" theme))
- (let ((settings (get theme 'theme-settings)))
+ (let ((settings (get theme 'theme-settings)) ; '(prop symbol theme value)
+ ;; We are enabling the theme, so don't inhibit enabling it. (Bug#34027)
+ (custom--inhibit-theme-enable nil))
;; Loop through theme settings, recalculating vars/faces.
(dolist (s settings)
(let* ((prop (car s))
- (symbol (cadr s))
- (spec-list (get symbol prop)))
- (put symbol prop (cons (cddr s) (assq-delete-all theme spec-list)))
+ (symbol (cadr s))
+ (spec-list (get symbol prop))
+ (sv (get symbol 'standard-value))
+ (val (and (boundp symbol) (symbol-value symbol))))
+ ;; We can't call `custom-push-theme' when enabling the theme: it's not
+ ;; that the theme settings have changed, it's just that we want to
+ ;; enable those settings. But we might need to save a user setting
+ ;; outside of Customize, in order to get back to it when disabling
+ ;; the theme, just like in `custom-push-theme'.
+ (when (and (custom--should-apply-setting theme)
+ ;; Only do it for variables; for faces, using
+ ;; `face-new-frame-defaults' is enough.
+ (eq prop 'theme-value)
+ (boundp symbol)
+ (not (or spec-list
+ ;; Only if the current value is different from
+ ;; the standard value.
+ (and sv (equal (eval (car sv)) val))
+ ;; And only if the changed value is different
+ ;; from the new value under the user theme.
+ (and (eq theme 'user)
+ (equal (custom-quote val) (nth 3 s))))))
+ (setq spec-list `((changed ,(custom-quote val)))))
+ (put symbol prop (cons (cddr s) (assq-delete-all theme spec-list)))
(cond
((eq prop 'theme-face)
(custom-theme-recalc-face symbol))
@@ -1440,7 +1477,7 @@ See `custom-enabled-themes' for a list of enabled themes."
(let* ((prop (car s))
(symbol (cadr s))
(val (assq-delete-all theme (get symbol prop))))
- (put symbol prop val)
+ (custom-push-theme prop symbol theme 'reset)
(cond
((eq prop 'theme-value)
(custom-theme-recalc-variable symbol))
@@ -1541,6 +1578,20 @@ Each of the arguments ARGS has this form:
This means reset VARIABLE. (The argument IGNORED is ignored)."
(apply #'custom-theme-reset-variables 'user args))
+(defun custom-add-choice (variable choice)
+ "Add CHOICE to the custom type of VARIABLE.
+If a choice with the same tag already exists, no action is taken."
+ (let ((choices (get variable 'custom-type)))
+ (unless (eq (car choices) 'choice)
+ (error "Not a choice type: %s" choices))
+ (unless (seq-find (lambda (elem)
+ (equal (caddr (member :tag elem))
+ (caddr (member :tag choice))))
+ (cdr choices))
+ ;; Put the new choice at the end.
+ (put variable 'custom-type
+ (append choices (list choice))))))
+
;;; The End.
(provide 'custom)