aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2015-02-09 10:52:48 -0500
committerStefan Monnier2015-02-09 10:52:48 -0500
commit2973127159944de98f1e4ece7fd46a202e1352c6 (patch)
treed6aea49834e1afd044d366c423de9d9847191364
parent699ece275727be4ce452cdc43fe09fd7d8f8034c (diff)
downloademacs-2973127159944de98f1e4ece7fd46a202e1352c6.tar.gz
emacs-2973127159944de98f1e4ece7fd46a202e1352c6.zip
* lisp/emacs-lisp/cl-generic.el (cl--generic-lambda): Use macroexp-parse-body.
-rw-r--r--lisp/ChangeLog2
-rw-r--r--lisp/emacs-lisp/cl-generic.el13
2 files changed, 6 insertions, 9 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index d9024982807..e86d62da05a 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,7 @@
12015-02-09 Stefan Monnier <monnier@iro.umontreal.ca> 12015-02-09 Stefan Monnier <monnier@iro.umontreal.ca>
2 2
3 * emacs-lisp/cl-generic.el (cl--generic-lambda): Use macroexp-parse-body.
4
3 * emacs-lisp/eieio-core.el (eieio-oset-default): Catch the unexpected 5 * emacs-lisp/eieio-core.el (eieio-oset-default): Catch the unexpected
4 case where the default value would be re-interpreted as a form! 6 case where the default value would be re-interpreted as a form!
5 7
diff --git a/lisp/emacs-lisp/cl-generic.el b/lisp/emacs-lisp/cl-generic.el
index 42e637958b1..c4232863cfc 100644
--- a/lisp/emacs-lisp/cl-generic.el
+++ b/lisp/emacs-lisp/cl-generic.el
@@ -243,8 +243,6 @@ This macro can only be used within the lexical scope of a cl-generic method."
243 "Make the lambda expression for a method with ARGS and BODY." 243 "Make the lambda expression for a method with ARGS and BODY."
244 (let ((plain-args ()) 244 (let ((plain-args ())
245 (specializers nil) 245 (specializers nil)
246 (doc-string (if (and (stringp (car-safe body)) (cdr body))
247 (pop body)))
248 (mandatory t)) 246 (mandatory t))
249 (dolist (arg args) 247 (dolist (arg args)
250 (push (pcase arg 248 (push (pcase arg
@@ -255,9 +253,7 @@ This macro can only be used within the lexical scope of a cl-generic method."
255 (_ arg)) 253 (_ arg))
256 plain-args)) 254 plain-args))
257 (setq plain-args (nreverse plain-args)) 255 (setq plain-args (nreverse plain-args))
258 (let ((fun `(cl-function (lambda ,plain-args 256 (let ((fun `(cl-function (lambda ,plain-args ,@body)))
259 ,@(if doc-string (list doc-string))
260 ,@body)))
261 (macroenv (cons `(cl-generic-current-method-specializers 257 (macroenv (cons `(cl-generic-current-method-specializers
262 . ,(lambda () specializers)) 258 . ,(lambda () specializers))
263 macroexpand-all-environment))) 259 macroexpand-all-environment)))
@@ -266,14 +262,13 @@ This macro can only be used within the lexical scope of a cl-generic method."
266 ;; destructuring args, `declare' and whatnot). 262 ;; destructuring args, `declare' and whatnot).
267 (pcase (macroexpand fun macroenv) 263 (pcase (macroexpand fun macroenv)
268 (`#'(lambda ,args . ,body) 264 (`#'(lambda ,args . ,body)
269 (let* ((doc-string (and doc-string (stringp (car body)) (cdr body) 265 (let* ((parsed-body (macroexp-parse-body body))
270 (pop body)))
271 (cnm (make-symbol "cl--cnm")) 266 (cnm (make-symbol "cl--cnm"))
272 (nmp (make-symbol "cl--nmp")) 267 (nmp (make-symbol "cl--nmp"))
273 (nbody (macroexpand-all 268 (nbody (macroexpand-all
274 `(cl-flet ((cl-call-next-method ,cnm) 269 `(cl-flet ((cl-call-next-method ,cnm)
275 (cl-next-method-p ,nmp)) 270 (cl-next-method-p ,nmp))
276 ,@body) 271 ,@(cdr parsed-body))
277 macroenv)) 272 macroenv))
278 ;; FIXME: Rather than `grep' after the fact, the 273 ;; FIXME: Rather than `grep' after the fact, the
279 ;; macroexpansion should directly set some flag when cnm 274 ;; macroexpansion should directly set some flag when cnm
@@ -283,7 +278,7 @@ This macro can only be used within the lexical scope of a cl-generic method."
283 (uses-cnm (cl--generic-fgrep (list cnm nmp) nbody))) 278 (uses-cnm (cl--generic-fgrep (list cnm nmp) nbody)))
284 (cons (not (not uses-cnm)) 279 (cons (not (not uses-cnm))
285 `#'(lambda (,@(if uses-cnm (list cnm)) ,@args) 280 `#'(lambda (,@(if uses-cnm (list cnm)) ,@args)
286 ,@(if doc-string (list doc-string)) 281 ,@(delq nil (car parsed-body))
287 ,(if (not (memq nmp uses-cnm)) 282 ,(if (not (memq nmp uses-cnm))
288 nbody 283 nbody
289 `(let ((,nmp (lambda () 284 `(let ((,nmp (lambda ()