Hello,

First, I must thank the developers of preview-latex for this really
great package.

Included is a small patch for preview-latex that does three things:

1) Greatly reduces file clutter.  When generating previews, only two
   things are added to the main tex directory, a directory called
   MASTERTEXFILE.prv and a file called file _region_.tex.  All other
   files generated when creating previews, including previews of
   regions, are placed in the directory MASTERTEXFILE.prv.

2) Any typeset version of the document, such as a .pdf or .dvi file is
   left alone.  Previously they were deleted when generating a preview.

3) Auxilary files are created for previews since there is no longer
   any danger of clobbering anything.

Regards,

Tim

Index: ChangeLog
===================================================================
RCS file: /sources/auctex/auctex/ChangeLog,v
retrieving revision 5.1627
diff -u -u -p -r5.1627 ChangeLog
--- ChangeLog	26 Oct 2008 17:51:29 -0000	5.1627
+++ ChangeLog	30 Oct 2008 13:38:28 -0000
@@ -1,3 +1,7 @@
+2008-10-30  Timothy Toolan  <[EMAIL PROTECTED]>
+
+	* tex.el (TeX-expand-list): Add %M.
+
 2008-10-26  Ralf Angeli  <[EMAIL PROTECTED]>
 
 	* tex.el (plain-TeX-common-initialization): Respect double dollar,
Index: tex.el
===================================================================
RCS file: /sources/auctex/auctex/tex.el,v
retrieving revision 5.635
diff -u -u -p -r5.635 tex.el
--- tex.el	26 Oct 2008 17:50:58 -0000	5.635
+++ tex.el	30 Oct 2008 13:38:28 -0000
@@ -500,7 +500,8 @@ string."
     ;; case the file is in a different subdirectory
     ("%b" TeX-current-file-name-master-relative)
     ;; the following is for preview-latex.
-    ("%m" preview-create-subdirectory))
+    ("%m" preview-create-subdirectory)
+    ("%M" preview-create-prv-directory))
   "List of expansion strings for TeX command names.
 
 Each entry is a list with two or more elements.  The first element is
Index: preview/ChangeLog
===================================================================
RCS file: /sources/auctex/auctex/preview/ChangeLog,v
retrieving revision 1.871
diff -u -u -p -r1.871 ChangeLog
--- preview/ChangeLog	10 May 2008 20:16:07 -0000	1.871
+++ preview/ChangeLog	30 Oct 2008 13:38:28 -0000
@@ -1,3 +1,27 @@
+2008-10-30  Timothy Toolan  <[EMAIL PROTECTED]>
+
+	* latex/preview.dtx: Remove \nofiles from the auctex option.
+	Rename .aux file names to contain no directory component.
+
+	* preview.el (preview-dvipng-command, preview-dvips-command)
+	(preview-fast-dvips-command, preview-pdf2dsc-command): Add temp
+	directory path component to input file.
+	(preview-dvips-abort, preview-gs-dvips-sentinel)
+	(preview-dvipng-place-all): Add temp directory path component to
+	file to be deleted.
+	(preview-LaTeX-command): Remove \nofiles command.
+	(preview-create-prv-directory): Add function.
+	(preview-create-subdirectory): Change TeX-active-master to
+	TeX-master-file.
+	(preview-start-pdf2dsc): Add temp directory path component to
+	input file.
+	(preview-dump-replacements, preview-undump-replacements): Add
+	-output-directory option and insert temp directory path.
+	(preview-nodump-replacements): New definition.
+	(preview-cache-preamble): Define preview-output-dir.
+	(TeX-inline-preview-internal): Define preview-output-dir, call
+	preview-do-replacements when not caching preamble.
+
 2008-05-10  Reiner Steib  <[EMAIL PROTECTED]>
 
 	* preview.el (preview-auto-cache-preamble): Fix markup in in doc
Index: preview/preview.el
===================================================================
RCS file: /sources/auctex/auctex/preview/preview.el,v
retrieving revision 1.283
diff -u -u -p -r1.283 preview.el
--- preview/preview.el	10 May 2008 20:16:06 -0000	1.283
+++ preview/preview.el	30 Oct 2008 13:38:29 -0000
@@ -523,7 +523,7 @@ an explicit list of elements in the CDR,
 be consulted recursively.")
 
 (defcustom preview-dvipng-command
-  "dvipng -picky -noghostscript %d -o \"%m/prev%%03d.png\""
+  "dvipng -picky -noghostscript %M/%d -o \"%m/prev%%03d.png\""
   "*Command used for converting to separate PNG images.
 
 You might specify options for converting to other image types,
@@ -543,19 +543,19 @@ if you customize this."
 		 (symbol :tag "Other" :value png)))
 
 (defcustom preview-dvips-command
-  "dvips -Pwww -i -E %d -o %m/preview.000"
+  "dvips -Pwww -i -E %M/%d -o %m/preview.000"
   "*Command used for converting to separate EPS images."
   :group 'preview-latex
   :type 'string)
 
 (defcustom preview-fast-dvips-command
-  "dvips -Pwww %d -o %m/preview.ps"
+  "dvips -Pwww %M/%d -o %m/preview.ps"
   "*Command used for converting to a single PS file."
   :group 'preview-latex
   :type 'string)
 
 (defcustom preview-pdf2dsc-command
-  "pdf2dsc %s.pdf %m/preview.dsc"
+  "pdf2dsc %M/%s.pdf %m/preview.dsc"
   "*Command used for generating dsc from a PDF file."
   :group 'preview-latex
   :type 'string)
@@ -861,7 +861,8 @@ Pure borderless black-on-white will retu
       (delete-file
        (let ((gsfile preview-gs-file))
 	 (with-current-buffer TeX-command-buffer
-	   (funcall (car gsfile) "dvi"))))
+	   (concat (preview-create-prv-directory) "/" 
+                   (funcall (car gsfile) "dvi")))))
     (file-error nil))
   (when preview-ps-file
       (condition-case nil
@@ -885,7 +886,8 @@ The usual PROCESS and COMMAND arguments 
 	       (condition-case nil
 		   (delete-file
 		    (with-current-buffer TeX-command-buffer
-		      (funcall (car gsfile) "dvi")))
+                      (concat (preview-create-prv-directory) "/"
+                              (funcall (car gsfile) "dvi"))))
 		 (file-error nil))
 	       (if preview-ps-file
 		   (preview-prepare-fast-conversion))
@@ -1931,7 +1933,8 @@ Deletes the dvi file when finished."
 	  (let ((gsfile preview-gs-file))
 	    (delete-file
 	     (with-current-buffer TeX-command-buffer
-	       (funcall (car gsfile) "dvi"))))
+               (concat (preview-create-prv-directory) "/"
+                       (funcall (car gsfile) "dvi")))))
 	(file-error nil)))))
    
 (defun preview-active-string (ov)
@@ -2212,7 +2215,7 @@ list of LaTeX commands is inserted just 
   :group 'preview-latex
   :type preview-expandable-string)
 
-(defcustom preview-LaTeX-command '("%`%l \"\\nonstopmode\\nofiles\
+(defcustom preview-LaTeX-command '("%`%l \"\\nonstopmode\
 \\PassOptionsToPackage{" ("," . preview-required-option-list) "}{preview}\
 \\AtBeginDocument{\\ifx\\ifPreview\\undefined"
 preview-default-preamble "\\fi}\"%' %t")
@@ -2537,6 +2540,17 @@ might be needed for colloborative work o
 	    (directory-files topdir t "\\`tmp" t)
 	  (file-error nil))))
 
+(defun preview-create-prv-directory ()
+  "If necessary, generate a top directory similar to that in
+`preview-create-subdirectory', then return the name of the
+created directory relative to the master directory, in
+shell-quoted form."
+  (let ((topdir (expand-file-name (TeX-master-file "prv"))))
+    (unless (file-directory-p topdir)
+      (make-directory topdir))
+    (add-hook 'kill-emacs-hook #'preview-cleanout-tempfiles t)
+    (shell-quote-argument (file-name-nondirectory topdir))))
+
 (defun preview-create-subdirectory ()
   "Create a temporary subdir for the current TeX process.
 If necessary, generates a fitting top
@@ -2548,7 +2562,7 @@ set to the corresponding TEMPDIR descrip
 in `preview-make-filename'.  The directory is registered
 in `preview-temp-dirs' in order not to be cleaned out
 later while in use."
-  (let ((topdir (expand-file-name (TeX-active-master "prv"))))
+  (let ((topdir (expand-file-name (TeX-master-file "prv"))))
     (if (file-directory-p topdir)
 	(unless (member topdir preview-temp-dirs)
 	  ;;  Cleans out the top preview directory by
@@ -3091,18 +3105,19 @@ If FAST is set, do a fast conversion."
 (defun preview-start-pdf2dsc ()
   "Start a PDF2DSC process."
   (let* ((file preview-gs-file)
-	 tempdir
+	 tempdir tempprvdir
 	 pdfsource
 	 (command (with-current-buffer TeX-command-buffer
 		    (prog1
 			(TeX-command-expand preview-pdf2dsc-command
 					    (car file))
 		      (setq tempdir TeX-active-tempdir
+                            tempprvdir (preview-create-prv-directory)
 			    pdfsource (TeX-master-file "pdf")))))
 	 (name "Preview-PDF2DSC"))
     (setq TeX-active-tempdir tempdir)
     (setq preview-ps-file (preview-attach-filename
-			   pdfsource
+			   (concat tempprvdir "/" pdfsource)
 			   (preview-make-filename
 			    (preview-make-filename
 			     "preview.dsc" tempdir) tempdir)))
@@ -3222,22 +3237,33 @@ This is passed through `preview-do-repla
 				 (string :tag "non-literal regexp replacement")))))))
 
 (defvar preview-format-name)
+(defvar preview-output-dir)
 
 (defcustom preview-dump-replacements
   '(preview-LaTeX-command-replacements
-    ("\\`\\([^ ]+\\)\
+    ("\\`\\([^ ]+\\)\\( +-output-directory=[^ ]+\\.prv\\|\\)\
 \\(\\( +-\\([^ \\\\\"]\\|\\\\\\.\\|\"[^\"]*\"\\)*\\)*\\)\\(.*\\)\\'"
-     . ("\\1 -ini -interaction=nonstopmode \"&\\1\" " preview-format-name ".ini \\5")))
+     . ("\\1 -output-directory=" preview-output-dir " -ini -interaction=nonstopmode \"&\\1\" " preview-format-name ".ini \\6")))
   "Generate a dump command from the usual preview command."
   :group 'preview-latex
   :type '(repeat
 	  (choice (symbol :tag "Named replacement")
 		  (cons string (repeat (choice symbol string))))))
 
+(defcustom preview-nodump-replacements
+  '(("\\`\\([^ ]+\\)\
+\\(.*\\)\\'"
+     . ("\\1 -output-directory=" preview-output-dir " \\2")))
+  "Just add the output directory to the usual preview command."
+  :group 'preview-latex
+  :type '(repeat
+	  (choice (symbol :tag "Named replacement")
+		  (cons string (repeat (choice symbol string))))))
+
 (defcustom preview-undump-replacements
   '(("\\`\\([^ ]+\\)\
  .*? \"\\\\input\" \\(.*\\)\\'"
-     . ("\\1 -interaction=nonstopmode \"&" preview-format-name "\" \\2")))
+     . ("\\1 -interaction=nonstopmode -output-directory=" preview-output-dir " \"&" preview-output-dir "/" preview-format-name "\" \\2")))
   "Use a dumped format for reading preamble."
   :group 'preview-latex
   :type '(repeat
@@ -3259,6 +3285,7 @@ If FORMAT-CONS is non-nil, a previous fo
 	  (expand-file-name (preview-dump-file-name (TeX-master-file "ini"))))
 	 (master (TeX-master-file))
 	 (format-name (expand-file-name master))
+         (preview-output-dir (preview-create-prv-directory))
 	 (preview-format-name (shell-quote-argument
 			       (preview-dump-file-name (file-name-nondirectory
 							master))))
@@ -3471,13 +3498,15 @@ internal parameters, STR may be a log to
       ((preview-format-name (shell-quote-argument
 			     (preview-dump-file-name
 			      (file-name-nondirectory master))))
+       (preview-output-dir (preview-create-prv-directory))
        (process
 	(TeX-run-command
 	 "Preview-LaTeX"
 	 (if (consp (cdr dumped-cons))
 	     (preview-do-replacements
 	      command preview-undump-replacements)
-	   command) file)))
+	   (preview-do-replacements
+            command preview-nodump-replacements)) file)))
     (condition-case err
 	(progn
 	  (when str
Index: preview/latex/preview.dtx
===================================================================
RCS file: /sources/auctex/auctex/preview/latex/preview.dtx,v
retrieving revision 1.124
diff -u -u -p -r1.124 preview.dtx
--- preview/latex/preview.dtx	3 Feb 2008 14:53:31 -0000	1.124
+++ preview/latex/preview.dtx	30 Oct 2008 13:38:29 -0000
@@ -20,7 +20,7 @@
 %     Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
 %     Boston, MA 02110-1301  USA
 % \fi
-% \CheckSum{1664}
+% \CheckSum{1748}
 % \GetFileInfo{preview.sty}
 % \date{\filedate}
 % \author{David [EMAIL PROTECTED]
@@ -1305,17 +1305,57 @@ Please complain to your document class a
 % long as the document has not started, but after that we need the
 % error message mechanism operative.
 %
-% The |\nofiles| command here tries to avoid clobbering input files
-% used for references and similar.  It will come too late if you call
-% the package with \cmd{\AtBeginDocument}, so you'll need to issue
-% |\nofiles| yourself in that case.  Previously, this was done
-% unconditionally in the main style file, but since we don't know what
-% the package may be used for, this was inappropriate.
-%
 % So here is the contents of the |prauctex.def| file:
 %    \begin{macrocode}
 %<auctex>\ifPreview\else\expandafter\endinput\fi
-%<auctex>\nofiles
+%    \end{macrocode}
+% This function will define the global macro |[EMAIL PROTECTED]| which will
+% contain the argument |#1| with all slashes replaced with dashes.
+% The macro |[EMAIL PROTECTED]| can safely be used in a |\write| or |\edef|
+% command.
+%    \begin{macrocode}
+%<auctex>[EMAIL PROTECTED]@[EMAIL PROTECTED]
+%<auctex>[EMAIL PROTECTED]
+%<auctex>  \else\if#1/[EMAIL PROTECTED]@argnoslash-}\else%
+%<auctex>  [EMAIL PROTECTED]@argnoslash#1}\fi%
+%<auctex>  [EMAIL PROTECTED]
+%    \end{macrocode}
+% It would be nicer to wrap this with a |\let|, but because the
+% argument needs to be used unmodified in some places and modified in
+% others, it was copied here from |latex.ltx| and modified.  The three
+% changes include the line to define |[EMAIL PROTECTED]| and replacing |#1|
+% with |[EMAIL PROTECTED]| in the two places where the .aux file is used.
+%    \begin{macrocode}
+%<auctex>[EMAIL PROTECTED] {%
+%<auctex>  [EMAIL PROTECTED]
+%<auctex>  \clearpage
+%<auctex>  [EMAIL PROTECTED]
+%<auctex>    [EMAIL PROTECTED]@[EMAIL PROTECTED]
+%<auctex>  \fi
+%<auctex>  [EMAIL PROTECTED]
+%<auctex>  [EMAIL PROTECTED]
+%<auctex>    [EMAIL PROTECTED]
+%<auctex>    [EMAIL PROTECTED]
+%<auctex>    [EMAIL PROTECTED]@a:[EMAIL PROTECTED]
+%<auctex>      [EMAIL PROTECTED]@[EMAIL PROTECTED]
+%<auctex>  \fi
+%<auctex>  [EMAIL PROTECTED]
+%<auctex>    [EMAIL PROTECTED]@partaux
+%<auctex>    [EMAIL PROTECTED]
+%<auctex>      [EMAIL PROTECTED] [EMAIL PROTECTED]
+%<auctex>      [EMAIL PROTECTED]
+%<auctex>    \fi
+%<auctex>    [EMAIL PROTECTED]@{#1.tex}%
+%<auctex>    \clearpage
+%<auctex>    [EMAIL PROTECTED]
+%<auctex>    [EMAIL PROTECTED]
+%<auctex>      [EMAIL PROTECTED]
+%<auctex>    \fi
+%<auctex>  \else
+%<auctex>    \deadcycles\z@
+%<auctex>    [EMAIL PROTECTED]@#1}%
+%<auctex>  \fi
+%<auctex>  [EMAIL PROTECTED]@mainaux}
 %<auctex>[EMAIL PROTECTED]
 %    \end{macrocode}
 % Ok, here comes creative error message formatting.  It turns out a
_______________________________________________
auctex-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/auctex-devel

Reply via email to