aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/custom.el
diff options
context:
space:
mode:
authorStefan Monnier2011-03-01 00:03:24 -0500
committerStefan Monnier2011-03-01 00:03:24 -0500
commitd032d5e7dfabfae60f3304da02c97cd1e189b9a2 (patch)
tree64219849ec4b697e19a1da1c2a5786b61a2c3387 /lisp/custom.el
parent39605a343b566a1a72e0afb61f96d085c2ef8054 (diff)
downloademacs-d032d5e7dfabfae60f3304da02c97cd1e189b9a2.tar.gz
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.el39
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
55the car of that and use it as the default binding for symbol. 55the car of that and use it as the default binding for symbol.
56Otherwise, VALUE will be evaluated and used as the default binding for 56Otherwise, VALUE will be evaluated and used as the default binding for
57symbol." 57symbol."
58 (unless (default-boundp symbol) 58 (eval `(defvar ,symbol ,(if (get symbol 'saved-value)
59 ;; Use the saved value if it exists, otherwise the standard setting. 59 (car (get symbol 'saved-value))
60 (set-default symbol (eval (if (get symbol 'saved-value) 60 value))))
61 (car (get symbol 'saved-value))
62 value)))))
63 61
64(defun custom-initialize-set (symbol value) 62(defun custom-initialize-set (symbol value)
65 "Initialize SYMBOL based on VALUE. 63 "Initialize SYMBOL based on VALUE.
@@ -81,15 +79,15 @@ The value is either the symbol's current value
81 \(as obtained using the `:get' function), if any, 79 \(as obtained using the `:get' function), if any,
82or the value in the symbol's `saved-value' property if any, 80or the value in the symbol's `saved-value' property if any,
83or (last of all) VALUE." 81or (last of all) VALUE."
84 (funcall (or (get symbol 'custom-set) 'set-default) 82 (funcall (or (get symbol 'custom-set) 'set-default)
85 symbol 83 symbol
86 (cond ((default-boundp symbol) 84 (cond ((default-boundp symbol)
87 (funcall (or (get symbol 'custom-get) 'default-value) 85 (funcall (or (get symbol 'custom-get) 'default-value)
88 symbol)) 86 symbol))
89 ((get symbol 'saved-value) 87 ((get symbol 'saved-value)
90 (eval (car (get symbol 'saved-value)))) 88 (eval (car (get symbol 'saved-value))))
91 (t 89 (t
92 (eval value))))) 90 (eval value)))))
93 91
94(defun custom-initialize-changed (symbol value) 92(defun custom-initialize-changed (symbol value)
95 "Initialize SYMBOL with VALUE. 93 "Initialize SYMBOL with VALUE.
@@ -142,10 +140,8 @@ set to nil, as the value is no longer rogue."
142 ;; Maybe this option was rogue in an earlier version. It no longer is. 140 ;; Maybe this option was rogue in an earlier version. It no longer is.
143 (when (get symbol 'force-value) 141 (when (get symbol 'force-value)
144 (put symbol 'force-value nil)) 142 (put symbol 'force-value nil))
145 (when doc 143 (if (keywordp doc)
146 (if (keywordp doc) 144 (error "Doc string is missing"))
147 (error "Doc string is missing")
148 (put symbol 'variable-documentation doc)))
149 (let ((initialize 'custom-initialize-reset) 145 (let ((initialize 'custom-initialize-reset)
150 (requests nil)) 146 (requests nil))
151 (unless (memq :group args) 147 (unless (memq :group args)
@@ -189,6 +185,13 @@ set to nil, as the value is no longer rogue."
189 ;; Do the actual initialization. 185 ;; Do the actual initialization.
190 (unless custom-dont-initialize 186 (unless custom-dont-initialize
191 (funcall initialize symbol default))) 187 (funcall initialize symbol default)))
188 ;; Use defvar to set the docstring as well as the special-variable-p flag.
189 ;; FIXME: We should reproduce more of `defvar's behavior, such as the warning
190 ;; when the var is currently let-bound.
191 (if (not (default-boundp symbol))
192 ;; Don't use defvar to avoid setting a default-value when undesired.
193 (when doc (put symbol 'variable-documentation doc))
194 (eval `(defvar ,symbol nil ,@(when doc (list doc)))))
192 (push symbol current-load-list) 195 (push symbol current-load-list)
193 (run-hooks 'custom-define-hook) 196 (run-hooks 'custom-define-hook)
194 symbol) 197 symbol)