GNU bug report logs - #79462
14.1.0; Set correct TeX-sentinel-function before starting processes.

Previous Next

Package: auctex;

Reported by: Al Haji-Ali <abdo.haji.ali <at> gmail.com>

Date: Wed, 17 Sep 2025 07:40:02 UTC

Severity: normal

Found in version 14.1.0

Done: Arash Esbati <arash <at> gnu.org>

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Al Haji-Ali <abdo.haji.ali <at> gmail.com>
Subject: bug#79462: closed (Re: bug#79462: 14.1.0; Set correct
 TeX-sentinel-function before starting processes.)
Date: Thu, 18 Sep 2025 07:35:02 +0000
[Message part 1 (text/plain, inline)]
Your bug report

#79462: 14.1.0; Set correct TeX-sentinel-function before starting processes.

which was filed against the auctex package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to 79462 <at> debbugs.gnu.org.

-- 
79462: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=79462
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Arash Esbati <arash <at> gnu.org>
To: Ikumi Keita <ikumi <at> ikumi.que.jp>
Cc: 79462-done <at> debbugs.gnu.org, Al Haji-Ali <abdo.haji.ali <at> gmail.com>
Subject: Re: bug#79462: 14.1.0; Set correct TeX-sentinel-function before
 starting processes.
Date: Thu, 18 Sep 2025 09:34:13 +0200
Hi all,

Ikumi Keita <ikumi <at> ikumi.que.jp> writes:

> Provided that Al's analysis is correct, it seems to me that we
> can/should also change `(sit-for 0)' to `(redisplay)' or
> `(force-mode-line-update)' in `preview-start-*' functions. However, his
> proposal seems to be towards the right direction, so I'm in favor of
> acceptiong it. :-)

Thanks for the patch and the comment.  I installed that change with
commit f338ca4e and therefore closing this report.

@Al: Can you please do me a favor and don't use markdown style ticks in
commit messages?

  * preview.el (preview-gs-dvips-process-setup,
  preview-dvipng-process-setup, preview-pdf2dsc-process-setup,
  preview-dvipng-place-all): Set `TeX-sentinel-function` before calling
                                 ^---------------------^

Emacs convention is `x' or 'x', TIA.

Best, Arash

[Message part 3 (message/rfc822, inline)]
From: Al Haji-Ali <abdo.haji.ali <at> gmail.com>
To: bug-auctex <at> gnu.org
Cc: Ikumi Keita <ikumi <at> ikumi.que.jp>, Arash Esbati <arash <at> gnu.org>
Subject: 14.1.0; Set correct TeX-sentinel-function before starting processes.
Date: Wed, 17 Sep 2025 09:31:52 +0200
[Message part 4 (text/plain, inline)]
Hello,

This is a follow-up bug-report/patch from:
https://lists.gnu.org/archive/html/auctex-devel/2025-08/msg00026.html

Previously, preview was setting the TeX-sentinel-function to temporary lambda functions inside `preview-start-*` functions which just outputs a message. This value is overwritten by functions that call `preview-start-*` to a correct sentinel. In most cases, this is harmless as the original sentinel is never called. However, preview-start-* also has a `sit-for` call which causes timers to be processed, and which may call `accept-process-output` causing the "wrong" temporary sentinel to be called.
I faced this issue when developing preview-point (discussed above) and I am submitting this patch which simply sets the correct sentinel before calling preview-start-*.

-- Al

[preview-TeX-sentinel-function.patch (text/x-patch, inline)]
From 6166cbec1b40ef26eb79dca9bb9b37c8318ce1d2 Mon Sep 17 00:00:00 2001
From: Al Haji-Ali <a.hajiali <at> hw.ac.uk>
Date: Wed, 3 Sep 2025 11:10:11 +0100
Subject: [PATCH] preview: Set correct TeX-sentinel-function before starting
 processes.

* preview.el (preview-gs-dvips-process-setup,
preview-dvipng-process-setup, preview-pdf2dsc-process-setup,
preview-dvipng-place-all): Set `TeX-sentinel-function` before calling
preview-start-* functions to start processes.
(preview-start-dvipng, preview-start-dvips, preview-start-pdf2dsc):
Remove temporary setting of `TeX-sentinel-function`.
---
 preview.el | 27 +++++++++------------------
 1 file changed, 9 insertions(+), 18 deletions(-)

diff --git a/preview.el b/preview.el
index 88886b83..22316335 100644
--- a/preview.el
+++ b/preview.el
@@ -133,8 +133,7 @@ considerable time under XEmacs, it should come after the `:min'
 spec to avoid unnecessary evaluation time."
   :group 'preview-appearance
   :type preview-specs-type
-  :set #'preview-specs-setter
-)
+  :set #'preview-specs-setter)
 
 (defvar preview-error-icon nil
   "The icon used for PostScript errors.
@@ -892,10 +891,10 @@ Pure borderless black-on-white will return an empty string."
                                         (cdr preview-resolution)))))
   (if preview-parsed-pdfoutput
       (preview-pdf2dsc-process-setup)
-    (let ((process (preview-start-dvips preview-fast-conversion)))
       (setq TeX-sentinel-function #'preview-gs-dvips-sentinel)
-      (list process (current-buffer) TeX-active-tempdir preview-ps-file
-            preview-gs-image-type))))
+    (list (preview-start-dvips preview-fast-conversion) (current-buffer)
+          TeX-active-tempdir preview-ps-file
+          preview-gs-image-type)))
 
 (defun preview-dvipng-process-setup ()
   "Set up dvipng process for conversion."
@@ -913,17 +912,15 @@ Pure borderless black-on-white will return an empty string."
     (unless (preview-supports-image-type preview-dvipng-image-type)
       (error "preview-dvipng-image-type setting '%s unsupported by this Emacs"
              preview-dvipng-image-type))
-    (let ((process (preview-start-dvipng)))
       (setq TeX-sentinel-function #'preview-dvipng-sentinel)
-      (list process (current-buffer) TeX-active-tempdir t
-          preview-dvipng-image-type))))
+    (list (preview-start-dvipng) (current-buffer) TeX-active-tempdir t
+          preview-dvipng-image-type)))
 
 
 (defun preview-pdf2dsc-process-setup ()
-  (let ((process (preview-start-pdf2dsc)))
     (setq TeX-sentinel-function #'preview-pdf2dsc-sentinel)
-    (list process (current-buffer) TeX-active-tempdir preview-ps-file
-          preview-gs-image-type)))
+  (list (preview-start-pdf2dsc) (current-buffer) TeX-active-tempdir
+        preview-ps-file preview-gs-image-type))
 
 (defun preview-dvips-abort ()
   "Abort a Dvips run."
@@ -2528,12 +2525,12 @@ Deletes the dvi file when finished."
           (push ov preview-gs-queue))))
     (if (setq preview-gs-queue (nreverse preview-gs-queue))
         (progn
-          (preview-start-dvips preview-fast-conversion)
           (setq TeX-sentinel-function (lambda (process command)
                                         (preview-gs-dvips-sentinel
                                          process
                                          command
                                          t)))
+          (preview-start-dvips preview-fast-conversion)
           (dolist (ov preview-gs-queue)
             (setq snippet (aref (overlay-get ov 'queued) 2))
             (overlay-put ov 'filenames
@@ -3809,8 +3806,6 @@ The fourth value is the transparent border thickness."
     (goto-char (point-max))
     (insert-before-markers "Running `" name "' with ``" command "''\n")
     (setq mode-name name)
-    (setq TeX-sentinel-function
-          (lambda (_process name) (message "%s: done." name)))
     (if TeX-process-asynchronous
         (let ((process (start-process name (current-buffer) TeX-shell
                                       TeX-shell-command-option
@@ -3851,8 +3846,6 @@ If FAST is set, do a fast conversion."
     (goto-char (point-max))
     (insert-before-markers "Running `" name "' with ``" command "''\n")
     (setq mode-name name)
-    (setq TeX-sentinel-function
-          (lambda (_process name) (message "%s: done." name)))
     (if TeX-process-asynchronous
         (let ((process (start-process name (current-buffer) TeX-shell
                                       TeX-shell-command-option
@@ -3893,8 +3886,6 @@ If FAST is set, do a fast conversion."
     (goto-char (point-max))
     (insert-before-markers "Running `" name "' with ``" command "''\n")
     (setq mode-name name)
-    (setq TeX-sentinel-function
-          (lambda (_process name) (message "%s: done." name)))
     (if TeX-process-asynchronous
         (let ((process (start-process name (current-buffer) TeX-shell
                                       TeX-shell-command-option
-- 
2.39.3 (Apple Git-146)


This bug report was last modified 1 day ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.