Emacs: TeX pdf compression now supports spaces.

Emacs: tex-clean in LISP, no more shell.
master
Pierre Neidhardt 2013-02-26 21:30:27 +01:00
parent b97c7e9f40
commit 14dae113bb
1 changed files with 24 additions and 12 deletions

View File

@ -274,7 +274,7 @@ WARNING: the -shell-escape option is a potential security issue."
(delete-windows-on "*compilation*"))))
(defcustom tex-my-extension-list '(".aux" ".glg" ".glo" ".gls" ".idx" ".ilg" ".ind" ".lof" ".log" ".nav" ".out" ".snm" ".synctex" ".synctex.gz" ".tns" ".toc" ".xdy")
(defcustom tex-my-extension-list '("aux" "glg" "glo" "gls" "idx" "ilg" "ind" "lof" "log" "nav" "out" "snm" "synctex" "synctex.gz" "tns" "toc" "xdy")
"List of known TeX exentsions. This list is used by 'tex-clean to purge all matching files."
:safe 'listp)
@ -290,11 +290,23 @@ but there is no warranty."
buffer-file-name
tex-my-masterfile)))
(setq file-noext (replace-regexp-in-string ".tex" "" (file-name-nondirectory local-master)))
(shell-command
(concat "rm -f \"" file-noext
(mapconcat 'identity tex-my-extension-list (concat "\" \"" file-noext))
"\""))))
(let (
;; File name without extension.
(file
(replace-regexp-in-string "tex" "" (file-name-nondirectory local-master))))
;; Concatate file name to list.
(mapcar
;; Delete file if exist
(lambda (argfile) (interactive)
(when (and (file-exists-p argfile) (file-writable-p argfile))
(delete-file argfile)
(message "[%s] deleted." argfile)))
(mapcar
;; Concat file name with extensions.
(lambda (arg) (interactive) (concat file arg))
tex-my-extension-list))
)))
(defun tex-pdf-compress ()
"PDF compressions might really strip down the PDF size. The
@ -313,13 +325,13 @@ your document embeds raster graphics."
(file-temp
(concat (make-temp-name (concat "/tmp/" (file-name-nondirectory local-master))) ".pdf"))
;; File name with extension.
;; File name with PDF extension.
(file
(replace-regexp-in-string "tex" "pdf" (file-name-nondirectory local-master))))
(when (and (file-exists-p file) (file-writable-p file))
(shell-command
(concat "gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=" file-temp " " file))
(concat "gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=\"" file-temp "\" \"" file "\""))
(rename-file file-temp file t)
))))