(defvar custom-field-keymap
(let ((map (copy-keymap widget-field-keymap)))
- (define-key map "\C-c\C-c" 'Custom-set)
- (define-key map "\C-x\C-s" 'Custom-save)
+ (define-key map "\C-c\C-c" #'Custom-set)
+ (define-key map "\C-x\C-s" #'Custom-save)
map)
"Keymap used inside editable fields in customization buffers.")
+;; FIXME: Doesn't this affect all `editable-field's ever? Why not set
+;; the right keymap right away when we (define-widget 'editable-field ...)?
(widget-put (get 'editable-field 'widget-type) :keymap custom-field-keymap)
;;; Utilities.
(and (equal value (eval (car tmp)))
(equal comment temp))
(error nil))
- (if (equal value (eval (car (get symbol 'standard-value))))
+ (if (custom--standard-value-p symbol value)
'standard
'set)
'changed))
redraw the widget immediately."
(let* ((symbol (widget-value widget)))
(if (get symbol 'standard-value)
- (unless (equal (custom-variable-current-value widget)
- (eval (car (get symbol 'standard-value))))
+ (unless (custom--standard-value-p
+ symbol (custom-variable-current-value widget))
(custom-variable-backup-value widget))
(user-error "No standard setting known for %S" symbol))
(put symbol 'variable-comment nil)
(defun custom-save-faces ()
"Save all customized faces in `custom-file'."
(save-excursion
- (custom-save-delete 'custom-reset-faces)
+ (custom-save-delete 'custom-reset-faces) ;FIXME: Never written!?
(custom-save-delete 'custom-set-faces)
(let ((standard-output (current-buffer))
(saved-list (make-list 1 0)))
(defvar tool-bar-map)
-;;; `custom-tool-bar-map' used to be set up here. This will fail to
-;;; DTRT when `display-graphic-p' returns nil during compilation. Hence
-;;; we set this up lazily in `Custom-mode'.
+;; `custom-tool-bar-map' used to be set up here. This will fail to
+;; DTRT when `display-graphic-p' returns nil during compilation. Hence
+;; we set this up lazily in `Custom-mode'.
(defvar custom-tool-bar-map nil
"Keymap for toolbar in Custom mode.")
(make-local-variable 'custom-options)
(make-local-variable 'custom-local-buffer)
(custom--initialize-widget-variables)
- (add-hook 'widget-edit-functions 'custom-state-buffer-message nil t))
+ (add-hook 'widget-edit-functions #'custom-state-buffer-message nil t))
(defun custom--revert-buffer (_ignore-auto _noconfirm)
(unless custom--invocation-options
for more information."
(declare (doc-string 3) (debug (name body))
(indent defun))
- ;; It is better not to use backquote in this file,
- ;; because that makes a bootstrapping problem
- ;; if you need to recompile all the Lisp files using interpreted code.
`(custom-declare-variable
',symbol
,(if lexical-binding
(let ((options (get symbol 'custom-options)))
(unless (member option options)
(put symbol 'custom-options (cons option options)))))
-(defalias 'custom-add-frequent-value 'custom-add-option)
+(defalias 'custom-add-frequent-value #'custom-add-option)
(defun custom-add-link (symbol widget)
"To the custom option SYMBOL add the link WIDGET."
"Return the standard value of VARIABLE."
(eval (car (get variable 'standard-value)) t))
+(defun custom--standard-value-p (variable value)
+ "Return non-nil if VALUE is `equal' to the standard value of VARIABLE."
+ (let ((sv (get variable 'standard-value)))
+ (and sv (equal value (eval (with-demoted-errors "%S" (car sv)) t)))))
+
(defun custom-note-var-changed (variable)
"Inform Custom that VARIABLE has been set (changed).
VARIABLE is a symbol that names a user option.
(let* ((get (or (get symbol 'custom-get) #'default-value))
(value (funcall get symbol))
(saved (get symbol 'saved-value))
- (standard (get symbol 'standard-value))
(comment (get symbol 'customized-variable-comment)))
;; Save default value if different from standard value.
(put symbol 'saved-value
- (unless (and standard
- (equal value (ignore-errors (eval (car standard)))))
+ (unless (custom--standard-value-p symbol value)
(list (custom-quote value))))
;; Clear customized information (set, but not saved).
(put symbol 'customized-value nil)
;; recompute when the theme is disabled.
(when (and (eq prop 'theme-value)
(boundp symbol))
- (let ((sv (get symbol 'standard-value))
- (val (symbol-value symbol)))
+ (let ((val (symbol-value symbol)))
(unless (or
;; We only do this trick if the current value
;; is different from the standard value.
- (and sv (equal (eval (car sv)) val))
+ (custom--standard-value-p symbol 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
(let* ((prop (car s))
(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
(not (or spec-list
;; Only if the current value is different from
;; the standard value.
- (and sv (equal (eval (car sv)) val))
+ (custom--standard-value-p symbol val)
;; And only if the changed value is different
;; from the new value under the user theme.
(and (eq theme 'user)