summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp
diff options
context:
space:
mode:
authorDaniel Colascione <dancol@dancol.org>2015-03-02 16:41:59 -0800
committerDaniel Colascione <dancol@dancol.org>2015-03-02 16:41:59 -0800
commit8af3e1848cbdc570b6c173480c2988a552f3f74d (patch)
tree29d1ccc791bcc100707c45edb2aa3a6b5eeac328 /lisp/emacs-lisp
parent8f0f8c166c2c76789acfa0cf3d42eafbbfa95973 (diff)
downloademacs-8af3e1848cbdc570b6c173480c2988a552f3f74d.tar.gz
emacs-8af3e1848cbdc570b6c173480c2988a552f3f74d.tar.bz2
emacs-8af3e1848cbdc570b6c173480c2988a552f3f74d.zip
Add cl-iter-defun
* lisp/emacs-lisp/cl-macs.el (cl-iter-defun): Add cl-iter-defun.
Diffstat (limited to 'lisp/emacs-lisp')
-rw-r--r--lisp/emacs-lisp/cl-macs.el21
1 files changed, 21 insertions, 0 deletions
diff --git a/lisp/emacs-lisp/cl-macs.el b/lisp/emacs-lisp/cl-macs.el
index c3da091fb00..36f263cd20a 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.