]> code.delx.au - gnu-emacs/commitdiff
Use `macroexp-parse-body'
authorDaniel Colascione <dancol@dancol.org>
Tue, 3 Mar 2015 21:18:00 +0000 (13:18 -0800)
committerDaniel Colascione <dancol@dancol.org>
Tue, 3 Mar 2015 21:19:25 +0000 (13:19 -0800)
* lisp/emacs-lisp/generator.el: (iter-defun): Use `macroexp-parse-body'.

* test/automated/generator-tests.el (cps-testcase): Use
(cps-test-declarations-preserved): New test.

lisp/ChangeLog
lisp/emacs-lisp/generator.el
test/ChangeLog
test/automated/generator-tests.el

index 0cfe8eed02a847d65c40244d73130ac2689c2579..3bc9b8c85ceaddd22579544c3b42dd8968aea4cd 100644 (file)
@@ -1,3 +1,18 @@
+2015-03-03  Daniel Colascione  <dancol@dancol.org>
+
+       * emacs-lisp/generator.el: Make globals conform to elisp
+       style throughout.  Use more efficient font-lock patterns.
+       (cps-inhibit-atomic-optimization): Rename from
+       `cps-disable-atomic-optimization'.
+       (cps--gensym): New macro; replaces `cl-gensym' throughout.
+       (cps-generate-evaluator): Move the `iter-yield' local macro
+       definition here
+       (iter-defun, iter-lambda): from here.
+
+       (iter-defun): Use `macroexp-parse-body'.
+
+2015-03-03  Daniel Colascione  <dancol@dancol.org>
+
 2015-03-03  Stefan Monnier  <monnier@iro.umontreal.ca>
 
        * progmodes/gud.el: Use lexical-binding (bug#19966).
index 77b1fab9b0997e1591684d4e0f5e6526e94520a8..284de41058049e2273d98b379d5996c5720b5ba3 100644 (file)
@@ -687,14 +687,12 @@ encapsulates the state of a computation that produces a sequence
 of values.  Callers can retrieve each value using `iter-next'."
   (declare (indent defun))
   (cl-assert lexical-binding)
-  (let (preamble)
-    (when (stringp (car body))
-      (push (pop body) preamble))
-    (when (eq (car-safe (car body)) 'declare)
-      (push (pop body) preamble))
+  (let* ((parsed-body (macroexp-parse-body body))
+         (declarations (car parsed-body))
+         (exps (cdr parsed-body)))
     `(defun ,name ,arglist
-       ,@(nreverse preamble)
-       ,(cps-generate-evaluator body))))
+       ,@declarations
+       ,(cps-generate-evaluator exps))))
 
 (defmacro iter-lambda (arglist &rest body)
   "Return a lambda generator.
index 55f8c6c8eb8566c4f616d01b7d89e638cddd34d3..4488aab701f78102815ea8c9f708df83fa5320eb 100644 (file)
@@ -3,6 +3,7 @@
        * automated/generator-tests.el (cps-testcase): Use
        `cps-inhibit-atomic-optimization' instead of
        `cps-disable-atomic-optimization'.
+       (cps-test-declarations-preserved): New test.
 
        * automated/finalizer-tests.el (finalizer-basic)
        (finalizer-circular-reference, finalizer-cross-reference)
index 3ee65105597f18dd16693492f9ef3092b3069737..d9c81b59a23c4ad524b93305c130335d7c9b42d1 100644 (file)
@@ -287,3 +287,12 @@ identical output.
     (should (equal (iter-next iter) 1))
     (should-error (iter-next iter))
     (should (equal nr-unwound 1))))
+
+(iter-defun generator-with-docstring ()
+  "Documentation!"
+  (declare (indent 5))
+  nil)
+
+(ert-deftest cps-test-declarations-preserved ()
+  (should (equal (documentation 'generator-with-docstring) "Documentation!"))
+  (should (equal (get 'generator-with-docstring 'lisp-indent-function) 5)))