with-snippet-dirs: use UNWIND-PROTECT

This commit is contained in:
João Távora 2012-04-21 11:58:12 +01:00
parent 59e18a999e
commit 9dedf91209

View File

@ -204,12 +204,13 @@ TODO: correct this bug!"
,@body)) ,@body))
(defmacro with-snippet-dirs (dirs &rest body) (defmacro with-snippet-dirs (dirs &rest body)
`(let ((default-directory (make-temp-file "yasnippet-fixture" t))) `(unwind-protect
(setq yas/snippet-dirs ',(mapcar #'car (cadr dirs))) (let ((default-directory (make-temp-file "yasnippet-fixture" t)))
(mapc #'yas/make-file-or-dirs ,dirs) (setq yas/snippet-dirs ',(mapcar #'car (cadr dirs)))
,@body (mapc #'yas/make-file-or-dirs ,dirs)
,@body)
(when (>= emacs-major-version 23) (when (>= emacs-major-version 23)
(delete-directory default-directory 'recursive)))) (delete-directory default-directory 'recursive))))
;;; Older emacsen ;;; Older emacsen
;;; ;;;