[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master 8b38d30: Use `macroexp-parse-body'
From: |
Daniel Colascione |
Subject: |
[Emacs-diffs] master 8b38d30: Use `macroexp-parse-body' |
Date: |
Tue, 03 Mar 2015 21:19:32 +0000 |
branch: master
commit 8b38d30e1b02809c34cfba9c7f15ca46f9d45f80
Author: Daniel Colascione <address@hidden>
Commit: Daniel Colascione <address@hidden>
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.
---
lisp/ChangeLog | 15 +++++++++++++++
lisp/emacs-lisp/generator.el | 12 +++++-------
test/ChangeLog | 1 +
test/automated/generator-tests.el | 9 +++++++++
4 files changed, 30 insertions(+), 7 deletions(-)
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 0cfe8ee..3bc9b8c 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,18 @@
+2015-03-03 Daniel Colascione <address@hidden>
+
+ * 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 <address@hidden>
+
2015-03-03 Stefan Monnier <address@hidden>
* progmodes/gud.el: Use lexical-binding (bug#19966).
diff --git a/lisp/emacs-lisp/generator.el b/lisp/emacs-lisp/generator.el
index 77b1fab..284de41 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
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.
diff --git a/test/ChangeLog b/test/ChangeLog
index 55f8c6c..4488aab 100644
--- a/test/ChangeLog
+++ b/test/ChangeLog
@@ -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)
diff --git a/test/automated/generator-tests.el
b/test/automated/generator-tests.el
index 3ee6510..d9c81b5 100644
--- a/test/automated/generator-tests.el
+++ b/test/automated/generator-tests.el
@@ -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)))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] master 8b38d30: Use `macroexp-parse-body',
Daniel Colascione <=