changeset 64200:25277c60733f

(custom-initialize-safe-set, custom-initialize-safe-default): New functions.
author Luc Teirlinck <teirllm@auburn.edu>
date Sun, 10 Jul 2005 16:32:59 +0000
parents 9e93a9a7409a
children 43f2b7f50a25
files lisp/custom.el
diffstat 1 files changed, 22 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/custom.el	Sun Jul 10 14:47:45 2005 +0000
+++ b/lisp/custom.el	Sun Jul 10 16:32:59 2005 +0000
@@ -76,6 +76,28 @@
 		 (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).