Super Nerdy Cool

My (technical) adventures through the professional world…
June 30, 2011

Ignore errors when executing a command in emacs with condition-case

Suppose you want to execute a command in your emacs init file, but this command sometimes return an error. For example, you ask emacs to open a file for you, but the file doesn’t exist. When an error occurs, the rest of the init will not be loaded. Once can make use of the condition-case command to ignore the error. The following is an example:

 <pre class="example">(condition-case nil

(wg-load “~/.emacs.d/workgroups-save”) ;; ignore errors from this command (error nil))

6 Comments to “Ignore errors when executing a command in emacs with condition-case”

Leave a Comment