feat(lib): imply &allow-other-keys in fn! macro
This commit is contained in:
parent
0ad7874a28
commit
f2588b0e90
1 changed files with 13 additions and 1 deletions
|
@ -215,8 +215,20 @@ See `eval-if!' for details on this macro's purpose."
|
||||||
(defmacro fn! (arglist &rest body)
|
(defmacro fn! (arglist &rest body)
|
||||||
"Returns (cl-function (lambda ARGLIST BODY...))
|
"Returns (cl-function (lambda ARGLIST BODY...))
|
||||||
The closure is wrapped in `cl-function', meaning ARGLIST will accept anything
|
The closure is wrapped in `cl-function', meaning ARGLIST will accept anything
|
||||||
`cl-defun' will. "
|
`cl-defun' will. Implicitly adds `&allow-other-keys' if `&key' is present in
|
||||||
|
ARGLIST."
|
||||||
(declare (indent defun) (doc-string 1) (pure t) (side-effect-free t))
|
(declare (indent defun) (doc-string 1) (pure t) (side-effect-free t))
|
||||||
|
;; Don't complain about undeclared keys.
|
||||||
|
(when (memq '&key arglist)
|
||||||
|
(if (memq '&aux arglist)
|
||||||
|
(let (newarglist arg)
|
||||||
|
(while arglist
|
||||||
|
(setq arg (pop arglist))
|
||||||
|
(when (eq arg '&aux)
|
||||||
|
(push '&allow-other-keys newarglist))
|
||||||
|
(push arg newarglist))
|
||||||
|
(setq arglist (nreverse newarglist)))
|
||||||
|
(setq arglist (append arglist (list '&allow-other-keys)))))
|
||||||
`(cl-function (lambda ,arglist ,@body)))
|
`(cl-function (lambda ,arglist ,@body)))
|
||||||
|
|
||||||
(defmacro cmd! (&rest body)
|
(defmacro cmd! (&rest body)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue