diff options
| author | Luc Teirlinck | 2005-07-10 16:32:59 +0000 |
|---|---|---|
| committer | Luc Teirlinck | 2005-07-10 16:32:59 +0000 |
| commit | ff48d7e6f0f31c47c56c55359536e6bc275363aa (patch) | |
| tree | a1f4b5a87812c2b4fb48dbd115ae2b87781eebf8 | |
| parent | 72df78c9e8bf9db8595e8f8e728ca62d9b48be27 (diff) | |
| download | emacs-ff48d7e6f0f31c47c56c55359536e6bc275363aa.tar.gz emacs-ff48d7e6f0f31c47c56c55359536e6bc275363aa.zip | |
(custom-initialize-safe-set, custom-initialize-safe-default): New functions.
| -rw-r--r-- | lisp/custom.el | 22 |
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." | |||
| 76 | (eval (car (get symbol 'saved-value))) | 76 | (eval (car (get symbol 'saved-value))) |
| 77 | (eval value))))) | 77 | (eval value))))) |
| 78 | 78 | ||
| 79 | (defun custom-initialize-safe-set (symbol value) | ||
| 80 | "Like `custom-initialize-set', but catches errors. | ||
| 81 | If an error occurs during initialization, SYMBOL is set to nil | ||
| 82 | and no error is thrown. This is meant for use in pre-loaded files | ||
| 83 | where some variables used to compute VALUE are not yet defined. | ||
| 84 | You can then re-evaluate VALUE in startup.el, for instance using | ||
| 85 | `custom-reevaluate-setting'." | ||
| 86 | (condition-case nil | ||
| 87 | (custom-initialize-set symbol value) | ||
| 88 | (error (set-default symbol nil)))) | ||
| 89 | |||
| 90 | (defun custom-initialize-safe-default (symbol value) | ||
| 91 | "Like `custom-initialize-default', but catches errors. | ||
| 92 | If an error occurs during initialization, SYMBOL is set to nil | ||
| 93 | and no error is thrown. This is meant for use in pre-loaded files | ||
| 94 | where some variables used to compute VALUE are not yet defined. | ||
| 95 | You can then re-evaluate VALUE in startup.el, for instance using | ||
| 96 | `custom-reevaluate-setting'." | ||
| 97 | (condition-case nil | ||
| 98 | (custom-initialize-default symbol value) | ||
| 99 | (error (set-default symbol nil)))) | ||
| 100 | |||
| 79 | (defun custom-initialize-reset (symbol value) | 101 | (defun custom-initialize-reset (symbol value) |
| 80 | "Initialize SYMBOL based on VALUE. | 102 | "Initialize SYMBOL based on VALUE. |
| 81 | Set the symbol, using its `:set' function (or `set-default' if it has none). | 103 | Set the symbol, using its `:set' function (or `set-default' if it has none). |