Commit 8b38d30e authored by Daniel Colascione's avatar Daniel Colascione
Browse files

Use `macroexp-parse-body'

* 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.
parent 7133f262
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> 2015-03-03 Stefan Monnier <monnier@iro.umontreal.ca>
   
* progmodes/gud.el: Use lexical-binding (bug#19966). * progmodes/gud.el: Use lexical-binding (bug#19966).
......
...@@ -687,14 +687,12 @@ encapsulates the state of a computation that produces a sequence ...@@ -687,14 +687,12 @@ encapsulates the state of a computation that produces a sequence
of values. Callers can retrieve each value using `iter-next'." of values. Callers can retrieve each value using `iter-next'."
(declare (indent defun)) (declare (indent defun))
(cl-assert lexical-binding) (cl-assert lexical-binding)
(let (preamble) (let* ((parsed-body (macroexp-parse-body body))
(when (stringp (car body)) (declarations (car parsed-body))
(push (pop body) preamble)) (exps (cdr parsed-body)))
(when (eq (car-safe (car body)) 'declare)
(push (pop body) preamble))
`(defun ,name ,arglist `(defun ,name ,arglist
,@(nreverse preamble) ,@declarations
,(cps-generate-evaluator body)))) ,(cps-generate-evaluator exps))))
(defmacro iter-lambda (arglist &rest body) (defmacro iter-lambda (arglist &rest body)
"Return a lambda generator. "Return a lambda generator.
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
* automated/generator-tests.el (cps-testcase): Use * automated/generator-tests.el (cps-testcase): Use
`cps-inhibit-atomic-optimization' instead of `cps-inhibit-atomic-optimization' instead of
`cps-disable-atomic-optimization'. `cps-disable-atomic-optimization'.
(cps-test-declarations-preserved): New test.
* automated/finalizer-tests.el (finalizer-basic) * automated/finalizer-tests.el (finalizer-basic)
(finalizer-circular-reference, finalizer-cross-reference) (finalizer-circular-reference, finalizer-cross-reference)
......
...@@ -287,3 +287,12 @@ identical output. ...@@ -287,3 +287,12 @@ identical output.
(should (equal (iter-next iter) 1)) (should (equal (iter-next iter) 1))
(should-error (iter-next iter)) (should-error (iter-next iter))
(should (equal nr-unwound 1)))) (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)))
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment