* lisp/emacs-lisp/macroexp.el (macroexp-parse-body): Handle cl-declare

and :documentation.  Change return value format accordingly.
* lisp/emacs-lisp/cl-generic.el (cl--generic-lambda):
* lisp/emacs-lisp/pcase.el (pcase-lambda): Adjust accordingly.
* lisp/emacs-lisp/cl-macs.el (cl--transform-lambda): Use macroexp-parse-body.
This commit is contained in:
Stefan Monnier 2015-02-22 23:50:03 -05:00
parent 3f006e1d47
commit e846bbf360
5 changed files with 36 additions and 30 deletions

View file

@ -297,15 +297,16 @@ definitions to shadow the loaded ones for use in file byte-compilation."
;;; Handy functions to use in macros.
(defun macroexp-parse-body (exps)
"Parse EXPS into ((DOC DECLARE-FORM INTERACTIVE-FORM) . BODY)."
`((,(and (stringp (car exps))
(pop exps))
,(and (eq (car-safe (car exps)) 'declare)
(pop exps))
,(and (eq (car-safe (car exps)) 'interactive)
(pop exps)))
,@exps))
(defun macroexp-parse-body (body)
"Parse a function BODY into (DECLARATIONS . EXPS)."
(let ((decls ()))
(while (and (cdr body)
(let ((e (car body)))
(or (stringp e)
(memq (car-safe e)
'(:documentation declare interactive cl-declare)))))
(push (pop body) decls))
(cons (nreverse decls) body)))
(defun macroexp-progn (exps)
"Return an expression equivalent to `(progn ,@EXPS)."