branch: main
commit d151b5c9feb5480b47d05276dfa10f3f288eea29
Author: Al Haji-Ali <[email protected]>
Commit: Arash Esbati <[email protected]>
Save ini files inside `TeX-output-dir'
* preview.el (preview-dumped-alist): Change format to include
output file.
(preview-watch-preamble): Accept output file as argument to save
in format-cons.
(preview-unwatch-preamble, preview-mode-setup): Accommodate
changes of format-cons above.
(preview-format-kill): Delete output file.
(preview-cache-preamble): Use TeX-master-output-file instead of
TeX-master-output for ini file.
---
preview.el | 86 +++++++++++++++++++++++++++++++++-----------------------------
1 file changed, 46 insertions(+), 40 deletions(-)
diff --git a/preview.el b/preview.el
index bb0f8ee9..fc0b7566 100644
--- a/preview.el
+++ b/preview.el
@@ -1898,7 +1898,7 @@ definition of OV, AFTER-CHANGE, BEG, END and LENGTH."
(preview-format-kill format-cons)
(setcdr format-cons t)))
-(defun preview-watch-preamble (file command format-cons)
+(defun preview-watch-preamble (file command format-cons &optional out-file)
"Set up a watch on master file FILE.
FILE can be an associated buffer instead of a filename.
COMMAND is the command that generated the format.
@@ -1906,32 +1906,35 @@ FORMAT-CONS contains the format info for the main
format dump handler."
(let ((buffer (if (bufferp file)
file
- (find-buffer-visiting file))) ov)
+ (find-buffer-visiting file)))
+ ov)
(setcdr
format-cons
- (cons command
- (when buffer
- (with-current-buffer buffer
- (save-excursion
- (save-restriction
- (widen)
- (goto-char (point-min))
- (unless (re-search-forward preview-dump-threshold nil t)
- (error "Can't find preamble of `%s'" file))
- (setq ov (make-overlay (point-min) (point)))
- (overlay-put ov 'format-cons format-cons)
- (overlay-put ov 'insert-in-front-hooks
- '(preview-preamble-changed-function))
- (overlay-put ov 'modification-hooks
- '(preview-preamble-changed-function))
- ov))))))))
+ (cl-list*
+ (or out-file file)
+ command
+ (when buffer
+ (with-current-buffer buffer
+ (save-excursion
+ (save-restriction
+ (widen)
+ (goto-char (point-min))
+ (unless (re-search-forward preview-dump-threshold nil t)
+ (error "Can't find preamble of `%s'" file))
+ (setq ov (make-overlay (point-min) (point)))
+ (overlay-put ov 'format-cons format-cons)
+ (overlay-put ov 'insert-in-front-hooks
+ '(preview-preamble-changed-function))
+ (overlay-put ov 'modification-hooks
+ '(preview-preamble-changed-function))
+ ov))))))))
(defun preview-unwatch-preamble (format-cons)
"Stop watching a format on FORMAT-CONS.
The watch has been set up by `preview-watch-preamble'."
(when (consp (cdr format-cons))
- (when (cddr format-cons)
- (delete-overlay (cddr format-cons)))
+ (when (cdddr format-cons)
+ (delete-overlay (cdddr format-cons)))
(setcdr (cdr format-cons) nil)))
(defun preview-register-change (ov)
@@ -2493,15 +2496,14 @@ Possible values are nil, t, and `ask'."
(defvar preview-dumped-alist nil
"Alist of dumped masters.
-The elements are (NAME . ASSOC). NAME is the master file name
-\(without extension), ASSOC is what to do with regard to this
-format. Possible values: nil means no format is available
-and none should be generated. t means no format is available,
-it should be generated on demand. If the value is a cons cell,
-the CAR of the cons cell is the command with which the format
-has been generated, and the CDR is some Emacs-flavor specific
-value used for maintaining a watch on possible changes of the
-preamble.")
+The elements are (NAME . ASSOC). NAME is the master file name (without
+extension), ASSOC is what to do with regard to this format. Possible
+values: nil means no format is available and none should be generated.
+t means no format is available, it should be generated on demand. If
+the value is a cons cell, the CAR of the cons cell is the name of output
+master file, the CADR of the cons cell is the command with which the
+format has been generated, and the CDDR is some Emacs-flavor specific
+value used for maintaining a watch on possible changes of the preamble.")
(defun preview-cleanout-tempfiles ()
"Clean out all directories and files with non-persistent data.
@@ -3156,8 +3158,9 @@ pp")
(when (consp (cdr format-cons))
(preview-unwatch-preamble format-cons)
(preview-watch-preamble (current-buffer)
- (cadr format-cons)
- format-cons)))))
+ (caddr format-cons)
+ format-cons
+ (cadr format-cons))))))
;;;###autoload
(defun LaTeX-preview-setup ()
@@ -3996,10 +3999,11 @@ Those are just needed for cleanup."
"Kill a cached format.
FORMAT-CONS is intended to be an element of `preview-dumped-alist'.
Tries through `preview-format-extensions'."
- (dolist (ext preview-format-extensions)
- (condition-case nil
- (delete-file (preview-dump-file-name (concat (car format-cons) ext)))
- (file-error nil))))
+ (when (consp (cdr format-cons))
+ (dolist (ext preview-format-extensions)
+ (condition-case nil
+ (delete-file (preview-dump-file-name (concat (cadr format-cons)
ext)))
+ (file-error nil)))))
(defun preview-dump-file-name (file)
"Make a file name suitable for dumping from FILE."
@@ -4101,20 +4105,21 @@ If FORMAT-CONS is non-nil, a previous format may get
reused."
(interactive)
(setq TeX-current-process-region-p nil)
(let* ((dump-file
- (expand-file-name (preview-dump-file-name (TeX-master-file "ini"))))
+ (expand-file-name (preview-dump-file-name (TeX-master-output-file
"ini"))))
(master (TeX-master-file))
(format-name (expand-file-name master))
(preview-format-name (shell-quote-argument
- (preview-dump-file-name (file-name-nondirectory
- master))))
+ (preview-dump-file-name
+ (TeX-master-output-file nil))))
(master-file (expand-file-name (TeX-master-file t)))
+ (master-output-file (expand-file-name (TeX-master-output-file nil)))
(command (preview-do-replacements
(TeX-command-expand
(preview-string-expand preview-LaTeX-command))
preview-dump-replacements))
(preview-auto-cache-preamble nil))
(unless (and (consp (cdr format-cons))
- (string= command (cadr format-cons)))
+ (string= command (caddr format-cons)))
(unless format-cons
(setq format-cons (assoc format-name preview-dumped-alist)))
(if format-cons
@@ -4162,7 +4167,8 @@ If FORMAT-CONS is non-nil, a previous format may get
reused."
(preview-watch-preamble
master-file
command
- format-cons)
+ format-cons
+ master-output-file)
(preview-format-kill format-cons))
(delete-file dump-file))
(error (preview-log-error err "Dumping" process)))