Search code examples
emacselisp

How to give a list as arguments to a function in elisp?


I'm trying to learn elisp and emacs customization. I setq'ed a list of arguments to a variable. How do I go about passing this list to a function instead of just giving the arguments directly.

Thanks in advance.


Solution

  • Use the apply function:

    (apply 'function arglist)
    

    For example:

    (apply '+ '(1 2 3 4))
    ==> 10