Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add cl- version of async-defun and async-lambda #12

Open
isamert opened this issue Mar 9, 2024 · 0 comments
Open

Add cl- version of async-defun and async-lambda #12

isamert opened this issue Mar 9, 2024 · 0 comments

Comments

@isamert
Copy link

isamert commented Mar 9, 2024

It would be nice to have async-cl-defun, I defined the following and it works for me:

;;;###autoload
(defmacro async-cl-defun (name arglist &rest body)
  "Same as `async-defun' but uses `cl-defun' to define the function."
  (declare (doc-string 3) (indent 2))
  (cl-assert lexical-binding)
  (let* ((parsed-body (macroexp-parse-body body))
         (declarations (car parsed-body))
         (exps (macroexpand-all
                `(cl-macrolet
                     ((await (value)
                             `(async-await--check-return-value (iter-yield ,value))))
                   ,@(cdr parsed-body))
                macroexpand-all-environment)))
    `(cl-defun ,name ,arglist
       ,@declarations
       (async-await--awaiter
        (funcall (iter2-lambda () ,exps))))))

If you are okay adding this, I can put together a PR (instead of using the implementation above, I will try to create one without doing code duplication).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant