Search code examples
syntaxelisp

How can you write multiple statements in elisp 'if' statement?


In elisp, there is an 'if' case where I would like to perform many different things:

(if condition
    (do-something)
    (do-another-thing)
    ...)

However, (do-another-thing) is executed in the else-case only. How can you specify a block of instructions to execute? For example:

(if condition
    (begin
        (do-something)
        (do-another-thing)
        ...))

Solution

  • Use progn:

    (if condition
        (progn
            (do-something)
            (do-another-thing)))
    

    See sequencing in the manual.