summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Monnier <monnier@iro.umontreal.ca>2015-02-09 10:52:48 -0500
committerStefan Monnier <monnier@iro.umontreal.ca>2015-02-09 10:52:48 -0500
commit2973127159944de98f1e4ece7fd46a202e1352c6 (patch)
treed6aea49834e1afd044d366c423de9d9847191364
parent699ece275727be4ce452cdc43fe09fd7d8f8034c (diff)
downloademacs-2973127159944de98f1e4ece7fd46a202e1352c6.tar.gz
* 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 @@
2015-02-09 Stefan Monnier <monnier@iro.umontreal.ca>
+ * emacs-lisp/cl-generic.el (cl--generic-lambda): Use macroexp-parse-body.
+
* emacs-lisp/eieio-core.el (eieio-oset-default): Catch the unexpected
case where the default value would be re-interpreted as a form!
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."
"Make the lambda expression for a method with ARGS and BODY."
(let ((plain-args ())
(specializers nil)
- (doc-string (if (and (stringp (car-safe body)) (cdr body))
- (pop body)))
(mandatory t))
(dolist (arg args)
(push (pcase arg
@@ -255,9 +253,7 @@ This macro can only be used within the lexical scope of a cl-generic method."
(_ arg))
plain-args))
(setq plain-args (nreverse plain-args))
- (let ((fun `(cl-function (lambda ,plain-args
- ,@(if doc-string (list doc-string))
- ,@body)))
+ (let ((fun `(cl-function (lambda ,plain-args ,@body)))
(macroenv (cons `(cl-generic-current-method-specializers
. ,(lambda () specializers))
macroexpand-all-environment)))
@@ -266,14 +262,13 @@ This macro can only be used within the lexical scope of a cl-generic method."
;; destructuring args, `declare' and whatnot).
(pcase (macroexpand fun macroenv)
(`#'(lambda ,args . ,body)
- (let* ((doc-string (and doc-string (stringp (car body)) (cdr body)
- (pop body)))
+ (let* ((parsed-body (macroexp-parse-body body))
(cnm (make-symbol "cl--cnm"))
(nmp (make-symbol "cl--nmp"))
(nbody (macroexpand-all
`(cl-flet ((cl-call-next-method ,cnm)
(cl-next-method-p ,nmp))
- ,@body)
+ ,@(cdr parsed-body))
macroenv))
;; FIXME: Rather than `grep' after the fact, the
;; 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."
(uses-cnm (cl--generic-fgrep (list cnm nmp) nbody)))
(cons (not (not uses-cnm))
`#'(lambda (,@(if uses-cnm (list cnm)) ,@args)
- ,@(if doc-string (list doc-string))
+ ,@(delq nil (car parsed-body))
,(if (not (memq nmp uses-cnm))
nbody
`(let ((,nmp (lambda ()