aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/custom.el
diff options
context:
space:
mode:
authorChong Yidong2006-01-02 15:18:08 +0000
committerChong Yidong2006-01-02 15:18:08 +0000
commitc2e2f9be2c104f1c151fd31ca979ac57a6298e4a (patch)
tree9e9d565270367eb7f36c58fde3205d7d114234cb /lisp/custom.el
parentd358aa106d66961f4750337f3a5b3048a44e4069 (diff)
downloademacs-c2e2f9be2c104f1c151fd31ca979ac57a6298e4a.tar.gz
emacs-c2e2f9be2c104f1c151fd31ca979ac57a6298e4a.zip
Change ordering so all the Custom Themes code is in one place.
Fix docstring for custom-theme-set-variables.
Diffstat (limited to 'lisp/custom.el')
-rw-r--r--lisp/custom.el221
1 files changed, 107 insertions, 114 deletions
diff --git a/lisp/custom.el b/lisp/custom.el
index 7741ce2e933..5c89f928f0c 100644
--- a/lisp/custom.el
+++ b/lisp/custom.el
@@ -599,6 +599,112 @@ This recursively follows aliases."
599 ((equal load "cus-edit")) 599 ((equal load "cus-edit"))
600 (t (condition-case nil (load load) (error nil)))))))) 600 (t (condition-case nil (load load) (error nil))))))))
601 601
602(defvar custom-local-buffer nil
603 "Non-nil, in a Customization buffer, means customize a specific buffer.
604If this variable is non-nil, it should be a buffer,
605and it means customize the local bindings of that buffer.
606This variable is a permanent local, and it normally has a local binding
607in every Customization buffer.")
608(put 'custom-local-buffer 'permanent-local t)
609
610(defun custom-set-default (variable value)
611 "Default :set function for a customizable variable.
612Normally, this sets the default value of VARIABLE to VALUE,
613but if `custom-local-buffer' is non-nil,
614this sets the local binding in that buffer instead."
615 (if custom-local-buffer
616 (with-current-buffer custom-local-buffer
617 (set variable value))
618 (set-default variable value)))
619
620(defun custom-set-minor-mode (variable value)
621 ":set function for minor mode variables.
622Normally, this sets the default value of VARIABLE to nil if VALUE
623is nil and to t otherwise,
624but if `custom-local-buffer' is non-nil,
625this sets the local binding in that buffer instead."
626 (if custom-local-buffer
627 (with-current-buffer custom-local-buffer
628 (funcall variable (if value 1 0)))
629 (funcall variable (if value 1 0))))
630
631(defun custom-quote (sexp)
632 "Quote SEXP iff it is not self quoting."
633 (if (or (memq sexp '(t nil))
634 (keywordp sexp)
635 (and (listp sexp)
636 (memq (car sexp) '(lambda)))
637 (stringp sexp)
638 (numberp sexp)
639 (vectorp sexp)
640;;; (and (fboundp 'characterp)
641;;; (characterp sexp))
642 )
643 sexp
644 (list 'quote sexp)))
645
646(defun customize-mark-to-save (symbol)
647 "Mark SYMBOL for later saving.
648
649If the default value of SYMBOL is different from the standard value,
650set the `saved-value' property to a list whose car evaluates to the
651default value. Otherwise, set it to nil.
652
653To actually save the value, call `custom-save-all'.
654
655Return non-nil iff the `saved-value' property actually changed."
656 (let* ((get (or (get symbol 'custom-get) 'default-value))
657 (value (funcall get symbol))
658 (saved (get symbol 'saved-value))
659 (standard (get symbol 'standard-value))
660 (comment (get symbol 'customized-variable-comment)))
661 ;; Save default value iff different from standard value.
662 (if (or (null standard)
663 (not (equal value (condition-case nil
664 (eval (car standard))
665 (error nil)))))
666 (put symbol 'saved-value (list (custom-quote value)))
667 (put symbol 'saved-value nil))
668 ;; Clear customized information (set, but not saved).
669 (put symbol 'customized-value nil)
670 ;; Save any comment that might have been set.
671 (when comment
672 (put symbol 'saved-variable-comment comment))
673 (not (equal saved (get symbol 'saved-value)))))
674
675(defun customize-mark-as-set (symbol)
676 "Mark current value of SYMBOL as being set from customize.
677
678If the default value of SYMBOL is different from the saved value if any,
679or else if it is different from the standard value, set the
680`customized-value' property to a list whose car evaluates to the
681default value. Otherwise, set it to nil.
682
683Return non-nil iff the `customized-value' property actually changed."
684 (let* ((get (or (get symbol 'custom-get) 'default-value))
685 (value (funcall get symbol))
686 (customized (get symbol 'customized-value))
687 (old (or (get symbol 'saved-value) (get symbol 'standard-value))))
688 ;; Mark default value as set iff different from old value.
689 (if (or (null old)
690 (not (equal value (condition-case nil
691 (eval (car old))
692 (error nil)))))
693 (put symbol 'customized-value (list (custom-quote value)))
694 (put symbol 'customized-value nil))
695 ;; Changed?
696 (not (equal customized (get symbol 'customized-value)))))
697
698(defun custom-reevaluate-setting (symbol)
699 "Reset the value of SYMBOL by re-evaluating its saved or standard value.
700Use the :set function to do so. This is useful for customizable options
701that are defined before their standard value can really be computed.
702E.g. dumped variables whose default depends on run-time information."
703 (funcall (or (get symbol 'custom-set) 'set-default)
704 symbol
705 (eval (car (or (get symbol 'saved-value) (get symbol 'standard-value))))))
706
707
602;;; Custom Themes 708;;; Custom Themes
603 709
604;; Custom themes are collections of settings that can be enabled or 710;; Custom themes are collections of settings that can be enabled or
@@ -718,15 +824,8 @@ See `custom-known-themes' for a list of known themes."
718 (put theme 'theme-settings 824 (put theme 'theme-settings
719 (cons (list prop symbol theme value) 825 (cons (list prop symbol theme value)
720 theme-settings)))))) 826 theme-settings))))))
721
722(defvar custom-local-buffer nil
723 "Non-nil, in a Customization buffer, means customize a specific buffer.
724If this variable is non-nil, it should be a buffer,
725and it means customize the local bindings of that buffer.
726This variable is a permanent local, and it normally has a local binding
727in every Customization buffer.")
728(put 'custom-local-buffer 'permanent-local t)
729 827
828
730(defun custom-set-variables (&rest args) 829(defun custom-set-variables (&rest args)
731 "Install user customizations of variable values specified in ARGS. 830 "Install user customizations of variable values specified in ARGS.
732These settings are registered as theme `user'. 831These settings are registered as theme `user'.
@@ -743,15 +842,6 @@ handle SYMBOL properly.
743COMMENT is a comment string about SYMBOL." 842COMMENT is a comment string about SYMBOL."
744 (apply 'custom-theme-set-variables 'user args)) 843 (apply 'custom-theme-set-variables 'user args))
745 844
746(defun custom-reevaluate-setting (symbol)
747 "Reset the value of SYMBOL by re-evaluating its saved or standard value.
748Use the :set function to do so. This is useful for customizable options
749that are defined before their standard value can really be computed.
750E.g. dumped variables whose default depends on run-time information."
751 (funcall (or (get symbol 'custom-set) 'set-default)
752 symbol
753 (eval (car (or (get symbol 'saved-value) (get symbol 'standard-value))))))
754
755(defun custom-theme-set-variables (theme &rest args) 845(defun custom-theme-set-variables (theme &rest args)
756 "Initialize variables for theme THEME according to settings in ARGS. 846 "Initialize variables for theme THEME according to settings in ARGS.
757Each of the arguments in ARGS should be a list of this form: 847Each of the arguments in ARGS should be a list of this form:
@@ -766,16 +856,6 @@ REQUEST is a list of features we must require in order to
766handle SYMBOL properly. 856handle SYMBOL properly.
767COMMENT is a comment string about SYMBOL. 857COMMENT is a comment string about SYMBOL.
768 858
769Several properties of THEME and SYMBOL are used in the process:
770
771If THEME's property `theme-immediate' is non-nil, this is equivalent of
772providing the NOW argument to all symbols in the argument list:
773evaluate each EXP and set the corresponding SYMBOL. However,
774there's a difference in the handling of SYMBOL's property
775`force-value': if NOW is non-nil, SYMBOL's property `force-value' is set to
776the symbol `rogue', else if THEME's property `theme-immediate' is non-nil,
777SYMBOL's property `force-value' is set to the symbol `immediate'.
778
779EXP itself is saved unevaluated as SYMBOL property `saved-value' and 859EXP itself is saved unevaluated as SYMBOL property `saved-value' and
780in SYMBOL's list property `theme-value' \(using `custom-push-theme')." 860in SYMBOL's list property `theme-value' \(using `custom-push-theme')."
781 (custom-check-theme theme) 861 (custom-check-theme theme)
@@ -838,93 +918,6 @@ in SYMBOL's list property `theme-value' \(using `custom-push-theme')."
838 (custom-push-theme 'theme-value symbol theme 'set value)) 918 (custom-push-theme 'theme-value symbol theme 'set value))
839 (setq args (cdr (cdr args))))))) 919 (setq args (cdr (cdr args)))))))
840 920
841(defun custom-set-default (variable value)
842 "Default :set function for a customizable variable.
843Normally, this sets the default value of VARIABLE to VALUE,
844but if `custom-local-buffer' is non-nil,
845this sets the local binding in that buffer instead."
846 (if custom-local-buffer
847 (with-current-buffer custom-local-buffer
848 (set variable value))
849 (set-default variable value)))
850
851(defun custom-set-minor-mode (variable value)
852 ":set function for minor mode variables.
853Normally, this sets the default value of VARIABLE to nil if VALUE
854is nil and to t otherwise,
855but if `custom-local-buffer' is non-nil,
856this sets the local binding in that buffer instead."
857 (if custom-local-buffer
858 (with-current-buffer custom-local-buffer
859 (funcall variable (if value 1 0)))
860 (funcall variable (if value 1 0))))
861
862(defun custom-quote (sexp)
863 "Quote SEXP iff it is not self quoting."
864 (if (or (memq sexp '(t nil))
865 (keywordp sexp)
866 (and (listp sexp)
867 (memq (car sexp) '(lambda)))
868 (stringp sexp)
869 (numberp sexp)
870 (vectorp sexp)
871;;; (and (fboundp 'characterp)
872;;; (characterp sexp))
873 )
874 sexp
875 (list 'quote sexp)))
876
877(defun customize-mark-to-save (symbol)
878 "Mark SYMBOL for later saving.
879
880If the default value of SYMBOL is different from the standard value,
881set the `saved-value' property to a list whose car evaluates to the
882default value. Otherwise, set it to nil.
883
884To actually save the value, call `custom-save-all'.
885
886Return non-nil iff the `saved-value' property actually changed."
887 (let* ((get (or (get symbol 'custom-get) 'default-value))
888 (value (funcall get symbol))
889 (saved (get symbol 'saved-value))
890 (standard (get symbol 'standard-value))
891 (comment (get symbol 'customized-variable-comment)))
892 ;; Save default value iff different from standard value.
893 (if (or (null standard)
894 (not (equal value (condition-case nil
895 (eval (car standard))
896 (error nil)))))
897 (put symbol 'saved-value (list (custom-quote value)))
898 (put symbol 'saved-value nil))
899 ;; Clear customized information (set, but not saved).
900 (put symbol 'customized-value nil)
901 ;; Save any comment that might have been set.
902 (when comment
903 (put symbol 'saved-variable-comment comment))
904 (not (equal saved (get symbol 'saved-value)))))
905
906(defun customize-mark-as-set (symbol)
907 "Mark current value of SYMBOL as being set from customize.
908
909If the default value of SYMBOL is different from the saved value if any,
910or else if it is different from the standard value, set the
911`customized-value' property to a list whose car evaluates to the
912default value. Otherwise, set it to nil.
913
914Return non-nil iff the `customized-value' property actually changed."
915 (let* ((get (or (get symbol 'custom-get) 'default-value))
916 (value (funcall get symbol))
917 (customized (get symbol 'customized-value))
918 (old (or (get symbol 'saved-value) (get symbol 'standard-value))))
919 ;; Mark default value as set iff different from old value.
920 (if (or (null old)
921 (not (equal value (condition-case nil
922 (eval (car old))
923 (error nil)))))
924 (put symbol 'customized-value (list (custom-quote value)))
925 (put symbol 'customized-value nil))
926 ;; Changed?
927 (not (equal customized (get symbol 'customized-value)))))
928 921
929;;; Defining themes. 922;;; Defining themes.
930 923