3

How can I tell preview-latex to store all temporary files (especially the folder _region_.prv which contains the preview images) in /tmp and not in the folder of my actual .tex file, when I'm using it with AucTeX in emacs?

I checked the documentation and also looked in the customize-group of preview and auctex for a variable that allows me to select the directory for temporary files but without success. I know, that this question was already asked 3 years ago but without any real solution as far as I can tell. Maybe now 3 years later there is a solution for this?

In the case, that this really would not be possible, is there a way to delete all this preview related files (including the _region_.prv folder) on exiting the .tex file?

1

I don't know if it is possible to do it easily with AUCTeX and I think it's not a good idea to modify a package so I provide a solution to clear the folder.

You can definie a function clear-preview:

(defun clear-preview () (shell-command "rm -rf *.prv preview.fmt"))

If there is other file created by the preview function you can add them also.

  • @BenjaminSchiel you're welcome. Do other file are created or not? If it's the case I must modify the answer to have a proper clean function – Romain Picot Jan 3 '16 at 12:09
  • Yes sometimes there is a preview.fmt file created for the previews. It would be good to delete it too. – BenjaminSchiel Jan 9 '16 at 23:42
  • @BenjaminSchiel answer update 😃 – Romain Picot Jan 10 '16 at 10:47
0

As a partial answer, it's now (as of auctex-11.89, probably earlier) possible to set the prefix for the AUCTeX region files (_region_.tex etc.) by customising TeX-region, away from the default _region_. (This is relevant for the _region_.prv folder.) For example, one can set the variable to .auctex_region_, at least causing the generated files to be "hidden" files. Note, however, that under most normal configurations, LaTeX cannot touch hidden "dot" files, due to security reasons (for some details see here), so with the above setting of the variable, TeX-command-region and the like won't work; preview-latex, though will still work normally.

Unfortunately, naively setting TeX-region to a string containing a slash, to force the files to be placed in a subdirectory, does not work — the _region_.tex file will be located in the subdirectory, as desired, but the latex child process will output its files into the project root directory instead and AUCTeX won't find them.

Additionally, the value of the prefix for the prv_ files appears to be hard-coded in preview.el in the function preview-dump-file-name. Obviously, one could override the function or advise it, but that seems less elegant and future-proof.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.