I'm new to emacs-lisp. I wrote a function that kills the buffer of my main work document work.org and opens specific project files.
(defun load-current-files () (interactive) (kill-buffer "work.org") (find-file "~/file-1.txt") (find-file "~/file-2.txt") (find-file "~/file-3.txt"))
The function works perfectly when work.org is open. However, if I've already killed that buffer, the function, very naturally throws an error saying
Lisp error: (error "No buffer named work.org").
That makes perfect sense. But how do I tell a defun to just keep chugging along even if it encounters an error? Can I wrap a command in an (ignore-errors) layer or something?
(ignore-errors (kill-buffer "work.org"))
Something like that?