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

后端 未结 2 936
走了就别回头了
走了就别回头了 2021-01-30 12:12

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

(if condition
    (do-something)
    (do-something-else)
    ...)
<         


        
相关标签:
2条回答
  • 2021-01-30 12:58

    If there's no else required, it might be more readable to use:

    (when condition
        (do-something)
        (do-something-else))
    

    And, there's the converse

    (unless (not condition)
        (do-something)
        (do-something-else))
    

    Check out the Emacs Lisp manual for conditionals.

    0 讨论(0)
  • 2021-01-30 13:01

    Use progn:

    (if condition
        (progn
            (do-something)
            (do-something-else)))
    
    0 讨论(0)
提交回复
热议问题