aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiles Bader2002-04-19 07:43:43 +0000
committerMiles Bader2002-04-19 07:43:43 +0000
commit6d912ee1a79392e3fcfa4f7932b0587560e2bfb6 (patch)
treee0562f60cbc63ef75c9def34693f0205463b53cd
parent60acd41c1941e1bea9e32377d310f065dd14e311 (diff)
downloademacs-6d912ee1a79392e3fcfa4f7932b0587560e2bfb6.tar.gz
emacs-6d912ee1a79392e3fcfa4f7932b0587560e2bfb6.zip
(customize-mark-to-save, customize-mark-as-set)
(custom-quote): Moved here from `cus-edit.el'.
-rw-r--r--lisp/ChangeLog9
-rw-r--r--lisp/custom.el67
2 files changed, 75 insertions, 1 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 27ef4505318..6bce5295b7b 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,10 @@
12002-04-19 Miles Bader <miles@gnu.org>
2
3 * custom.el (customize-mark-to-save, customize-mark-as-set)
4 (custom-quote): Moved here from `cus-edit.el'.
5 * cus-edit.el (customize-mark-to-save, customize-mark-as-set)
6 (custom-quote): Moved to `custom.el'.
7
12002-04-18 Richard M. Stallman <rms@gnu.org> 82002-04-18 Richard M. Stallman <rms@gnu.org>
2 9
3 * facemenu.el (list-text-properties-at): Command deleted. 10 * facemenu.el (list-text-properties-at): Command deleted.
@@ -61,7 +68,7 @@
61 68
62 * term.el (term-emulate-terminal): Fix last change. 69 * term.el (term-emulate-terminal): Fix last change.
63 70
642002-04-16 Pavel Jan,Bm(Bk <Pavel@Janik.cz> 712002-04-16 Pavel Jan,Am(Bk <Pavel@Janik.cz>
65 72
66 * bindings.el (mode-line-mode-menu): Update names to reflect 73 * bindings.el (mode-line-mode-menu): Update names to reflect
67 latest changes. 74 latest changes.
diff --git a/lisp/custom.el b/lisp/custom.el
index f7c0e0e0ee9..cae8450c968 100644
--- a/lisp/custom.el
+++ b/lisp/custom.el
@@ -549,6 +549,73 @@ this sets the local binding in that buffer instead."
549 (set variable value)) 549 (set variable value))
550 (set-default variable value))) 550 (set-default variable value)))
551 551
552(defun custom-quote (sexp)
553 "Quote SEXP iff it is not self quoting."
554 (if (or (memq sexp '(t nil))
555 (keywordp sexp)
556 (and (listp sexp)
557 (memq (car sexp) '(lambda)))
558 (stringp sexp)
559 (numberp sexp)
560 (vectorp sexp)
561;;; (and (fboundp 'characterp)
562;;; (characterp sexp))
563 )
564 sexp
565 (list 'quote sexp)))
566
567(defun customize-mark-to-save (symbol)
568 "Mark SYMBOL for later saving.
569
570If the default value of SYMBOL is different from the standard value,
571set the `saved-value' property to a list whose car evaluates to the
572default value. Otherwise, set it til nil.
573
574To actually save the value, call `custom-save-all'.
575
576Return non-nil iff the `saved-value' property actually changed."
577 (let* ((get (or (get symbol 'custom-get) 'default-value))
578 (value (funcall get symbol))
579 (saved (get symbol 'saved-value))
580 (standard (get symbol 'standard-value))
581 (comment (get symbol 'customized-variable-comment)))
582 ;; Save default value iff different from standard value.
583 (if (or (null standard)
584 (not (equal value (condition-case nil
585 (eval (car standard))
586 (error nil)))))
587 (put symbol 'saved-value (list (custom-quote value)))
588 (put symbol 'saved-value nil))
589 ;; Clear customized information (set, but not saved).
590 (put symbol 'customized-value nil)
591 ;; Save any comment that might have been set.
592 (when comment
593 (put symbol 'saved-variable-comment comment))
594 (not (equal saved (get symbol 'saved-value)))))
595
596(defun customize-mark-as-set (symbol)
597 "Mark current value of SYMBOL as being set from customize.
598
599If the default value of SYMBOL is different from the saved value if any,
600or else if it is different from the standard value, set the
601`customized-value' property to a list whose car evaluates to the
602default value. Otherwise, set it til nil.
603
604Return non-nil iff the `customized-value' property actually changed."
605 (let* ((get (or (get symbol 'custom-get) 'default-value))
606 (value (funcall get symbol))
607 (customized (get symbol 'customized-value))
608 (old (or (get symbol 'saved-value) (get symbol 'standard-value))))
609 ;; Mark default value as set iff different from old value.
610 (if (or (null old)
611 (not (equal value (condition-case nil
612 (eval (car old))
613 (error nil)))))
614 (put symbol 'customized-value (list (custom-quote value)))
615 (put symbol 'customized-value nil))
616 ;; Changed?
617 (not (equal customized (get symbol 'customized-value)))))
618
552;;; The End. 619;;; The End.
553 620
554;; Process the defcustoms for variables loaded before this file. 621;; Process the defcustoms for variables loaded before this file.