emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] master 8af3e18: Add cl-iter-defun


From: Daniel Colascione
Subject: [Emacs-diffs] master 8af3e18: Add cl-iter-defun
Date: Tue, 03 Mar 2015 00:43:02 +0000

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

    Add cl-iter-defun
    
    * lisp/emacs-lisp/cl-macs.el (cl-iter-defun): Add cl-iter-defun.
---
 doc/misc/cl.texi           |    7 +++++++
 lisp/ChangeLog             |    2 ++
 lisp/emacs-lisp/cl-macs.el |   21 +++++++++++++++++++++
 3 files changed, 30 insertions(+), 0 deletions(-)

diff --git a/doc/misc/cl.texi b/doc/misc/cl.texi
index 052ca6b..c6076ba 100644
--- a/doc/misc/cl.texi
+++ b/doc/misc/cl.texi
@@ -296,6 +296,13 @@ list.  Also, the function body is enclosed in an implicit 
block
 called @var{name}; @pxref{Blocks and Exits}.
 @end defmac
 
address@hidden cl-iter-defun name arglist address@hidden
+This form is identical to the regular @code{iter-defun} form, except
+that @var{arglist} is allowed to be a full Common Lisp argument
+list.  Also, the function body is enclosed in an implicit block
+called @var{name}; @pxref{Blocks and Exits}.
address@hidden defmac
+
 @defmac cl-defsubst name arglist address@hidden
 This is just like @code{cl-defun}, except that the function that
 is defined is automatically proclaimed @code{inline}, i.e.,
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 5018ca4..aae09fd 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,7 @@
 2015-03-03  Daniel Colascione  <address@hidden>
 
+       * emacs-lisp/cl-macs.el (cl-iter-defun): Add cl-iter-defun.
+
        * emacs-lisp/generator.el (iter-defun): Correctly propagate
        docstrings and declarations to underlying function.
 
diff --git a/lisp/emacs-lisp/cl-macs.el b/lisp/emacs-lisp/cl-macs.el
index c3da091..36f263c 100644
--- a/lisp/emacs-lisp/cl-macs.el
+++ b/lisp/emacs-lisp/cl-macs.el
@@ -301,6 +301,27 @@ and BODY is implicitly surrounded by (cl-block NAME ...).
         (form `(defun ,name ,@(cdr res))))
     (if (car res) `(progn ,(car res) ,form) form)))
 
+;;;###autoload
+(defmacro cl-iter-defun (name args &rest body)
+  "Define NAME as a generator function.
+Like normal `iter-defun', except ARGLIST allows full Common Lisp conventions,
+and BODY is implicitly surrounded by (cl-block NAME ...).
+
+\(fn NAME ARGLIST [DOCSTRING] BODY...)"
+  (declare (debug
+            ;; Same as iter-defun but use cl-lambda-list.
+            (&define [&or name ("setf" :name setf name)]
+                     cl-lambda-list
+                     cl-declarations-or-string
+                     [&optional ("interactive" interactive)]
+                     def-body))
+           (doc-string 3)
+           (indent 2))
+  (require 'generator)
+  (let* ((res (cl--transform-lambda (cons args body) name))
+         (form `(iter-defun ,name ,@(cdr res))))
+    (if (car res) `(progn ,(car res) ,form) form)))
+
 ;; The lambda list for macros is different from that of normal lambdas.
 ;; Note that &environment is only allowed as first or last items in the
 ;; top level list.



reply via email to

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