/[emacs]/emacs/lisp/custom.el
ViewVC logotype

Diff of /emacs/lisp/custom.el

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.80 by teirllm, Sat Feb 12 17:56:32 2005 UTC revision 1.81 by monnier, Sun Mar 6 00:27:53 2005 UTC
# Line 1  Line 1 
1  ;;; custom.el --- tools for declaring and initializing options  ;;; custom.el --- tools for declaring and initializing options
2  ;;  ;;
3  ;; Copyright (C) 1996, 1997, 1999, 2001, 2002, 2004  ;; Copyright (C) 1996, 1997, 1999, 2001, 2002, 2004, 2005
4  ;;  Free Software Foundation, Inc.  ;;  Free Software Foundation, Inc.
5  ;;  ;;
6  ;; Author: Per Abrahamsen <abraham@dina.kvl.dk>  ;; Author: Per Abrahamsen <abraham@dina.kvl.dk>
# Line 726  handle SYMBOL properly. Line 726  handle SYMBOL properly.
726  COMMENT is a comment string about SYMBOL."  COMMENT is a comment string about SYMBOL."
727    (apply 'custom-theme-set-variables 'user args))    (apply 'custom-theme-set-variables 'user args))
728    
729    (defun custom-reevaluate-setting (symbol)
730      "Reset the value of SYMBOL by re-evaluating its saved or default value.
731    This is useful for variables that are defined before their default value
732    can really be computed.  E.g. dumped variables whose default depends on
733    run-time information."
734      (funcall (or (get symbol 'custom-set) 'set-default)
735               symbol
736               (eval (car (or (get symbol 'saved-value) (get symbol 'standard-value))))))
737    
738  (defun custom-theme-set-variables (theme &rest args)  (defun custom-theme-set-variables (theme &rest args)
739    "Initialize variables for theme THEME according to settings in ARGS.    "Initialize variables for theme THEME according to settings in ARGS.
740  Each of the arguments in ARGS should be a list of this form:  Each of the arguments in ARGS should be a list of this form:
# Line 753  SYMBOL's property `force-value' is set t Line 762  SYMBOL's property `force-value' is set t
762  EXP itself is saved unevaluated as SYMBOL property `saved-value' and  EXP itself is saved unevaluated as SYMBOL property `saved-value' and
763  in SYMBOL's list property `theme-value' \(using `custom-push-theme')."  in SYMBOL's list property `theme-value' \(using `custom-push-theme')."
764    (custom-check-theme theme)    (custom-check-theme theme)
765    (let ((immediate (get theme 'theme-immediate)))    (setq args
766      (setq args          (sort args
767            (sort args                (lambda (a1 a2)
768                  (lambda (a1 a2)                  (let* ((sym1 (car a1))
769                    (let* ((sym1 (car a1))                         (sym2 (car a2))
770                           (sym2 (car a2))                         (1-then-2 (memq sym1 (get sym2 'custom-dependencies)))
771                           (1-then-2 (memq sym1 (get sym2 'custom-dependencies)))                         (2-then-1 (memq sym2 (get sym1 'custom-dependencies))))
772                           (2-then-1 (memq sym2 (get sym1 'custom-dependencies))))                    (cond ((and 1-then-2 2-then-1)
773                      (cond ((and 1-then-2 2-then-1)                           (error "Circular custom dependency between `%s' and `%s'"
774                             (error "Circular custom dependency between `%s' and `%s'"                                  sym1 sym2))
775                                    sym1 sym2))                          (2-then-1 nil)
776                            (2-then-1 nil)                          ;; Put symbols with :require last.  The macro
777                            ;; Put symbols with :require last.  The macro                          ;; define-minor-mode generates a defcustom
778                            ;; define-minor-mode generates a defcustom                          ;; with a :require and a :set, where the
779                            ;; with a :require and a :set, where the                          ;; setter function calls the mode function.
780                            ;; setter function calls the mode function.                          ;; Putting symbols with :require last ensures
781                            ;; Putting symbols with :require last ensures                          ;; that the mode function will see other
782                            ;; that the mode function will see other                          ;; customized values rather than default
783                            ;; customized values rather than default                          ;; values.
784                            ;; values.                          (t (nth 3 a2)))))))
785                            (t (nth 3 a2)))))))    (while args
786      (while args      (let ((entry (car args)))
787        (let ((entry (car args)))        (if (listp entry)
788          (if (listp entry)            (let* ((symbol (indirect-variable (nth 0 entry)))
789              (let* ((symbol (indirect-variable (nth 0 entry)))                   (value (nth 1 entry))
790                     (value (nth 1 entry))                   (now (nth 2 entry))
791                     (now (nth 2 entry))                   (requests (nth 3 entry))
792                     (requests (nth 3 entry))                   (comment (nth 4 entry))
793                     (comment (nth 4 entry))                   set)
794                     set)              (when requests
795                (when requests                (put symbol 'custom-requests requests)
796                  (put symbol 'custom-requests requests)                (mapc 'require requests))
797                  (mapc 'require requests))              (setq set (or (get symbol 'custom-set) 'custom-set-default))
798                (setq set (or (get symbol 'custom-set) 'custom-set-default))              (put symbol 'saved-value (list value))
799                (put symbol 'saved-value (list value))              (put symbol 'saved-variable-comment comment)
800                (put symbol 'saved-variable-comment comment)              (custom-push-theme 'theme-value symbol theme 'set value)
801                (custom-push-theme 'theme-value symbol theme 'set value)              ;; Allow for errors in the case where the setter has
               ;; Allow for errors in the case where the setter has  
802              ;; changed between versions, say, but let the user know.              ;; changed between versions, say, but let the user know.
803              (condition-case data              (condition-case data
804                  (cond (now                  (cond (now
# Line 802  in SYMBOL's list property `theme-value' Line 810  in SYMBOL's list property `theme-value'
810                         (funcall set symbol (eval value))))                         (funcall set symbol (eval value))))
811                (error                (error
812                 (message "Error setting %s: %s" symbol data)))                 (message "Error setting %s: %s" symbol data)))
813                (setq args (cdr args))              (setq args (cdr args))
814                (and (or now (default-boundp symbol))              (and (or now (default-boundp symbol))
815                     (put symbol 'variable-comment comment)))                   (put symbol 'variable-comment comment)))
816            ;; Old format, a plist of SYMBOL VALUE pairs.          ;; Old format, a plist of SYMBOL VALUE pairs.
817            (message "Warning: old format `custom-set-variables'")          (message "Warning: old format `custom-set-variables'")
818            (ding)          (ding)
819            (sit-for 2)          (sit-for 2)
820            (let ((symbol (indirect-variable (nth 0 args)))          (let ((symbol (indirect-variable (nth 0 args)))
821                  (value (nth 1 args)))                (value (nth 1 args)))
822              (put symbol 'saved-value (list value))            (put symbol 'saved-value (list value))
823              (custom-push-theme 'theme-value symbol theme 'set value))            (custom-push-theme 'theme-value symbol theme 'set value))
824            (setq args (cdr (cdr args))))))))          (setq args (cdr (cdr args)))))))
825    
826  (defun custom-set-default (variable value)  (defun custom-set-default (variable value)
827    "Default :set function for a customizable variable.    "Default :set function for a customizable variable.
# Line 1091  This means reset VARIABLE to its value i Line 1099  This means reset VARIABLE to its value i
1099    
1100  (provide 'custom)  (provide 'custom)
1101    
1102  ;;; arch-tag: 041b6116-aabe-4f9a-902d-74092bc3dab2  ;; arch-tag: 041b6116-aabe-4f9a-902d-74092bc3dab2
1103  ;;; custom.el ends here  ;;; custom.el ends here

Legend:
Removed from v.1.80  
changed lines
  Added in v.1.81

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26