Skip to main content


elisp question

I'm certain I have reinvented a wheel here, but for the life of me I can't find it. Have I?

(defmacro jrl-extract-list (vars list &rest body)
  "Split a list into indiviual variables"
  (let ((list* (gensym)))
    (append
     `(let ,(cons (list list* list) vars))
     (seq-map (lambda (var)
                `(setq ,var (car ,list*)
                       ,list* (cdr ,list*)))
              vars)
     body)))

#emacs #lisp #elisp

Edit: Of course it was pcase.

in reply to Jonathan Lamothe

elisp question

Sensitive content

in reply to Marco Antoniotti

elisp question
@Marco Antoniotti It extracts a list into individual variables, so:
(let ((my-list '(1 2 3)))
  (jrl-extract-list (foo bar baz) my-list
                    (format "foo: %d, bar: %d, baz: %d" foo bar baz)))

would yield: "foo: 1, bar: 2, baz: 3"
in reply to Jonathan Lamothe

elisp question

Sensitive content

in reply to Jonathan Lamothe

elisp question

My guess is that maybe pcase can do something similar?

pcase confuses me.

in reply to Jonathan Lamothe

elisp question

Sensitive content

This entry was edited (11 hours ago)
in reply to Jonathan Lamothe

elisp question

Sensitive content

This website uses cookies. If you continue browsing this website, you agree to the usage of cookies.