Repository navigation
[6224] Fix headless -c file conversion - #4745
Merged
Merged
Conversation
MoganSTEM -headless -c <in> <out> had two problems: - In headless mode there is no active view, so (load-buffer ...) followed by (export-buffer ...) depends on current-buffer and can fail or export the wrong buffer. Load and export the buffers addressed by the input and output URLs explicitly, initialising the plugins of both formats. The pdf case keeps its dedicated branch (screens are expanded into slides). - The format of the output file was looked up with url-format before any plugin was loaded. The latex format is only registered once its plugin is initialised, and the output file normally does not exist yet, so the answer was "generic" and the export wrote the plain text only (no preamble, no equations). Force the lazy plugins first and take the target format from the file suffix. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
- lazy-plugin-force 之后的两个 plugin-initialize 是 no-op,删除; source-format 绑定随之不再需要 - headless 下 scheme 输出被重定向进日志,错误信息改写 current-error-port 才能到达终端 stderr - 注释改为中文精简版,说明 lazy-plugin-force 必须先于格式解析
PinkMagicFly
force-pushed
the
pr/headless-convert
branch
from
October 19, 2026 10:03
e7701fe to
ff92a9a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2223
What happened
I wanted to convert documents from the command line, without opening a window, with
MoganSTEM -headless -c <in> <out>. Converting a TeXmacs document to LaTeX or to anotherTeXmacs format wrote no output file at all, and nothing about the conversion was printed (only the
normal startup and shutdown lines).
Problem
For every conversion except
.tex -> .tmu(which has its own branch) and PDF, the codein
TeXmacs_maingenerates(load-buffer "<in>" :strict) (export-buffer "<out>").On a clean build of
main(c68a494fc, Windows), with an empty user directory and cache:MoganSTEM -headless -c doc.tm doc.texwrites no file;MoganSTEM -headless -c doc.tm doc.tmuwrites no file;MoganSTEM -headless -c blocks.tex blocks.tmuworks (the special branch).I did not trace why the generated sequence produces nothing; headless mode has no active
view, and
export-bufferexports the current buffer.Change (
src/System/Boot/init_texmacs.cpp, default branch only)The generated Scheme now:
(lazy-plugin-force)first (about 1 s);(url-format source)(the input file exists) and thetarget format from the file suffix,
(format-from-suffix (url-suffix target)). Theoutput file normally does not exist yet, so
url-formatcannot be asked about it, andformats such as
latexare only registered once their plugin has been initialised;(
buffer-load source) and exports that buffer (buffer-export source target target-format), printing a message if either step fails.The
.tex -> .tmubranch is unchanged. The PDF branch (screens expanded into slides) isunchanged except that it now carries its own
load-buffer.Verified
A local script runs conversions and checks the output text (31 checks, all pass on this
branch):
.tex -> .tmu:gathered/aligned/array/pmatrixrows and options (the unchangedbranch, as a regression guard);
.tm -> .tex: a full document with\documentclass,\usepackage{amsmath},\begin{equation},\begin{gather*}, aligned and plain text;.tm -> .tmu,.tmu -> .tex, and a.tex -> .tmu -> .texround trip.On the clean
mainbuild,.tm -> .texand.tm -> .tmuwrite nothing (above).Not checked
check or change the process exit status.
.tex -> .tmubranch were not changed and were not re-testedbeyond the regression guard above.
it to
tests/(C++) or a Scheme integration test if you tell me which you prefer.How this fix was made
The fix was developed through human-aided debugging: I reported the symptoms, ran the
builds and checked the results by hand, and the cause was worked out interactively with
an AI assistant. The code itself was written using Claude Sonnet 5.5 (Anthropic). I
reviewed and tested it before submitting. The commit carries a
Co-Authored-Bytrailerto the same effect.