mirror of
https://github.com/doomemacs/doomemacs
synced 2025-08-01 12:17:25 -05:00
feat(lib): imply &allow-other-keys in fn! macro
This commit is contained in:
@ -215,8 +215,20 @@ See `eval-if!' for details on this macro's purpose."
|
||||
(defmacro fn! (arglist &rest body)
|
||||
"Returns (cl-function (lambda ARGLIST BODY...))
|
||||
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))
|
||||
;; 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)))
|
||||
|
||||
(defmacro cmd! (&rest body)
|
||||
|
Reference in New Issue
Block a user