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


Vinh Nguyen


June 30, 2011

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:

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