Browse Source

ox-latex: Remove all temporary files when compiling

* lisp/ox-latex.el (org-latex-compile): Remove all numbered temporary
  files after compiling.
Nicolas Goaziou 4 years ago
parent
commit
b21c5fa272
1 changed files with 7 additions and 3 deletions
  1. 7 3
      lisp/ox-latex.el

+ 7 - 3
lisp/ox-latex.el

@@ -2852,9 +2852,13 @@ Return PDF file name or an error if it couldn't be produced."
 	  ;; Else remove log files, when specified, and signal end of
 	  ;; process to user, along with any error encountered.
 	  (when (and (not snippet) org-latex-remove-logfiles)
-	    (dolist (ext org-latex-logfiles-extensions)
-	      (let ((file (concat out-dir base-name "." ext)))
-		(when (file-exists-p file) (delete-file file)))))
+	    (dolist (file (directory-files
+			   out-dir t
+			   (concat (regexp-quote base-name)
+				   "\\(?:\\.[0-9]+\\)?"
+				   "\\."
+				   (regexp-opt org-latex-logfiles-extensions))))
+	      (delete-file file)))
 	  (message (concat "Process completed"
 			   (if (not errors) "."
 			     (concat " with errors: " errors)))))