summaryrefslogtreecommitdiff
path: root/lisp/custom.el
diff options
context:
space:
mode:
authorLuc Teirlinck <teirllm@auburn.edu>2005-07-10 16:32:59 +0000
committerLuc Teirlinck <teirllm@auburn.edu>2005-07-10 16:32:59 +0000
commitff48d7e6f0f31c47c56c55359536e6bc275363aa (patch)
treea1f4b5a87812c2b4fb48dbd115ae2b87781eebf8 /lisp/custom.el
parent72df78c9e8bf9db8595e8f8e728ca62d9b48be27 (diff)
(custom-initialize-safe-set, custom-initialize-safe-default): New functions.
Diffstat (limited to 'lisp/custom.el')
-rw-r--r--lisp/custom.el22
1 files changed, 22 insertions, 0 deletions
diff --git a/lisp/custom.el b/lisp/custom.el
index 8c2c50b6454..3f8608361c6 100644
--- a/lisp/custom.el
+++ b/lisp/custom.el
@@ -76,6 +76,28 @@ if any, or VALUE."
(eval (car (get symbol 'saved-value)))
(eval value)))))
+(defun custom-initialize-safe-set (symbol value)
+ "Like `custom-initialize-set', but catches errors.
+If an error occurs during initialization, SYMBOL is set to nil
+and no error is thrown. This is meant for use in pre-loaded files
+where some variables used to compute VALUE are not yet defined.
+You can then re-evaluate VALUE in startup.el, for instance using
+`custom-reevaluate-setting'."
+ (condition-case nil
+ (custom-initialize-set symbol value)
+ (error (set-default symbol nil))))
+
+(defun custom-initialize-safe-default (symbol value)
+ "Like `custom-initialize-default', but catches errors.
+If an error occurs during initialization, SYMBOL is set to nil
+and no error is thrown. This is meant for use in pre-loaded files
+where some variables used to compute VALUE are not yet defined.
+You can then re-evaluate VALUE in startup.el, for instance using
+`custom-reevaluate-setting'."
+ (condition-case nil
+ (custom-initialize-default symbol value)
+ (error (set-default symbol nil))))
+
(defun custom-initialize-reset (symbol value)
"Initialize SYMBOL based on VALUE.
Set the symbol, using its `:set' function (or `set-default' if it has none).