aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Colascione2015-03-03 13:18:00 -0800
committerDaniel Colascione2015-03-03 13:19:25 -0800
commit8b38d30e1b02809c34cfba9c7f15ca46f9d45f80 (patch)
treea5a5a73f2af6ca28da220e31965e20b9f128ab82
parent7133f262bbd818509825a3317c91e91e62bd56fb (diff)
downloademacs-8b38d30e1b02809c34cfba9c7f15ca46f9d45f80.tar.gz
emacs-8b38d30e1b02809c34cfba9c7f15ca46f9d45f80.zip
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.
-rw-r--r--lisp/ChangeLog15
-rw-r--r--lisp/emacs-lisp/generator.el12
-rw-r--r--test/ChangeLog1
-rw-r--r--test/automated/generator-tests.el9
4 files changed, 30 insertions, 7 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 0cfe8eed02a..3bc9b8c85ce 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,18 @@
12015-03-03 Daniel Colascione <dancol@dancol.org>
2
3 * emacs-lisp/generator.el: Make globals conform to elisp
4 style throughout. Use more efficient font-lock patterns.
5 (cps-inhibit-atomic-optimization): Rename from
6 `cps-disable-atomic-optimization'.
7 (cps--gensym): New macro; replaces `cl-gensym' throughout.
8 (cps-generate-evaluator): Move the `iter-yield' local macro
9 definition here
10 (iter-defun, iter-lambda): from here.
11
12 (iter-defun): Use `macroexp-parse-body'.
13
142015-03-03 Daniel Colascione <dancol@dancol.org>
15
12015-03-03 Stefan Monnier <monnier@iro.umontreal.ca> 162015-03-03 Stefan Monnier <monnier@iro.umontreal.ca>
2 17
3 * progmodes/gud.el: Use lexical-binding (bug#19966). 18 * progmodes/gud.el: Use lexical-binding (bug#19966).
diff --git a/lisp/emacs-lisp/generator.el b/lisp/emacs-lisp/generator.el
index 77b1fab9b09..284de410580 100644
--- a/lisp/emacs-lisp/generator.el
+++ b/lisp/emacs-lisp/generator.el
@@ -687,14 +687,12 @@ encapsulates the state of a computation that produces a sequence
687of values. Callers can retrieve each value using `iter-next'." 687of values. Callers can retrieve each value using `iter-next'."
688 (declare (indent defun)) 688 (declare (indent defun))
689 (cl-assert lexical-binding) 689 (cl-assert lexical-binding)
690 (let (preamble) 690 (let* ((parsed-body (macroexp-parse-body body))
691 (when (stringp (car body)) 691 (declarations (car parsed-body))
692 (push (pop body) preamble)) 692 (exps (cdr parsed-body)))
693 (when (eq (car-safe (car body)) 'declare)
694 (push (pop body) preamble))
695 `(defun ,name ,arglist 693 `(defun ,name ,arglist
696 ,@(nreverse preamble) 694 ,@declarations
697 ,(cps-generate-evaluator body)))) 695 ,(cps-generate-evaluator exps))))
698 696
699(defmacro iter-lambda (arglist &rest body) 697(defmacro iter-lambda (arglist &rest body)
700 "Return a lambda generator. 698 "Return a lambda generator.
diff --git a/test/ChangeLog b/test/ChangeLog
index 55f8c6c8eb8..4488aab701f 100644
--- a/test/ChangeLog
+++ b/test/ChangeLog
@@ -3,6 +3,7 @@
3 * automated/generator-tests.el (cps-testcase): Use 3 * automated/generator-tests.el (cps-testcase): Use
4 `cps-inhibit-atomic-optimization' instead of 4 `cps-inhibit-atomic-optimization' instead of
5 `cps-disable-atomic-optimization'. 5 `cps-disable-atomic-optimization'.
6 (cps-test-declarations-preserved): New test.
6 7
7 * automated/finalizer-tests.el (finalizer-basic) 8 * automated/finalizer-tests.el (finalizer-basic)
8 (finalizer-circular-reference, finalizer-cross-reference) 9 (finalizer-circular-reference, finalizer-cross-reference)
diff --git a/test/automated/generator-tests.el b/test/automated/generator-tests.el
index 3ee65105597..d9c81b59a23 100644
--- a/test/automated/generator-tests.el
+++ b/test/automated/generator-tests.el
@@ -287,3 +287,12 @@ identical output.
287 (should (equal (iter-next iter) 1)) 287 (should (equal (iter-next iter) 1))
288 (should-error (iter-next iter)) 288 (should-error (iter-next iter))
289 (should (equal nr-unwound 1)))) 289 (should (equal nr-unwound 1))))
290
291(iter-defun generator-with-docstring ()
292 "Documentation!"
293 (declare (indent 5))
294 nil)
295
296(ert-deftest cps-test-declarations-preserved ()
297 (should (equal (documentation 'generator-with-docstring) "Documentation!"))
298 (should (equal (get 'generator-with-docstring 'lisp-indent-function) 5)))