diff options
-rw-r--r-- | ennum.el | 20 |
1 files changed, 10 insertions, 10 deletions
@@ -33,6 +33,16 @@ last form in BODY." (insert-file-contents ,file) ,@body)) +(defmacro ennum-with-current-directory (directory &rest body) + "Change to DIRECTORY, evaluate BODY and restore the current +working directory. The value returned is the value of the last +form in BODY." + (declare (indent defun)) + (let ((current-directory-symbol (make-symbol "current-directory"))) + `(let ((,current-directory-symbol default-directory)) + (unwind-protect (progn (cd ,directory) ,@body) + (cd ,current-directory-symbol))))) + ;; TODO: Should the store have an absolute path to deal with directory ;; changes? Yes, since we ask for an absolute working directory, we ;; should. @@ -629,16 +639,6 @@ recognized as a directory, it should end in a slash. See (ennum--file-join (ennum-setting :images-directory) (ennum-video-link-poster link))))))) -(defmacro ennum-with-current-directory (directory &rest body) - "Change to DIRECTORY, evaluate BODY and restore the current -working directory. The value returned is the value of the last -form in BODY." - (declare (indent defun)) - (let ((current-directory-symbol (make-symbol "current-directory"))) - `(let ((,current-directory-symbol default-directory)) - (unwind-protect (progn (cd ,directory) ,@body) - (cd ,current-directory-symbol))))) - (defmacro ennum-with-temporary-directory (temporary-directory &rest body) "Create temporary directory, evaluate BODY with the absolute path of that directory assigned to TEMPORARY-DIRECTORY and |