]> code.delx.au - gnu-emacs/commitdiff
* emacs-lisp/cl-macs.el (cl-macrolet): Avoid excessive progn's.
authorLeo Liu <sdl.web@gmail.com>
Thu, 5 Jun 2014 17:08:18 +0000 (01:08 +0800)
committerLeo Liu <sdl.web@gmail.com>
Thu, 5 Jun 2014 17:08:18 +0000 (01:08 +0800)
lisp/ChangeLog
lisp/emacs-lisp/cl-macs.el

index 0abb367f5b8ec1dd765f99011bed70a8fc7bba3a..e0d2ff0a584b56dd7081c4eb86b788e67830d685 100644 (file)
@@ -1,3 +1,7 @@
+2014-06-05  Leo Liu  <sdl.web@gmail.com>
+
+       * emacs-lisp/cl-macs.el (cl-macrolet): Avoid excessive progn's.
+
 2014-06-05  Michal Nazarewicz  <mina86@mina86.com>
 
        * textmodes/tildify.el (tildify-foreach-region-outside-env): New
index 14e4d2da0c81f30a3e118cc2ba332423421d6194..299cffc83aa14740538d108f1fdf1c2c2144a920 100644 (file)
@@ -1886,13 +1886,15 @@ This is like `cl-flet', but for macros instead of functions.
              cl-declarations body)))
   (if (cdr bindings)
       `(cl-macrolet (,(car bindings)) (cl-macrolet ,(cdr bindings) ,@body))
-    (if (null bindings) (cons 'progn body)
-      (let* ((name (caar bindings))
-            (res (cl--transform-lambda (cdar bindings) name)))
-       (eval (car res))
-       (macroexpand-all (cons 'progn body)
-                         (cons (cons name `(lambda ,@(cdr res)))
-                               macroexpand-all-environment))))))
+    (let ((progn-maybe (lambda (body)
+                        (if (cdr body) (cons 'progn body) (car body)))))
+      (if (null bindings) (funcall progn-maybe body)
+       (let* ((name (caar bindings))
+              (res (cl--transform-lambda (cdar bindings) name)))
+         (eval (car res))
+         (macroexpand-all (funcall progn-maybe body)
+                          (cons (cons name `(lambda ,@(cdr res)))
+                                macroexpand-all-environment)))))))
 
 (defconst cl--old-macroexpand
   (if (and (boundp 'cl--old-macroexpand)