echo Impossible|sed 's/Im/To be /'

May 16, 2015

Emacs lisp exception

Emacs Elisp 例外處理

網路上找到了二篇 Elisp exception 相關的 blog.

result

(let ((result (ignore-errors
                (error "Failed")
                t)))
  (unless result
    (message "action exception")))

condition-case

(condition-case err-var
    (progn
      (error "Failed"))
  (error "Error: %s" err-var))

unwind-protect

(ignore-errors
  (unwind-protect
      (progn
        (error "hoge"))
    (message "This code is must executed!!")))