diff options
author | Stefan Monnier <monnier@iro.umontreal.ca> | 2011-03-01 00:03:24 -0500 |
---|---|---|
committer | Stefan Monnier <monnier@iro.umontreal.ca> | 2011-03-01 00:03:24 -0500 |
commit | d032d5e7dfabfae60f3304da02c97cd1e189b9a2 (patch) | |
tree | 64219849ec4b697e19a1da1c2a5786b61a2c3387 /lisp/custom.el | |
parent | 39605a343b566a1a72e0afb61f96d085c2ef8054 (diff) | |
download | emacs-d032d5e7dfabfae60f3304da02c97cd1e189b9a2.tar.gz emacs-d032d5e7dfabfae60f3304da02c97cd1e189b9a2.tar.bz2 emacs-d032d5e7dfabfae60f3304da02c97cd1e189b9a2.zip |
* doc/lispref/variables.texi (Scope): Mention the availability of lexbind.
(Lexical Binding): New node.
* doc/lispref/eval.texi (Eval): Add `eval's new `lexical' arg.
* lisp/emacs-lisp/cconv.el (cconv-liftwhen): Increase threshold.
(cconv-closure-convert-rec): Convert interactive spec in empty lexenv.
(cconv-analyse-use): Improve unused vars warnings.
(cconv-analyse-form): Analyze interactive spec in empty lexenv.
* lisp/emacs-lisp/bytecomp.el (byte-compile-lambda): Always byte-compile
the interactive spec in lexical-binding mode.
(byte-compile-refresh-preloaded): Don't reload byte-compiler files.
* lisp/custom.el (custom-initialize-default): Use defvar.
(custom-declare-variable): Set the special-variable-p flag.
* lisp/help-fns.el (help-make-usage): Drop leading underscores.
* lisp/dired.el (dired-revert, dired-make-relative): Mark unused args.
(dired-unmark-all-files): Remove unused var `query'.
(dired-overwrite-confirmed): Declare.
(dired-restore-desktop-buffer): Don't use dynamically scoped arg names.
* lisp/mpc.el: Mark unused args.
(mpc--faster-toggle): Remove unused var `songnb'.
* lisp/server.el (server-kill-buffer-running): Move before first use.
* lisp/minibuffer.el: Mark unused args.
* src/callint.c (quotify_arg): Simplify the logic.
(Fcall_interactively): Use lexical binding when evaluating the
interactive spec of a lexically bound function.
Diffstat (limited to 'lisp/custom.el')
-rw-r--r-- | lisp/custom.el | 39 |
1 files changed, 21 insertions, 18 deletions
diff --git a/lisp/custom.el b/lisp/custom.el index e41e7c7bdf8..d0d11610b91 100644 --- a/lisp/custom.el +++ b/lisp/custom.el @@ -55,11 +55,9 @@ Otherwise, if symbol has a `saved-value' property, it will evaluate the car of that and use it as the default binding for symbol. Otherwise, VALUE will be evaluated and used as the default binding for symbol." - (unless (default-boundp symbol) - ;; Use the saved value if it exists, otherwise the standard setting. - (set-default symbol (eval (if (get symbol 'saved-value) - (car (get symbol 'saved-value)) - value))))) + (eval `(defvar ,symbol ,(if (get symbol 'saved-value) + (car (get symbol 'saved-value)) + value)))) (defun custom-initialize-set (symbol value) "Initialize SYMBOL based on VALUE. @@ -81,15 +79,15 @@ The value is either the symbol's current value \(as obtained using the `:get' function), if any, or the value in the symbol's `saved-value' property if any, or (last of all) VALUE." - (funcall (or (get symbol 'custom-set) 'set-default) - symbol - (cond ((default-boundp symbol) - (funcall (or (get symbol 'custom-get) 'default-value) - symbol)) - ((get symbol 'saved-value) - (eval (car (get symbol 'saved-value)))) - (t - (eval value))))) + (funcall (or (get symbol 'custom-set) 'set-default) + symbol + (cond ((default-boundp symbol) + (funcall (or (get symbol 'custom-get) 'default-value) + symbol)) + ((get symbol 'saved-value) + (eval (car (get symbol 'saved-value)))) + (t + (eval value))))) (defun custom-initialize-changed (symbol value) "Initialize SYMBOL with VALUE. @@ -142,10 +140,8 @@ set to nil, as the value is no longer rogue." ;; Maybe this option was rogue in an earlier version. It no longer is. (when (get symbol 'force-value) (put symbol 'force-value nil)) - (when doc - (if (keywordp doc) - (error "Doc string is missing") - (put symbol 'variable-documentation doc))) + (if (keywordp doc) + (error "Doc string is missing")) (let ((initialize 'custom-initialize-reset) (requests nil)) (unless (memq :group args) @@ -189,6 +185,13 @@ set to nil, as the value is no longer rogue." ;; Do the actual initialization. (unless custom-dont-initialize (funcall initialize symbol default))) + ;; Use defvar to set the docstring as well as the special-variable-p flag. + ;; FIXME: We should reproduce more of `defvar's behavior, such as the warning + ;; when the var is currently let-bound. + (if (not (default-boundp symbol)) + ;; Don't use defvar to avoid setting a default-value when undesired. + (when doc (put symbol 'variable-documentation doc)) + (eval `(defvar ,symbol nil ,@(when doc (list doc))))) (push symbol current-load-list) (run-hooks 'custom-define-hook) symbol) |