changeset 576:70bb775b481c

Trial of removing .log/.dvi file when PDF successfully generated
author HIROSE Yuuji <yuuji@gentei.org>
date Mon, 25 Nov 2019 21:09:06 +0900
parents 637d152145d7
children 117a846879bc 89a13c59674f
files yatexprc.el
diffstat 1 files changed, 18 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/yatexprc.el	Wed Dec 26 08:11:24 2018 +0900
+++ b/yatexprc.el	Mon Nov 25 21:09:06 2019 +0900
@@ -1,7 +1,7 @@
 ;;; yatexprc.el --- YaTeX process handler -*- coding: sjis -*-
 ;;; 
 ;;; (c)1993-2018 by HIROSE Yuuji.[yuuji@yatex.org]
-;;; Last modified Wed May 30 08:32:30 2018 on firestorm
+;;; Last modified Mon Nov 25 21:01:57 2019 on monster
 ;;; $Id$
 
 ;;; Code:
@@ -168,6 +168,8 @@
 (defvar YaTeX-typeset-rerun-msg "Rerun to get cross-references right.")
 (defvar YaTeX-typeset-citation-msg
   "Warning: Citation \`")
+(defvar YaTeX-typeset-remove-dvi-when-pdf t
+  "*Non-nil means removing dvi file which has same rootname as PDF output")
 (defun YaTeX-typeset-sentinel (proc mes)
   (cond ((null (buffer-name (process-buffer proc)))
          ;; buffer killed
@@ -303,12 +305,22 @@
 			 (if (save-excursion
 			       (re-search-backward
 				(concat
-				 "^Output written on .*\\.pdf (.*page,"
-				 "\\|\\.dvi -> .*\\.pdf$")
+				 "^Output written on \\(.*\\.pdf\\) (.*page,"
+				 "\\|.* -> \\(.*\\.pdf\\)$")
 				nil t))
-			     ;; If PDF output log found in buffer,
-			     ;; set next default previewer to 'pdf viewer
-			     (put 'dvi2-command 'format 'pdf))
+			     (let*((pdf (or (YaTeX-match-string 1)
+					    (YaTeX-match-string 2)))
+				   (rootname (substring
+					      pdf 0 (rindex pdf ?.)))
+				   (dvi (format "%s.dvi" rootname))
+				   (log (format "%s.log" rootname)))
+			       ;; If PDF output log found in buffer,
+			       ;; set next default previewer to 'pdf viewer
+			       (put 'dvi2-command 'format 'pdf)
+			       (if YaTeX-typeset-remove-dvi-when-pdf
+				   (progn
+				     (delete-file log) ;Ugly, should not do here
+				     (delete-file dvi)))))
 		       ;;Confirm process buffer to be shown when error
 		       (YaTeX-showup-buffer
 			pbuf 'YaTeX-showup-buffer-bottom-most)