New answers tagged

0

This can be done by parsing the keyword arguments directly. ;; Function that takes two optional keyword arguments: `example-a', `example-b'. (defun some-name (&rest kwargs) ;; Two example keywords. (let ((example-a-as-var nil) (example-b-as-var nil)) ;; Extract keyword args. (let ((kw-iter keyword-args)) (while kw-iter (...


3

cl-defun handles this usecase: (require 'cl-lib) (cl-defun test (&key foo bar) (list foo bar)) (test :foo 1 :bar 2) ; (1 2) (test :foo 1 :bar 2 :baz 3) ; Error: "Keyword argument :baz not one of (:foo :bar)" In case you want the opposite behavior, pass &allow-other-keys after the key list.


Top 50 recent answers are included