New answers tagged

5

make-temp-file can be used to make a directory instead of a file, this example simply calls make-temp-file, then removes the directory afterwards. (let ((temp-dir (make-temp-file "foo" t))) (unwind-protect (progn ;; do stuff ) (delete-directory temp-dir t))) This same functionality as a macro: (defmacro with-temp-dir (temp-dir &...


3

;; Inspired from `dired-create-directory` code. (defun with-temp-dir (dir) "..." (let* ((expanded (directory-file-name (expand-file-name dir))) (try expanded) new) (unwind-protect (progn (when (file-exists-p expanded) (error "Cannot create directory %s: file exists" expanded)) ;; Find ...


Top 50 recent answers are included