aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2013-06-13 22:31:28 -0400
committerStefan Monnier2013-06-13 22:31:28 -0400
commit0b31660d3c10a0f8e243dd67bd0ecaf2c847d1e6 (patch)
treec98ad57350666702eb75c8c0978f8d7c8e55f8e7
parent99c812809854a1405ba879814b8ae9a09e82a5e4 (diff)
downloademacs-0b31660d3c10a0f8e243dd67bd0ecaf2c847d1e6.tar.gz
emacs-0b31660d3c10a0f8e243dd67bd0ecaf2c847d1e6.zip
* lisp/emacs-lisp/bytecomp.el (byte-compile-force-lexical-warnings): New var.
(byte-compile-preprocess): Use it. (byte-compile-file-form-defalias): Try a bit harder to use macros we can't quite recognize. (byte-compile-add-to-list): Remove. * lisp/emacs-lisp/cconv.el (cconv-warnings-only): New function. (cconv-closure-convert): Add assertion. * lisp/emacs-lisp/map-ynp.el: Use lexical-binding. (map-y-or-n-p): Remove unused vars `tail' and `object'. Factor out some repeated code. * etc/NEWS (utf-8 for el): Move to the incompatible section.
-rw-r--r--etc/ChangeLog4
-rw-r--r--etc/NEWS13
-rw-r--r--lisp/ChangeLog14
-rw-r--r--lisp/emacs-lisp/byte-opt.el1
-rw-r--r--lisp/emacs-lisp/bytecomp.el35
-rw-r--r--lisp/emacs-lisp/cconv.el14
-rw-r--r--lisp/emacs-lisp/map-ynp.el48
7 files changed, 69 insertions, 60 deletions
diff --git a/etc/ChangeLog b/etc/ChangeLog
index a31c6ff944e..1892d5fbb58 100644
--- a/etc/ChangeLog
+++ b/etc/ChangeLog
@@ -1,3 +1,7 @@
12013-06-14 Stefan Monnier <monnier@iro.umontreal.ca>
2
3 * NEWS (utf-8 for el): Move to the incompatible section.
4
12013-06-13 Paul Eggert <eggert@cs.ucla.edu> 52013-06-13 Paul Eggert <eggert@cs.ucla.edu>
2 6
3 * DEBUG: Document -Og and -fno-omit-frame-pointer. 7 * DEBUG: Document -Og and -fno-omit-frame-pointer.
diff --git a/etc/NEWS b/etc/NEWS
index 0501b4e97e2..1361b2491e6 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -414,6 +414,12 @@ It is layered as:
414 414
415* Incompatible Lisp Changes in Emacs 24.4 415* Incompatible Lisp Changes in Emacs 24.4
416 416
417** The default file coding for Emacs Lisp files is now utf-8.
418(See file-coding-system-alist.) In most cases, this change is transparent, but
419files that contain unusual characters without specifying an explicit coding
420system may fail to load with obscure errors.
421You should either convert them to utf-8 or add an explicit coding: cookie.
422
417** overriding-terminal-local-map does not replace the local keymaps any more. 423** overriding-terminal-local-map does not replace the local keymaps any more.
418It used to disable the minor mode, major mode, and text-property keymaps, 424It used to disable the minor mode, major mode, and text-property keymaps,
419whereas now it simply has higher precedence. 425whereas now it simply has higher precedence.
@@ -455,13 +461,6 @@ file using `set-file-extended-attributes'.
455+++ 461+++
456** New macro with-eval-after-load. Like eval-after-load, but better behaved. 462** New macro with-eval-after-load. Like eval-after-load, but better behaved.
457 463
458** The default file coding for Emacs Lisp files is now utf-8.
459(See file-coding-system-alist.) In most cases, this change is
460totally transparent. Files that contain unusual characters but do
461not specify an explicit coding system may fail to load with obscure
462errors. You should either convert them to utf-8 or add an explicit
463coding: cookie.
464
465** Obsoleted functions: 464** Obsoleted functions:
466*** `dont-compile' 465*** `dont-compile'
467*** `lisp-complete-symbol' 466*** `lisp-complete-symbol'
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 095ec9010f1..875a361f57b 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,17 @@
12013-06-14 Stefan Monnier <monnier@iro.umontreal.ca>
2
3 * emacs-lisp/bytecomp.el (byte-compile-force-lexical-warnings): New var.
4 (byte-compile-preprocess): Use it.
5 (byte-compile-file-form-defalias): Try a bit harder to use macros we
6 can't quite recognize.
7 (byte-compile-add-to-list): Remove.
8 * emacs-lisp/cconv.el (cconv-warnings-only): New function.
9 (cconv-closure-convert): Add assertion.
10
11 * emacs-lisp/map-ynp.el: Use lexical-binding.
12 (map-y-or-n-p): Remove unused vars `tail' and `object'.
13 Factor out some repeated code.
14
12013-06-13 Stefan Monnier <monnier@iro.umontreal.ca> 152013-06-13 Stefan Monnier <monnier@iro.umontreal.ca>
2 16
3 * subr.el (with-eval-after-load): New macro. 17 * subr.el (with-eval-after-load): New macro.
diff --git a/lisp/emacs-lisp/byte-opt.el b/lisp/emacs-lisp/byte-opt.el
index 7375c2176ba..7214501362d 100644
--- a/lisp/emacs-lisp/byte-opt.el
+++ b/lisp/emacs-lisp/byte-opt.el
@@ -287,6 +287,7 @@
287 (byte-compile--reify-function fn))))) 287 (byte-compile--reify-function fn)))))
288 (if (eq (car-safe newfn) 'function) 288 (if (eq (car-safe newfn) 'function)
289 (byte-compile-unfold-lambda `(,(cadr newfn) ,@(cdr form))) 289 (byte-compile-unfold-lambda `(,(cadr newfn) ,@(cdr form)))
290 ;; This can happen because of macroexp-warn-and-return &co.
290 (byte-compile-log-warning 291 (byte-compile-log-warning
291 (format "Inlining closure %S failed" name)) 292 (format "Inlining closure %S failed" name))
292 form)))) 293 form))))
diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el
index e603f76f41d..391401ae5d6 100644
--- a/lisp/emacs-lisp/bytecomp.el
+++ b/lisp/emacs-lisp/bytecomp.el
@@ -2174,6 +2174,8 @@ list that represents a doc string reference.
2174 byte-compile-maxdepth 0 2174 byte-compile-maxdepth 0
2175 byte-compile-output nil)))) 2175 byte-compile-output nil))))
2176 2176
2177(defvar byte-compile-force-lexical-warnings nil)
2178
2177(defun byte-compile-preprocess (form &optional _for-effect) 2179(defun byte-compile-preprocess (form &optional _for-effect)
2178 (setq form (macroexpand-all form byte-compile-macro-environment)) 2180 (setq form (macroexpand-all form byte-compile-macro-environment))
2179 ;; FIXME: We should run byte-optimize-form here, but it currently does not 2181 ;; FIXME: We should run byte-optimize-form here, but it currently does not
@@ -2182,9 +2184,10 @@ list that represents a doc string reference.
2182 ;; macroexpand-all. 2184 ;; macroexpand-all.
2183 ;; (if (memq byte-optimize '(t source)) 2185 ;; (if (memq byte-optimize '(t source))
2184 ;; (setq form (byte-optimize-form form for-effect))) 2186 ;; (setq form (byte-optimize-form form for-effect)))
2185 (if lexical-binding 2187 (cond
2186 (cconv-closure-convert form) 2188 (lexical-binding (cconv-closure-convert form))
2187 form)) 2189 (byte-compile-force-lexical-warnings (cconv-warnings-only form))
2190 (t form)))
2188 2191
2189;; byte-hunk-handlers cannot call this! 2192;; byte-hunk-handlers cannot call this!
2190(defun byte-compile-toplevel-file-form (form) 2193(defun byte-compile-toplevel-file-form (form)
@@ -4240,6 +4243,12 @@ binding slots have been popped."
4240 lam)) 4243 lam))
4241 (unless (byte-compile-file-form-defmumble 4244 (unless (byte-compile-file-form-defmumble
4242 name macro arglist body rest) 4245 name macro arglist body rest)
4246 (when macro
4247 (if (null fun)
4248 (message "Macro %s unrecognized, won't work in file" name)
4249 (message "Macro %s partly recognized, trying our luck" name)
4250 (push (cons name (eval fun))
4251 byte-compile-macro-environment)))
4243 (byte-compile-keep-pending form)))) 4252 (byte-compile-keep-pending form))))
4244 4253
4245 ;; We used to just do: (byte-compile-normal-call form) 4254 ;; We used to just do: (byte-compile-normal-call form)
@@ -4268,26 +4277,6 @@ binding slots have been popped."
4268 'byte-hunk-handler 'byte-compile-form-make-variable-buffer-local) 4277 'byte-hunk-handler 'byte-compile-form-make-variable-buffer-local)
4269(defun byte-compile-form-make-variable-buffer-local (form) 4278(defun byte-compile-form-make-variable-buffer-local (form)
4270 (byte-compile-keep-pending form 'byte-compile-normal-call)) 4279 (byte-compile-keep-pending form 'byte-compile-normal-call))
4271
4272(byte-defop-compiler-1 add-to-list byte-compile-add-to-list)
4273(defun byte-compile-add-to-list (form)
4274 ;; FIXME: This could be used for `set' as well, except that it's got
4275 ;; its own opcode, so the final `byte-compile-normal-call' needs to
4276 ;; be replaced with something else.
4277 (pcase form
4278 (`(,fun ',var . ,_)
4279 (byte-compile-check-variable var 'assign)
4280 (if (assq var byte-compile--lexical-environment)
4281 (byte-compile-log-warning
4282 (format "%s cannot use lexical var `%s'" fun var)
4283 nil :error)
4284 (unless (or (not (byte-compile-warning-enabled-p 'free-vars))
4285 (boundp var)
4286 (memq var byte-compile-bound-variables)
4287 (memq var byte-compile-free-references))
4288 (byte-compile-warn "assignment to free variable `%S'" var)
4289 (push var byte-compile-free-references)))))
4290 (byte-compile-normal-call form))
4291 4280
4292;;; tags 4281;;; tags
4293 4282
diff --git a/lisp/emacs-lisp/cconv.el b/lisp/emacs-lisp/cconv.el
index 761e33c059d..70fa71a0da4 100644
--- a/lisp/emacs-lisp/cconv.el
+++ b/lisp/emacs-lisp/cconv.el
@@ -143,7 +143,19 @@ Returns a form where all lambdas don't have any free variables."
143 ;; Analyze form - fill these variables with new information. 143 ;; Analyze form - fill these variables with new information.
144 (cconv-analyse-form form '()) 144 (cconv-analyse-form form '())
145 (setq cconv-freevars-alist (nreverse cconv-freevars-alist)) 145 (setq cconv-freevars-alist (nreverse cconv-freevars-alist))
146 (cconv-convert form nil nil))) ; Env initially empty. 146 (prog1 (cconv-convert form nil nil) ; Env initially empty.
147 (cl-assert (null cconv-freevars-alist)))))
148
149;;;###autoload
150(defun cconv-warnings-only (form)
151 "Add the warnings that closure conversion would encounter."
152 (let ((cconv-freevars-alist '())
153 (cconv-lambda-candidates '())
154 (cconv-captured+mutated '()))
155 ;; Analyze form - fill these variables with new information.
156 (cconv-analyse-form form '())
157 ;; But don't perform the closure conversion.
158 form))
147 159
148(defconst cconv--dummy-var (make-symbol "ignored")) 160(defconst cconv--dummy-var (make-symbol "ignored"))
149 161
diff --git a/lisp/emacs-lisp/map-ynp.el b/lisp/emacs-lisp/map-ynp.el
index 13202a9ce4d..1919d47687b 100644
--- a/lisp/emacs-lisp/map-ynp.el
+++ b/lisp/emacs-lisp/map-ynp.el
@@ -1,4 +1,4 @@
1;;; map-ynp.el --- general-purpose boolean question-asker 1;;; map-ynp.el --- general-purpose boolean question-asker -*- lexical-binding:t -*-
2 2
3;; Copyright (C) 1991-1995, 2000-2013 Free Software Foundation, Inc. 3;; Copyright (C) 1991-1995, 2000-2013 Free Software Foundation, Inc.
4 4
@@ -79,7 +79,7 @@ are meaningful here.
79 79
80Returns the number of actions taken." 80Returns the number of actions taken."
81 (let* ((actions 0) 81 (let* ((actions 0)
82 user-keys mouse-event map prompt char elt tail def 82 user-keys mouse-event map prompt char elt def
83 ;; Non-nil means we should use mouse menus to ask. 83 ;; Non-nil means we should use mouse menus to ask.
84 use-menus 84 use-menus
85 delayed-switch-frame 85 delayed-switch-frame
@@ -89,13 +89,15 @@ Returns the number of actions taken."
89 (next (if (functionp list) 89 (next (if (functionp list)
90 (lambda () (setq elt (funcall list))) 90 (lambda () (setq elt (funcall list)))
91 (lambda () (when list 91 (lambda () (when list
92 (setq elt (pop list)) 92 (setq elt (pop list))
93 t))))) 93 t))))
94 (try-again (lambda ()
95 (let ((x next))
96 (setq next (lambda () (setq next x) elt))))))
94 (if (and (listp last-nonmenu-event) 97 (if (and (listp last-nonmenu-event)
95 use-dialog-box) 98 use-dialog-box)
96 ;; Make a list describing a dialog box. 99 ;; Make a list describing a dialog box.
97 (let ((object (if help (capitalize (nth 0 help)))) 100 (let ((objects (if help (capitalize (nth 1 help))))
98 (objects (if help (capitalize (nth 1 help))))
99 (action (if help (capitalize (nth 2 help))))) 101 (action (if help (capitalize (nth 2 help)))))
100 (setq map `(("Yes" . act) ("No" . skip) 102 (setq map `(("Yes" . act) ("No" . skip)
101 ,@(mapcar (lambda (elt) 103 ,@(mapcar (lambda (elt)
@@ -129,8 +131,8 @@ Returns the number of actions taken."
129 (unwind-protect 131 (unwind-protect
130 (progn 132 (progn
131 (if (stringp prompter) 133 (if (stringp prompter)
132 (setq prompter `(lambda (object) 134 (setq prompter (lambda (object)
133 (format ,prompter object)))) 135 (format prompter object))))
134 (while (funcall next) 136 (while (funcall next)
135 (setq prompt (funcall prompter elt)) 137 (setq prompt (funcall prompter elt))
136 (cond ((stringp prompt) 138 (cond ((stringp prompt)
@@ -176,9 +178,7 @@ Returns the number of actions taken."
176 next (lambda () nil))) 178 next (lambda () nil)))
177 ((eq def 'quit) 179 ((eq def 'quit)
178 (setq quit-flag t) 180 (setq quit-flag t)
179 (setq next `(lambda () 181 (funcall try-again))
180 (setq next ',next)
181 ',elt)))
182 ((eq def 'automatic) 182 ((eq def 'automatic)
183 ;; Act on this and all following objects. 183 ;; Act on this and all following objects.
184 (if (funcall prompter elt) 184 (if (funcall prompter elt)
@@ -219,40 +219,30 @@ the current %s and exit."
219 (with-current-buffer standard-output 219 (with-current-buffer standard-output
220 (help-mode))) 220 (help-mode)))
221 221
222 (setq next `(lambda () 222 (funcall try-again))
223 (setq next ',next) 223 ((and (symbolp def) (commandp def))
224 ',elt))) 224 (call-interactively def)
225 ((and (symbolp def) (commandp def)) 225 ;; Regurgitated; try again.
226 (call-interactively def) 226 (funcall try-again))
227 ;; Regurgitated; try again.
228 (setq next `(lambda ()
229 (setq next ',next)
230 ',elt)))
231 ((vectorp def) 227 ((vectorp def)
232 ;; A user-defined key. 228 ;; A user-defined key.
233 (if (funcall (aref def 0) elt) ;Call its function. 229 (if (funcall (aref def 0) elt) ;Call its function.
234 ;; The function has eaten this object. 230 ;; The function has eaten this object.
235 (setq actions (1+ actions)) 231 (setq actions (1+ actions))
236 ;; Regurgitated; try again. 232 ;; Regurgitated; try again.
237 (setq next `(lambda () 233 (funcall try-again)))
238 (setq next ',next)
239 ',elt))))
240 ((and (consp char) 234 ((and (consp char)
241 (eq (car char) 'switch-frame)) 235 (eq (car char) 'switch-frame))
242 ;; switch-frame event. Put it off until we're done. 236 ;; switch-frame event. Put it off until we're done.
243 (setq delayed-switch-frame char) 237 (setq delayed-switch-frame char)
244 (setq next `(lambda () 238 (funcall try-again))
245 (setq next ',next)
246 ',elt)))
247 (t 239 (t
248 ;; Random char. 240 ;; Random char.
249 (message "Type %s for help." 241 (message "Type %s for help."
250 (key-description (vector help-char))) 242 (key-description (vector help-char)))
251 (beep) 243 (beep)
252 (sit-for 1) 244 (sit-for 1)
253 (setq next `(lambda () 245 (funcall try-again))))
254 (setq next ',next)
255 ',elt)))))
256 (prompt 246 (prompt
257 (funcall actor elt) 247 (funcall actor elt)
258 (setq actions (1+ actions)))))) 248 (setq actions (1+ actions))))))