emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master 8f0f8c1: Fix docstrings, declarations in iter-defun


From: Daniel Colascione
Subject: [Emacs-diffs] master 8f0f8c1: Fix docstrings, declarations in iter-defun
Date: Tue, 03 Mar 2015 00:11:58 +0000

branch: master
commit 8f0f8c166c2c76789acfa0cf3d42eafbbfa95973
Author: Daniel Colascione <address@hidden>
Commit: Daniel Colascione <address@hidden>

    Fix docstrings, declarations in iter-defun
    
    * lisp/emacs-lisp/generator.el (iter-defun): Correctly propagate
    docstrings and declarations to underlying function.
---
 lisp/ChangeLog               |    5 +++++
 lisp/emacs-lisp/generator.el |   14 ++++++++++----
 2 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 4ab4406..5018ca4 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,8 @@
+2015-03-03  Daniel Colascione  <address@hidden>
+
+       * emacs-lisp/generator.el (iter-defun): Correctly propagate
+       docstrings and declarations to underlying function.
+
 2015-03-02  Daniel Colascione  <address@hidden>
 
        * emacs-lisp/generator.el: New file.
diff --git a/lisp/emacs-lisp/generator.el b/lisp/emacs-lisp/generator.el
index 4e21e79..bb9fcff 100644
--- a/lisp/emacs-lisp/generator.el
+++ b/lisp/emacs-lisp/generator.el
@@ -674,10 +674,16 @@ 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)
-  `(defun ,name ,arglist
-     ,(cps-generate-evaluator
-       `(cl-macrolet ((iter-yield (value) `(cps-internal-yield ,value)))
-          ,@body))))
+  (let (preamble)
+    (when (stringp (car body))
+      (push (pop body) preamble))
+    (when (eq (car-safe (car body)) 'declare)
+      (push (pop body) preamble))
+    `(defun ,name ,arglist
+       ,@(nreverse preamble)
+       ,(cps-generate-evaluator
+         `(cl-macrolet ((iter-yield (value) `(cps-internal-yield ,value)))
+            ,@body)))))
 
 (defmacro iter-lambda (arglist &rest body)
   "Return a lambda generator.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]