From: Luc Teirlinck Date: Sun, 10 Jul 2005 16:32:59 +0000 (+0000) Subject: (custom-initialize-safe-set, custom-initialize-safe-default): New functions. X-Git-Tag: emacs-pretest-22.0.90~8257 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=ff48d7e6f0f31c47c56c55359536e6bc275363aa;p=emacs.git (custom-initialize-safe-set, custom-initialize-safe-default): New functions. --- 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).