bug#79473: 14.1.0; [PATCH] Save ini preview files inside TeX-output-dir
On 29/09/2025, Al Haji-Ali wrote: > Here's another patch that allows running the test in batch-mode. @Ikumi, is this what you had in mind regarding the test? Best regards, -- Al ___ bug-auctex mailing list [email protected] https://lists.gnu.org/mailman/listinfo/bug-auctex
bug#79473: 14.1.0; [PATCH] Save ini preview files inside TeX-output-dir
Hello Ikumi, On 29/09/2025, Ikumi Keita wrote: > You are following the test codes in tests/japanese directory. Is that > really necessary? I wrote three tests `japanese-preview-shift-jis', > `japanese-preview-different-coding-system' and > `japanese-preview-preserve-kanji-option' to be skipped in batch mode > because their issues involve misplacement of the preview images and thus > require confirmation by human eyes. That was what I tried first. Unfortunately, running in batch mode would require further investigations and changes. The first issue I ran into is that preview-cache-preamble -> preview-generate-preview -> preview-get-geometry -> preview-get-dpi fails in batch mode with an error: Wrong type argument: number-or-marker-p, nil because `frame-monitor-attributes` returns an alist with `mm-size` set to nil, when run in batch mode (but not in interactive mode). Most likely this geometry is not needed when caching the preamble, but some further modification would be required to handle this case. -- Al ___ bug-auctex mailing list [email protected] https://lists.gnu.org/mailman/listinfo/bug-auctex
bug#79473: 14.1.0; [PATCH] Save ini preview files inside TeX-output-dir
Hi all, Ikumi Keita writes: >> Al Haji-Ali writes: >> so even adding a new element to the tail would mean that CDDDR is no >> longer the Emacs-flavor specific value mentioned above (it would be a >> cons of such a value with the output file). > > Hmm. If I understand correctly, it is no longer possible to keep the > compatibility of the structure of (each element of) > `preview-dumped-alist' anyway, right? > Then I don't object strongly to have your proposal as-is, provided that > you add explicit statement of the format change and spell out how it > changed in NEWS.org. > Arash, what do you think about it? Thanks for looking at this. So, we have to bite the bullet. Should I install the patch provided upthread? We can then add something about it to NEWS.org. Best, Arash ___ bug-auctex mailing list [email protected] https://lists.gnu.org/mailman/listinfo/bug-auctex
bug#79473: 14.1.0; [PATCH] Save ini preview files inside TeX-output-dir
> Al Haji-Ali writes: > On 29/09/2025, Al Haji-Ali wrote: >> Here's another patch that allows running the test in batch-mode. > @Ikumi, is this what you had in mind regarding the test? Yes, it looks good to me. Sorry, I was lazy to look over your proposal. I'll install this fix and close this bug. Thank you so much for your cooperation. Regards, Ikumi Keita #StandWithUkraine #StopWarInUkraine #Gaza #StopGenocide #CeasefireNOW ___ bug-auctex mailing list [email protected] https://lists.gnu.org/mailman/listinfo/bug-auctex
bug#79473: 14.1.0; [PATCH] Save ini preview files inside TeX-output-dir
Hi Al, Al Haji-Ali writes: > This is another follow-up bug-report/patch from: > https://lists.gnu.org/archive/html/auctex-devel/2025-08/msg00026.html > > When caching the preamble while previewing files, an ini file is > created.. The attached places this ini file inside TeX-output-dir when > that is non-nil. A change to the format of the variable > `preview-dumped-alist` was required to save the name of the output file. > > Best regards, > -- Al > > From 61d952df797957dc66e2f065a24bd691a832b855 Mon Sep 17 00:00:00 2001 > From: Al Haji-Ali > Date: Wed, 3 Sep 2025 21:56:08 +0100 > Subject: [PATCH] Save ini preview 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 | 71 ++ > 1 file changed, 39 insertions(+), 32 deletions(-) > > diff --git a/preview.el b/preview.el > index bb0f8ee9..e86b0035 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 out-file command format-cons) Many thanks for the patch. Before looking further, is it possible to change the signature in a backward compatible way? The usual practice is append new args to the arg-list as optional ones, i.e.: (defun preview-watch-preamble (file command format-cons &optional out-file) I don't think this function is widely used elsewhere, but still. @Keita: WDYT? Best, Arash ___ bug-auctex mailing list [email protected] https://lists.gnu.org/mailman/listinfo/bug-auctex
bug#79473: 14.1.0; [PATCH] Save ini preview files inside TeX-output-dir
Hi Al, > Al Haji-Ali writes: > so even adding a new element to the tail would mean that CDDDR is no > longer the Emacs-flavor specific value mentioned above (it would be a > cons of such a value with the output file). Hmm. If I understand correctly, it is no longer possible to keep the compatibility of the structure of (each element of) `preview-dumped-alist' anyway, right? Then I don't object strongly to have your proposal as-is, provided that you add explicit statement of the format change and spell out how it changed in NEWS.org. Arash, what do you think about it? Regards, Ikumi Keita #StandWithUkraine #StopWarInUkraine #Gaza #StopGenocide #CeasefireNOW ___ bug-auctex mailing list [email protected] https://lists.gnu.org/mailman/listinfo/bug-auctex
bug#79473: 14.1.0; [PATCH] Save ini preview files inside TeX-output-dir
Hello again,
On 29/09/2025, Al Haji-Ali wrote:
> That was what I tried first. Unfortunately, running in batch mode would
> require further investigations and changes.
Here's another patch that allows running the test in batch-mode.
As you can see, I had to modify `preview-get-dpi` to handle nil
dimensions which are returned in batch-mode, but I don't know if this
could possibly have other consequences if run interactively (it would
have thrown an error before).
-- Al
>From a034a594e7f5940a5f353b9278e38b53c2bc56db Mon Sep 17 00:00:00 2001
From: Al Haji-Ali
Date: Sat, 27 Sep 2025 21:56:01 +0200
Subject: [PATCH] Add missing documentation and test related to
`preview-watch-preamble'.
* NEWS.org: Record changes related to `preview-dumped-alist' and
`preview-watch-preamble'.
* preview.el (preview-watch-preamble): Add missing documentation for
optional argument.
(preview-get-dpi): Handle nil dimensions for batch mode.
* tests/latex/preview-latex-test.el (preview-cache-preamble): Add test
for `preview-cache-preamble' with non-nil `TeX-output-dir'.
---
NEWS.org | 4 ++
preview.el| 12 +++---
tests/latex/preview-latex-test.el | 68 +++
3 files changed, 78 insertions(+), 6 deletions(-)
diff --git a/NEWS.org b/NEWS.org
index d17064e0..2df87479 100644
--- a/NEWS.org
+++ b/NEWS.org
@@ -17,6 +17,10 @@
- Add new support file =style/fontawesome7.el=.
+** Changed
+- Change the format of ~preview-dumped-alist~ and add new optional
+ argument to ~preview-watch-preamble~.
+
* [14.1.0] - 2025-07-11
** Added
diff --git a/preview.el b/preview.el
index fc0b7566..0b1d1207 100644
--- a/preview.el
+++ b/preview.el
@@ -1900,10 +1900,10 @@ definition of OV, AFTER-CHANGE, BEG, END and LENGTH."
(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.
-FORMAT-CONS contains the format info for the main
-format dump handler."
+FILE can be an associated buffer instead of a filename. COMMAND is the
+command that generated the format. FORMAT-CONS contains the format info
+for the main format dump handler. If OUT-FILE is non-nil it is used
+instead of FILE to determine the dump-files."
(let ((buffer (if (bufferp file)
file
(find-buffer-visiting file)))
@@ -3778,8 +3778,8 @@ name(\\([^)]+\\))\\)\\|\
(defun preview-get-dpi ()
(let* ((monitor-attrs (frame-monitor-attributes))
(mm-dims (cdr (assoc 'mm-size monitor-attrs)))
- (mm-width (nth 0 mm-dims))
- (mm-height (nth 1 mm-dims))
+ (mm-width (or (nth 0 mm-dims) 1))
+ (mm-height (or (nth 1 mm-dims) 1))
(pixel-dims (cl-cdddr (assoc 'geometry monitor-attrs)))
(pixel-width (nth 0 pixel-dims))
(pixel-height (nth 1 pixel-dims)))
diff --git a/tests/latex/preview-latex-test.el b/tests/latex/preview-latex-test.el
index 8c7d8314..8b69bb2e 100644
--- a/tests/latex/preview-latex-test.el
+++ b/tests/latex/preview-latex-test.el
@@ -23,6 +23,11 @@
(require 'ert)
(require 'preview)
+(require 'font-latex)
+
+(AUCTeX-set-ert-path
+ 'preview-test-file
+ "../../circ.tex")
(ert-deftest preview-error-quote-utf-8 ()
"`preview-error-quote' is robust against partial ^^-quoting or not.
@@ -42,6 +47,69 @@ emacs' coding system later."
(dolist (str '("prim\xC3\xA1rias" "prim^^c3\xA1rias" "prim^^c3^^a1rias"))
(should (string= (preview--decode-^^ab str 'utf-8) "primárias"
+(ert-deftest preview-cache-preamble ()
+ "Test caching of preamble with non-nil `TeX-output-dir'."
+ (let ((TeX-clean-confirm nil)
+(preview-auto-cache-preamble nil)
+(process-environment (copy-sequence process-environment))
+(TeX-output-dir "auctex-output")
+buffer1 buffer2
+(pt-msg (with-current-buffer (messages-buffer) (point
+(unwind-protect
+(save-window-excursion
+ (setq buffer1 (find-file preview-test-file))
+ (delete-other-windows)
+ (preview-cache-preamble)
+ (setq buffer2 (TeX-active-buffer))
+ (message "Please wait for asynchronous process to finish...")
+ (while (get-buffer-process buffer2)
+(sleep-for 1))
+ (should-error
+ (with-current-buffer (messages-buffer)
+ (goto-char pt-msg)
+ (search-forward "error in process sentinel:")))
+ (message "Please wait for asynchronous process to finish...done")
+
+ (with-current-buffer buffer1
+;; ini file should be deleted
+(should-not
+ (or
+ (file-exists-p
+ (expand-file-name
+(TeX-master-output-file "ini")))
+ (file-exists-p
+ (expand-file-name
+(TeX-master-file "ini")
+;; fmt file sh
bug#79473: 14.1.0; [PATCH] Save ini preview files inside TeX-output-dir
Hi Al, Al Haji-Ali writes: > Please find the attached patch which should do all three. I based my > test off `tests/japanese/preview-latex.el`, but I haven't written a > auctex test before, so let me know if I am missing anything. > > The test should fail an old version of auctex (without the commit > d151b5c9), but should succeed in the new one. thanks, I installed the (slightly changed) hunks for NEWS.org and preview.el under your name. We now only have to sort out the test part. Best, Arash ___ bug-auctex mailing list [email protected] https://lists.gnu.org/mailman/listinfo/bug-auctex
bug#79473: 14.1.0; [PATCH] Save ini preview files inside TeX-output-dir
Hi Al, > Al Haji-Ali writes: > Please find the attached patch which should do all three. I based my > test off `tests/japanese/preview-latex.el`, but I haven't written a > auctex test before, so let me know if I am missing anything. You are following the test codes in tests/japanese directory. Is that really necessary? I wrote three tests `japanese-preview-shift-jis', `japanese-preview-different-coding-system' and `japanese-preview-preserve-kanji-option' to be skipped in batch mode because their issues involve misplacement of the preview images and thus require confirmation by human eyes. I expect that confirmation of the erasure of .ini file and the location of .fmt file can be automated and don't require such human interaction. If I'm not missing something, I'd like you to rewrite your tests to run in batch sessions (i.e., "make" in tests/ directory). Regards, Ikumi Keita #StandWithUkraine #StopWarInUkraine #Gaza #StopGenocide #CeasefireNOW ___ bug-auctex mailing list [email protected] https://lists.gnu.org/mailman/listinfo/bug-auctex
bug#79473: 14.1.0; [PATCH] Save ini preview files inside TeX-output-dir
Hello both,
On 27/09/2025, Arash Esbati wrote:
> I think we have 3 points to address and then we can close this report:
>
> - Add a new test
> - Announce the changes in NEWS.org
> - Touch the docstring of `preview-watch-preamble' and describe the
> optional out-file.
Please find the attached patch which should do all three. I based my
test off `tests/japanese/preview-latex.el`, but I haven't written a
auctex test before, so let me know if I am missing anything.
The test should fail an old version of auctex (without the commit
d151b5c9), but should succeed in the new one.
Best regards,
-- Al
>From 90242bad8a0f0ccdcfc1e408bd286d13f2f12f77 Mon Sep 17 00:00:00 2001
From: Al Haji-Ali
Date: Sat, 27 Sep 2025 21:56:01 +0200
Subject: [PATCH] Add missing documentation and test related to
`preview-watch-preamble'.
* NEWS.org: Record changes related to `preview-dumped-alist' and
`preview-watch-preamble'.
* preview.el (preview-watch-preamble): Add missing documentation for
optional argument.
* tests/latex/preview-latex-test.el (preview-cache-preamble): Add test
for `preview-cache-preamble' with non-nil `TeX-output-dir'.
---
NEWS.org | 4 ++
preview.el| 8 ++--
tests/latex/preview-latex-test.el | 69 +++
3 files changed, 77 insertions(+), 4 deletions(-)
diff --git a/NEWS.org b/NEWS.org
index d17064e0..2df87479 100644
--- a/NEWS.org
+++ b/NEWS.org
@@ -17,6 +17,10 @@
- Add new support file =style/fontawesome7.el=.
+** Changed
+- Change the format of ~preview-dumped-alist~ and add new optional
+ argument to ~preview-watch-preamble~.
+
* [14.1.0] - 2025-07-11
** Added
diff --git a/preview.el b/preview.el
index fc0b7566..6ab43ed7 100644
--- a/preview.el
+++ b/preview.el
@@ -1900,10 +1900,10 @@ definition of OV, AFTER-CHANGE, BEG, END and LENGTH."
(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.
-FORMAT-CONS contains the format info for the main
-format dump handler."
+FILE can be an associated buffer instead of a filename. COMMAND is the
+command that generated the format. FORMAT-CONS contains the format info
+for the main format dump handler. If OUT-FILE is non-nil it is used
+instead of FILE to determine the dump-files."
(let ((buffer (if (bufferp file)
file
(find-buffer-visiting file)))
diff --git a/tests/latex/preview-latex-test.el b/tests/latex/preview-latex-test.el
index 8c7d8314..0fd00cd3 100644
--- a/tests/latex/preview-latex-test.el
+++ b/tests/latex/preview-latex-test.el
@@ -24,6 +24,10 @@
(require 'ert)
(require 'preview)
+(AUCTeX-set-ert-path
+ 'preview-test-file
+ "../../circ.tex")
+
(ert-deftest preview-error-quote-utf-8 ()
"`preview-error-quote' is robust against partial ^^-quoting or not.
If a utf-8 byte sequence is partially ^^-quoted in latex output, we have
@@ -42,6 +46,71 @@ emacs' coding system later."
(dolist (str '("prim\xC3\xA1rias" "prim^^c3\xA1rias" "prim^^c3^^a1rias"))
(should (string= (preview--decode-^^ab str 'utf-8) "primárias"
+(ert-deftest preview-cache-preamble ()
+ "Test caching of preamble with non-nil `TeX-output-dir'."
+ (skip-unless (not noninteractive))
+ (let ((TeX-clean-confirm nil)
+(preview-auto-cache-preamble nil)
+(process-environment (copy-sequence process-environment))
+(TeX-output-dir "auctex-output")
+buffer1 buffer2)
+(unwind-protect
+(save-window-excursion
+ (setq buffer1 (find-file preview-test-file))
+ (delete-other-windows)
+ (preview-cache-preamble)
+ (setq buffer2 (TeX-active-buffer))
+ (message "Please wait for asynchronous process to finish...")
+ (with-current-buffer buffer1
+(while (get-buffer-process (TeX-process-buffer-name
+(TeX-master-file)))
+ (sleep-for 1)))
+ ;; Actually, this type of trouble seems to be captured early by
+ ;; ert mechanism as error and not to reach here.
+ (should-not (string-match "error in process sentinel:"
+(current-message)))
+ (message "Please wait for asynchronous process to finish...done")
+
+ (with-current-buffer buffer1
+;; ini file should be deleted
+(should-not
+ (or
+ (file-exists-p
+ (expand-file-name
+(TeX-master-output-file "ini")))
+ (file-exists-p
+ (expand-file-name
+(TeX-master-file "ini")
+;; fmt file should be in output-directory
+(should
+ (file-exists-p
+ (expand-file-name
+ (preview-dump-file-name
+(TeX-master-output-file "fmt")
bug#79473: 14.1.0; [PATCH] Save ini preview files inside TeX-output-dir
Hi all, Ikumi Keita writes: > OK, it seems good to me. It also passes the regression test, so I > think we can install it. Thanks for providing and reviewing the patch. I installed it now (d151b5c9). > And I'd like to ask Al to add a new test for this fix. I think we have 3 points to address and then we can close this report: - Add a new test - Announce the changes in NEWS.org - Touch the docstring of `preview-watch-preamble' and describe the optional out-file. Best, Arash ___ bug-auctex mailing list [email protected] https://lists.gnu.org/mailman/listinfo/bug-auctex
bug#79473: 14.1.0; [PATCH] Save ini preview files inside TeX-output-dir
Hi Al and Arash, > Al Haji-Ali writes: > I am not sure if you still want the change so that at least the > function `preview-watch-preamble` is backward compatible. I am > attaching that version here in any case. Otherwise, this patch still > saves the output-file as the cadr of elements of > `preview-dumped-alist`. OK, it seems good to me. It also passes the regression test, so I think we can install it. And I'd like to ask Al to add a new test for this fix. Regards, Ikumi Keita #StandWithUkraine #StopWarInUkraine #Gaza #StopGenocide #CeasefireNOW ___ bug-auctex mailing list [email protected] https://lists.gnu.org/mailman/listinfo/bug-auctex
bug#79473: 14.1.0; [PATCH] Save ini preview files inside TeX-output-dir
Hello Arash & Ikumi, On 25/09/2025, Arash Esbati wrote: >> Hmm. If I understand correctly, it is no longer possible to keep the >> compatibility of the structure of (each element of) >> `preview-dumped-alist' anyway, right? Yes exactly. Any user code that accessed these elements using CD*R functions would break no matter where the output-file is placed. > Thanks for looking at this. So, we have to bite the bullet. Should I > install the patch provided upthread? We can then add something about it > to NEWS.org. I am not sure if you still want the change so that at least the function `preview-watch-preamble` is backward compatible. I am attaching that version here in any case. Otherwise, this patch still saves the output-file as the cadr of elements of `preview-dumped-alist`. Best regards, -- Al >From 66aeac66585adff29e5060e0eb8f8a60a20f2962 Mon Sep 17 00:00:00 2001 From: Al Haji-Ali Date: Wed, 3 Sep 2025 21:56:08 +0100 Subject: [PATCH] preview: 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 | 77 +- 1 file changed, 42 insertions(+), 35 deletions(-) diff --git a/preview.el b/preview.el index bb0f8ee9..cbad6b97 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) @@ -2498,10 +2501,10 @@ The elements are (NAME . ASSOC). NAME is the master file name 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 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 +wa
bug#79473: 14.1.0; [PATCH] Save ini preview files inside TeX-output-dir
Hello Ikumi, On 24/09/2025, Ikumi Keita wrote: > I'm reluctant to the idea to change the structure (order) of the > format-cons. If some third party package assumes the current structure, > it would break with this change. > On the other hand, I don't mind adding a new element to the tail of the > list. So I'd like to ask Al to have output master file as the last > element of the list. I am happy to do this. Just wanted to mention that the previous documentation of `preview-dumped-alist` was explicit in stating which elements meant what. --8<---cut here---start->8--- 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. --8<---cut here---end--->8--- so even adding a new element to the tail would mean that CDDDR is no longer the Emacs-flavor specific value mentioned above (it would be a cons of such a value with the output file). -- Al ___ bug-auctex mailing list [email protected] https://lists.gnu.org/mailman/listinfo/bug-auctex
bug#79473: 14.1.0; [PATCH] Save ini preview files inside TeX-output-dir
Hi Arash and Al, > Arash Esbati writes: > Before looking further, is it possible to change the signature in a > backward compatible way? The usual practice is append new args to the > arg-list as optional ones, i.e.: > (defun preview-watch-preamble (file command format-cons > &optional out-file) > I don't think this function is widely used elsewhere, but still. > @Keita: WDYT? > Al Haji-Ali writes: > Yes of course. I thought it would be better to have it mirror the > structure of `format-cons`, documented in `preview-dumped-alist` where > these are taken from. > --8<---cut here---start->8--- > 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. > --8<---cut here---end--->8--- > I added the output file as the CAR rather than tack it on at the end > since that seemed more logical to me. But let me know if this should > be modified in a backward compatible way as well. I'm reluctant to the idea to change the structure (order) of the format-cons. If some third party package assumes the current structure, it would break with this change. On the other hand, I don't mind adding a new element to the tail of the list. So I'd like to ask Al to have output master file as the last element of the list. Regards, Ikumi Keita #StandWithUkraine #StopWarInUkraine #Gaza #StopGenocide #CeasefireNOW ___ bug-auctex mailing list [email protected] https://lists.gnu.org/mailman/listinfo/bug-auctex
bug#79473: 14.1.0; [PATCH] Save ini preview files inside TeX-output-dir
Hi Arash, On 23/09/2025, Arash Esbati wrote: > Before looking further, is it possible to change the signature in a > backward compatible way? Yes of course. I thought it would be better to have it mirror the structure of `format-cons`, documented in `preview-dumped-alist` where these are taken from. --8<---cut here---start->8--- 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. --8<---cut here---end--->8--- I added the output file as the CAR rather than tack it on at the end since that seemed more logical to me. But let me know if this should be modified in a backward compatible way as well. -- Al ___ bug-auctex mailing list [email protected] https://lists.gnu.org/mailman/listinfo/bug-auctex
bug#79473: 14.1.0; [PATCH] Save ini preview files inside TeX-output-dir
[Re-sending to correct mailing-list] Hello, This is another follow-up bug-report/patch from: https://lists.gnu.org/archive/html/auctex-devel/2025-08/msg00026.html When caching the preamble while previewing files, an ini file is created.. The attached places this ini file inside TeX-output-dir when that is non-nil. A change to the format of the variable `preview-dumped-alist` was required to save the name of the output file. Best regards, -- Al >From 61d952df797957dc66e2f065a24bd691a832b855 Mon Sep 17 00:00:00 2001 From: Al Haji-Ali Date: Wed, 3 Sep 2025 21:56:08 +0100 Subject: [PATCH] Save ini preview 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 | 71 ++ 1 file changed, 39 insertions(+), 32 deletions(-) diff --git a/preview.el b/preview.el index bb0f8ee9..e86b0035 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 out-file command format-cons) "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* + out-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) @@ -2498,10 +2501,10 @@ The elements are (NAME . ASSOC). NAME is the master file name 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 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. @@ -3157,6 +3160,7 @@ pp") (preview-unwatch-preamble format-cons) (preview-watch-preamble (current-buffer) (cadr format-cons) +(caddr format-cons)
