Emacs: improved 'tex-clean function. More dynamic, using customizable list of extensions. Works on files with spaces.

master
Pierre Neidhardt 2013-01-22 18:42:51 +01:00
parent c1705603c6
commit 0d10761250
1 changed files with 11 additions and 9 deletions

View File

@ -203,10 +203,10 @@ variable, e.g. on the first line:
(defun tex-my-compile () (defun tex-my-compile ()
"Use compile to process your TeX-based document. Use a prefix "Use compile to process your TeX-based document. Use a prefix
argument to call the compiler along the '-shell-escape' argument to call the compiler along the '-shell-escape'
option. This will enable the use of '\write18{<external option. This will enable the use of '\write18{<external
command>}' from within TeX documents, which need to command>}' from within TeX documents, which need to allow
allow external application to be called from TeX. external application to be called from TeX.
This may be useful for some features like GnuPlot support with TikZ. This may be useful for some features like GnuPlot support with TikZ.
@ -238,17 +238,19 @@ WARNING: the -shell-escape option is a potential security issue."
(delete-windows-on "*compilation*") (delete-windows-on "*compilation*")
) )
;; TODO: rewrite this function using lists and/or macros. (defcustom tex-my-extension-list '(".aux" ".glg" ".glo" ".gls" ".idx" ".ilg" ".ind" ".lof" ".log" ".nav" ".out" ".snm" ".synctex" ".synctex.gz" ".tns" ".toc" ".xdy")
;; Add .synctex.gz and .synctex "List of known TeX exentsions. This list is used by 'tex-clean to purge all matching files."
:safe 'listp)
(defun tex-clean () (defun tex-clean ()
"Remove all TeX temporary files. This command should be safe, "Remove all TeX temporary files. This command should be safe,
but there is no warranty." but there is no warranty."
(interactive) (interactive)
(setq file-noext (replace-regexp-in-string ".tex" "" (file-name-nondirectory buffer-file-name))) (setq file-noext (replace-regexp-in-string ".tex" "" (file-name-nondirectory buffer-file-name)))
(shell-command (shell-command
(concat "rm -f " (concat "rm -f \"" file-noext
file-noext ".aux " file-noext ".glg" file-noext ".glo" file-noext ".gls" file-noext ".idx " file-noext ".ilg " file-noext ".ind " file-noext ".lof " file-noext ".log " file-noext ".nav " file-noext ".out " file-noext ".snm " file-noext ".tns " file-noext ".toc " file-noext ".xdy" (mapconcat 'identity tex-my-extension-list (concat "\" \"" file-noext))
) "\"")
) )
) )