skeeto / emacs-aio

async/await for Emacs Lisp
The Unlicense
218 stars 12 forks source link

Show correct arguments in documentation for `aio-defun` functions. #20

Open clonex10100 opened 3 years ago

clonex10100 commented 3 years ago

I'm working on a project using this library and it's great. The one problem is that in eldoc and other documentation, all of my aio-defun'd function show their argument list as (&rest args) which means I have to got to the definition to see how to call a function.

One solution I've found is to use set-advertised-calling-convention in the aio-defun macro.

What do you think?

(defmacro aio-defun (name arglist &rest body)
  "Like `aio-lambda' but gives the function a name like `defun'."
  (declare (indent defun)
           (doc-string 3)
           (debug (&define name lambda-list &rest sexp)))
  `(progn
     (defalias ',name (aio-lambda ,arglist ,@body))
     (function-put ',name 'aio-defun-p t)
     (set-advertised-calling-convention ',name ',arglist 0)))