GNU bug report logs - #48144
13.0.11; TeX-run-format signals error in sentinel

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: auctex; Reported by: "Basil L. Contovounesios" <contovob@HIDDEN>; dated Sat, 1 May 2021 16:16:02 UTC; Maintainer for auctex is bug-auctex@HIDDEN.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 1 May 2021 16:15:45 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat May 01 12:15:45 2021
Received: from localhost ([127.0.0.1]:37094 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lcsHQ-0007Aw-Lv
	for submit <at> debbugs.gnu.org; Sat, 01 May 2021 12:15:45 -0400
Received: from lists.gnu.org ([209.51.188.17]:57386)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <contovob@HIDDEN>) id 1lcsHP-0007Aq-1T
 for submit <at> debbugs.gnu.org; Sat, 01 May 2021 12:15:43 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:34116)
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <contovob@HIDDEN>) id 1lcsHJ-0005tp-Ld
 for bug-auctex@HIDDEN; Sat, 01 May 2021 12:15:42 -0400
Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]:38818)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.90_1) (envelope-from <contovob@HIDDEN>) id 1lcsHF-0005hp-CB
 for bug-auctex@HIDDEN; Sat, 01 May 2021 12:15:36 -0400
Received: by mail-wm1-x32d.google.com with SMTP id
 p6-20020a05600c3586b029014131bbe5c7so3270778wmq.3
 for <bug-auctex@HIDDEN>; Sat, 01 May 2021 09:15:30 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tcd.ie; s=google21;
 h=from:to:subject:date:message-id:user-agent:mime-version;
 bh=jTVydxXiQw+Qb1VSN+iZ2d5mx1Zvm473mfJdmRZIDD8=;
 b=QuHuELtHTR84bb0hGwLEQRW1oFIy2HqwalxotC0j3oSOPTtx/TcRrix0RXybTBOE4u
 gGe0W6YS4Dl1US9yrg5OFSowevj82csrsMEuIvGivkVE3yMXv5/wJnMLY5p8HUBW/lp0
 f7Zlt3FJ/Te+2crHnPpfyRqu0HXCmvr4yZwiNi//0pzFFBTiRu1Eg7TdyCjUHKsVISRQ
 /aEnSZcP7RUjy5HABWLZAFo6JkKG2yunIRi8BGbsQukM09HKvUbl6J6TazBRMsasM1a8
 UOXGAJbutuAe0V4vez/OOgIFKbURnwdlig9PECqx6/jSJBzQNVq/dKcf8AaTvXiWnvHn
 qm7Q==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:from:to:subject:date:message-id:user-agent
 :mime-version;
 bh=jTVydxXiQw+Qb1VSN+iZ2d5mx1Zvm473mfJdmRZIDD8=;
 b=V95dfyDQ+fBJTFCy6aMqkp6tNh+XG8zd/dn9nunaaDB0s+D4IrrQvJ5OqSgWV4r1xN
 DEyQ9Yd0AjqcgZxBkQyuS6A+Vvawt8pZh22tCLlJ3op+nh5DAU0I3MYLtb1uY+4oF6Zj
 wYYtxjEFXljNM2vi7E7yIjV9ulSJnk606aVtWLDzhlek1l2KpK7NSCvVVIncPrMwQAUC
 88IUp42umGB2DlJZKS+0QK0VV2GjFQ6zGr52Z6Dk+759F8Qb1r8h8ibf6xhzaFqgM28q
 bNmC+771Anf5cE3yuGC16vT+bUXSdKJ9wiktm3g4HmUtY/G/WxG/935P0jsoeGgzVdsT
 G5jg==
X-Gm-Message-State: AOAM532+kpQb45ODbh3HB6qODLn8xCVEAYtUpxGcYVPxXnvvgKejqsrs
 UDYoj+cEyVj457ZJsli4Jlvdmrlgc8bYzQ==
X-Google-Smtp-Source: ABdhPJycZe1XCyGcEAvni+ba6TNWLrVX0dfR8wuC+DwyU5QBepSBk6M62Uo/Hb1kU0gcsE2Idr1cWQ==
X-Received: by 2002:a1c:f404:: with SMTP id z4mr23187959wma.39.1619885728829; 
 Sat, 01 May 2021 09:15:28 -0700 (PDT)
Received: from localhost ([93.107.145.216])
 by smtp.gmail.com with ESMTPSA id a9sm6074831wrw.26.2021.05.01.09.15.28
 for <bug-auctex@HIDDEN>
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Sat, 01 May 2021 09:15:28 -0700 (PDT)
From: "Basil L. Contovounesios" <contovob@HIDDEN>
To: bug-auctex@HIDDEN
Subject: 13.0.11; TeX-run-format signals error in sentinel
Date: Sat, 01 May 2021 17:15:26 +0100
Message-ID: <87o8dujuqp.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
Received-SPF: pass client-ip=2a00:1450:4864:20::32d;
 envelope-from=contovob@HIDDEN; helo=mail-wm1-x32d.google.com
X-Spam_score_int: -20
X-Spam_score: -2.1
X-Spam_bar: --
X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
 RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001,
 SPF_PASS=-0.001 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: -1.3 (-)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.3 (--)

I was experimenting with configuring latexmk as best I could in
TeX-command-list when I noticed an inconsistency between TeX-run-format
and its sentinel.  Here's a recipe to illustrate what I mean:

0. emacs -Q
1. M-x package-initialize RET
2. (progn
     (setq debug-on-error t)
     (add-hook 'LaTeX-mode-hook
               (lambda () (setq TeX-command-default "Latexmk")))
     (with-eval-after-load 'tex
       (push '("Latexmk"
               "latexmk%(file-line-error) %(extraopts)%(mode) %t"
               TeX-run-format nil (latex-mode))
             TeX-command-list)))
3. C-x C-e
4. C-x C-f /tmp/helloworld.tex RET
5. M-x auto-insert RET RET article RET RET RET
6. \helloworld
7. C-c C-c y RET

  Debugger entered--Lisp error: (wrong-type-argument stringp nil)
    intern(nil)
    TeX-TeX-sentinel-check(#<process Latexmk> "Latexmk")
    TeX-TeX-sentinel(#<process Latexmk> "Latexmk")
    TeX-command-sentinel(#<process Latexmk> "exited abnormally with code 12\n")

AFAICT, this is because TeX-run-format uses TeX-TeX-sentinel, which
calls TeX-TeX-sentinel-check, which expects TeX-error-report-switches to
have been initialised by TeX-run-TeX, but we're not using TeX-run-TeX!

I'm not sure whether the TeX-error-report-switches initialisation should
be moved to TeX-run-format, or TeX-TeX-sentinel-check should guard
against an uninitialised TeX-error-report-switches.

Are my assumptions about or use of TeX-run-format wrong?  E.g., should I
just be using TeX-run-command for this purpose instead?

---

Some off-topic justification for how I ended up here:

I tried using a sentinel that is as close to TeX-run-TeX as possible,
whilst avoiding the false positive output parsing about cross-references
and the like in TeX-LaTeX-sentinel, which latexmk already handles.
TeX-run-format seems to fit a nice middle-ground between TeX-run-TeX and
TeX-run-command.

I also tried TeX-command-run-all instead of latexmk, but AFAICT the
former doesn't handle as many scenarios as the latter, such as running
Biber as needed.

Since neither TeX-run-format nor TeX-run-command runs
TeX-after-compilation-finished-functions, I've ended up with the
following custom sentinel for latexmk:

  (defun blc-latexmk-sentinel (proc _msg)
    "Run `TeX-after-compilation-finished-functions' on PROC success."
    (when (and (eq (process-status proc) 'exit)
               (zerop (process-exit-status proc)))
      (defvar TeX-command-buffer)
      (run-hook-with-args 'TeX-after-compilation-finished-functions
                          (with-current-buffer TeX-command-buffer
                            (expand-file-name
                             (TeX-active-master (TeX-output-extension)))))))

  (defun blc-TeX-run-latexmk (&rest args)
    "Like `TeX-run-format', but also run TeX compilation hooks."
    (let ((proc (apply #'TeX-run-format args)))
      (add-function :after (process-sentinel proc) #'blc-latexmk-sentinel)
      proc))

Please let me know if any of this runs afoul of AUCTeX's design, or if
there's a better way to integrate latexmk or call a hook on successful
compilation.  [I read through all of the relevant AUCTeX mailing list
discussions I could find, and I'm undecided about the auctex-latexmk
package on MELPA, which uses old-style function advice.]

Thanks,

-- 
Basil

Emacs  : GNU Emacs 28.0.50 (build 1, x86_64-pc-linux-gnu, X toolkit, cairo version 1.16.0, Xaw3d scroll bars)
 of 2021-05-01
Package: 13.0.11

current state:
==============
(setq
 AUCTeX-date "2021-04-28"
 window-system 'x
 LaTeX-version "2e"
 TeX-style-path '("~/.emacs.d/auctex"
		  "/home/blc/.emacs.d/elpa/auctex-13.0.11.0.20210428.195438/style"
		  "/home/blc/.emacs.d/auctex/auto" "/home/blc/.emacs.d/auctex/style" "auto" "style")
 TeX-auto-save nil
 TeX-parse-self nil
 TeX-master t
 TeX-command-list '(("Latexmk" "latexmk%(file-line-error) %(extraopts)%(mode) %t" TeX-run-format nil
		     (latex-mode))
		    ("TeX"
		     "%(PDF)%(tex) %(file-line-error) %`%(extraopts) %S%(PDFout)%(mode)%' %(output-dir) %t"
		     TeX-run-TeX nil (plain-tex-mode ams-tex-mode texinfo-mode) :help "Run plain TeX")
		    ("LaTeX" "%`%l%(mode)%' %T" TeX-run-TeX nil (latex-mode doctex-mode) :help
		     "Run LaTeX")
		    ("Makeinfo" "makeinfo %(extraopts) %(o-dir) %t" TeX-run-compile nil
		     (texinfo-mode) :help "Run Makeinfo with Info output")
		    ("Makeinfo HTML" "makeinfo %(extraopts) %(o-dir) --html %t" TeX-run-compile nil
		     (texinfo-mode) :help "Run Makeinfo with HTML output")
		    ("AmSTeX" "amstex %(PDFout) %`%(extraopts) %S%(mode)%' %(output-dir) %t"
		     TeX-run-TeX nil (ams-tex-mode) :help "Run AMSTeX")
		    ("ConTeXt" "%(cntxcom) --once --texutil %(extraopts) %(execopts)%t" TeX-run-TeX
		     nil (context-mode) :help "Run ConTeXt once")
		    ("ConTeXt Full" "%(cntxcom) %(extraopts) %(execopts)%t" TeX-run-TeX nil
		     (context-mode) :help "Run ConTeXt until completion")
		    ("BibTeX" "bibtex %(O?aux)" TeX-run-BibTeX nil
		     (plain-tex-mode latex-mode doctex-mode ams-tex-mode texinfo-mode context-mode)
		     :help "Run BibTeX")
		    ("Biber" "biber %s %(output-dir)" TeX-run-Biber nil
		     (plain-tex-mode latex-mode doctex-mode ams-tex-mode texinfo-mode) :help
		     "Run Biber")
		    ("View" "%V" TeX-run-discard-or-function t t :help "Run Viewer")
		    ("Print" "%p" TeX-run-command t t :help "Print the file")
		    ("Queue" "%q" TeX-run-background nil t :help "View the printer queue" :visible
		     TeX-queue-command)
		    ("File" "%(o?)dvips %d -o %f " TeX-run-dvips t
		     (plain-tex-mode latex-mode doctex-mode ams-tex-mode texinfo-mode) :help
		     "Generate PostScript file")
		    ("Dvips" "%(o?)dvips %d -o %f " TeX-run-dvips nil
		     (plain-tex-mode latex-mode doctex-mode ams-tex-mode texinfo-mode) :help
		     "Convert DVI file to PostScript")
		    ("Dvipdfmx" "dvipdfmx %d -o %(O?pdf)" TeX-run-dvipdfmx nil
		     (plain-tex-mode latex-mode doctex-mode ams-tex-mode texinfo-mode) :help
		     "Convert DVI file to PDF with dvipdfmx")
		    ("Ps2pdf" "ps2pdf %f %(O?pdf)" TeX-run-ps2pdf nil
		     (plain-tex-mode latex-mode doctex-mode ams-tex-mode texinfo-mode) :help
		     "Convert PostScript file to PDF")
		    ("Glossaries" "makeglossaries %(O?aux)" TeX-run-command nil
		     (plain-tex-mode latex-mode doctex-mode ams-tex-mode texinfo-mode) :help
		     "Run makeglossaries to create glossary\n     file")
		    ("Index" "makeindex %(O?idx)" TeX-run-index nil
		     (plain-tex-mode latex-mode doctex-mode ams-tex-mode texinfo-mode) :help
		     "Run makeindex to create index file")
		    ("upMendex" "upmendex %(O?idx)" TeX-run-index t
		     (plain-tex-mode latex-mode doctex-mode ams-tex-mode texinfo-mode) :help
		     "Run upmendex to create index file")
		    ("Xindy" "texindy %s" TeX-run-command nil
		     (plain-tex-mode latex-mode doctex-mode ams-tex-mode texinfo-mode) :help
		     "Run xindy to create index file")
		    ("Check" "lacheck %s" TeX-run-compile nil (latex-mode) :help
		     "Check LaTeX file for correctness")
		    ("ChkTeX" "chktex -v6 %s" TeX-run-compile nil (latex-mode) :help
		     "Check LaTeX file for common mistakes")
		    ("Spell" "(TeX-ispell-document \"\")" TeX-run-function nil t :help
		     "Spell-check the document")
		    ("Clean" "TeX-clean" TeX-run-function nil t :help
		     "Delete generated intermediate files")
		    ("Clean All" "(TeX-clean t)" TeX-run-function nil t :help
		     "Delete generated intermediate and output files")
		    ("Other" "" TeX-run-command t t :help "Run an arbitrary command"))
 )




Acknowledgement sent to "Basil L. Contovounesios" <contovob@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-auctex@HIDDEN. Full text available.
Report forwarded to bug-auctex@HIDDEN:
bug#48144; Package auctex. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Sat, 1 May 2021 16:30:02 UTC

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