Repository navigation
Conversation
mogan -c in.tm out.tex 得到的 .tex 只有纯文本、没有 LaTeX 标记,GUI 菜单导出正常。 根因:latex / bibtex 等格式由插件 init 脚本里的 lazy-format 登记,而插件本身走 (delayed (:idle 10) (plugin-initialize ...))。-c 的转换命令由 tm_server 用 exec_delayed 在启动后立即执行,先于插件初始化;此时后缀表里没有 tex, url-format 返回 "generic",export-buffer 再退化为 verbatim。GUI 不受影响, 因为开窗建菜单时已 (lazy-initialize-force) 强载插件;-c 现在隐含 -headless, 不开窗,这条路径不会触发。 修复:export-buffer 的格式判定抽成 export-buffer-format——后缀未知时先 (lazy-plugin-force) 再查一次,仍未知才退化为 verbatim。lazy-plugin-force 幂等, 已初始化时直接返回。 测试:tm-files-test.scm 新增 headless 用例——测试进程与 -c 同样在插件初始化 前执行,export-buffer-format 对 .tex 须返回 "latex",对真正未知的后缀返回 "verbatim"。 Fixes MoganLab#2223 Co-Authored-By: Claude Fable 5.1 <[email protected]>
This branch has not been deployed
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。
mogan -c HW.tm HW.tex得到的.tex只有纯文本、没有任何 LaTeX 标记;GUI 的 文件→导出 正常。1.2.9 正常,1.2.9.7 起复现,至今未修。根因
不是格式检测代码的问题,是执行时序:
.tex的格式映射由 latex 插件登记:plugins/latex/progs/init-latex.scm里(lazy-format (latex latex-format) latex)。lazy-plugin-initialize用(delayed (:idle 10) (plugin-initialize name))。-c的转换命令由tm_server在启动末尾exec_delayed,先于上面的 idle 延迟触发。export-buffer调url-format→ C++file_format→suffix_to_format→ Schemeformat-from-suffix,后缀表里没有tex,返回"generic",export-buffer把"generic"改成"verbatim",纯文本落盘。GUI 不受影响,因为开窗建菜单时
tm_window_rep::menu_main已(lazy-initialize-force)强载全部插件。-c现在隐含-headless(research.cpp),不开窗,这条强载路径永远不会走到。init_texmacs.cpp里#ifndef QTTEXMACS分支对 ImGui 后端手动(plugin-initialize 'latex)的注释说的正是同一件事,只是 Qt headless 没有对应处理。format-from-suffix自己调的lazy-format-force不够:它只强载已经lazy-format登记过的模块,而登记动作本身在还没跑的插件 init 里。改动
TeXmacs/progs/texmacs/texmacs/tm-files.scmexport-buffer的格式判定抽成export-buffer-format:(tm-define (export-buffer-format to) (with fm (url-format to) (when (== fm "generic") (lazy-plugin-force) (set! fm (url-format to))) (if (== fm "generic") "verbatim" fm)))后缀未知时先
(lazy-plugin-force)再查一次,仍未知才退化为 verbatim。lazy-plugin-force幂等(plugin-initialize-done?置位后直接返回),已识别的后缀不触发任何额外加载,GUI 路径行为不变。没有放进 kernel 的
format-from-suffix:那会让任何未知后缀的文件操作都强载全部插件,副作用面太大;导出是唯一需要这个保证的地方。TeXmacs/progs/texmacs/texmacs/tm-files-test.scm新增
test-export-buffer-format-forces-plugins(xmake r tm-files-test,headless)。测试进程与-c同样在插件初始化前执行到断言,所以它真实复现了时序:修复前.tex返回"verbatim",修复后返回"latex";真正未知的后缀仍为"verbatim"。说明
xmake r tm-files-test与gf fmt,烦请以 CI 为准。改动全部在 Scheme 层。-c in.tex out.tmu方向在init_texmacs.cpp里已有专门路径(直接调cpp-latex-document->texmacs),不经过export-buffer,不受本 PR 影响。🤖 Generated with Claude Code