Skip to content

Commit 8cbcff8

Browse files
authored
[201_94] 修复宏编辑器crash问题 (#2967)
1 parent e564d4d commit 8cbcff8

File tree

3 files changed

+160
-4
lines changed

3 files changed

+160
-4
lines changed

TeXmacs/progs/source/macro-widgets.scm

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@
236236
(if (symbol? l) (set! l (symbol->string l)))
237237
(initialize-macro-editor l mode)
238238
(let* ((b (current-buffer-url))
239-
(u (string->url (string-append "tmfs://aux/edit-" l "/"
239+
(u (string->url (string-append "tmfs://aux/edit-" l "-"
240240
(url->string (url-tail (current-window))))))
241241
(styps (embedded-style-list "macro-editor"))
242242
(macro-mode (if (in-math?) "Mathematics" "Text"))
@@ -304,7 +304,8 @@
304304
(if (symbol? l) (set! l (symbol->string l)))
305305
(set! macro-current-mode "Source")
306306
(let* ((b (current-buffer-url))
307-
(u (string->url (string-append "tmfs://aux/edit-" l)))
307+
(u (string->url (string-append "tmfs://aux/edit-" l "-"
308+
(url->string (url-tail (current-window))))))
308309
(styps (embedded-style-list "macro-editor"))
309310
(body (add-context (tree-up (cursor-tree)) `(arg "body")))
310311
(def `(assign ,l (inactive* (macro "body" ,body))))
@@ -358,7 +359,8 @@
358359
(if (symbol? l) (set! l (symbol->string l)))
359360
(set! macro-current-mode "Source")
360361
(let* ((b (current-buffer-url))
361-
(u (string->url (string-append "tmfs://aux/edit-" l)))
362+
(u (string->url (string-append "tmfs://aux/edit-" l "-"
363+
(url->string (url-tail (current-window))))))
362364
(styps (embedded-style-list "macro-editor"))
363365
(fm (table-get-format-all))
364366
(tf `(tformat ,@(tree-children fm) (arg "body")))
@@ -528,4 +530,4 @@
528530
"Macros editor" u))))
529531

530532
(register-auxiliary-widget-type 'macro-editor
531-
(list (lambda () (open-macro-editor "" :global))))
533+
(list (lambda () (open-macro-editor "" :global))))

TeXmacs/tests/tmu/201_94.tmu

Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
<TMU|<tuple|1.1.0|2026.2.0>>
2+
3+
<style|<tuple|generic|chinese|table-captions-above|number-europe|preview-ref>>
4+
5+
<\body>
6+
<\hide-preamble>
7+
编号编辑区
8+
9+
<assign|homework-number|01>
10+
11+
<assign|course-number|09>
12+
13+
\;
14+
15+
\;
16+
17+
\;
18+
19+
20+
21+
<assign|header-homework|大学物理第 <value|homework-number> 次作业>
22+
23+
<assign|header-course|课序:<value|course-number>>
24+
25+
\;
26+
27+
<assign|homework-title|<\macro>
28+
<\doc-title>
29+
大学物理第 <value|homework-number> 次作业
30+
</doc-title>
31+
</macro>>
32+
33+
<assign|data|<\macro|name|student-ID|Class>
34+
<\wide-tabular>
35+
<tformat|<cwith|1|-1|1|1|cell-halign|r>|<cwith|1|-1|1|-1|cell-lsep|0>|<cwith|1|-1|1|-1|cell-rsep|0>|<table|<row|<\cell>
36+
课序:
37+
</cell>|<\cell>
38+
<value|course-number>
39+
</cell>>|<row|<\cell>
40+
姓名:
41+
</cell>|<\cell>
42+
<arg|name>
43+
</cell>>|<row|<\cell>
44+
学号:
45+
</cell>|<\cell>
46+
<arg|student-ID>
47+
</cell>>|<row|<\cell>
48+
班级:
49+
</cell>|<\cell>
50+
<arg|Class>
51+
</cell>>>>
52+
</wide-tabular>
53+
</macro>>
54+
55+
\;
56+
57+
<assign|homework-using-books|<macro|book|<surround|<vspace*|0.5fn>|<vspace|0.5fn>|<title-block|<with|font-series|bold|<with|font|Noto CJK SC|font-base-size|16|作业内容:<arg|book>>>>>>>
58+
59+
<assign|title-block|<\macro|body>
60+
<tabular|<tformat|<twith|table-width|1par>|<cwith|1|1|1|1|cell-lsep|0spc>|<cwith|1|1|1|1|cell-rsep|0spc>|<cwith|1|1|1|1|cell-bsep|0spc>|<cwith|1|1|1|1|cell-tsep|0spc>|<cwith|1|1|1|1|cell-hyphen|t>|<table|<row|<\cell>
61+
<arg|body>
62+
</cell>>>>>
63+
</macro>>
64+
65+
\;
66+
67+
<assign|solution-text|<macro|解>>
68+
69+
<assign|exercise-sep|<macro|:>>
70+
71+
<assign|problem-solution|<\macro|problem|solution>
72+
<subsection|题目:<arg|problem>>
73+
74+
<\solution*>
75+
<arg|solution>
76+
</solution*>
77+
</macro>>
78+
</hide-preamble>
79+
80+
<\homework-title>
81+
01
82+
</homework-title>
83+
84+
\;
85+
86+
<data|||>
87+
88+
\;
89+
90+
\;
91+
92+
<homework-using-books|《大学物理学(第三版)》>
93+
94+
\;
95+
96+
<problem-solution||>
97+
98+
<\note*>
99+
\;
100+
</note*>
101+
</body>
102+
103+
<\initial>
104+
<\collection>
105+
<associate|font-base-size|12>
106+
<associate|page-even-footer|<tformat|<cwith|1|-1|1|-1|cell-halign|c>|<tformat|<twith|table-width|1par>|<twith|table-hmode|exact>|<cwith|1|1|1|1|cell-width|0.3par>|<cwith|1|1|1|1|cell-hmode|exact>|<cwith|1|1|3|3|cell-width|0.3par>|<cwith|1|1|3|3|cell-hmode|exact>|<cwith|1|1|2|2|cell-width|0.4par>|<cwith|1|1|2|2|cell-hmode|exact>|<cwith|1|1|1|1|cell-halign|l>|<cwith|1|1|3|3|cell-halign|r>|<table|<row|<cell|>|<cell|<page-the-page>>|<cell|>>>>>>
107+
<associate|page-even-header|<\wide-tabular>
108+
<tformat|<cwith|1|1|1|1|cell-rborder|0ln>|<cwith|1|1|1|-1|cell-tborder|0ln>|<cwith|1|1|1|-1|cell-bborder|1ln>|<cwith|1|1|1|1|cell-lborder|0ln>|<cwith|1|1|3|3|cell-rborder|0ln>|<cwith|1|1|2|2|cell-halign|c>|<cwith|1|1|3|3|cell-halign|r>|<table|<row|<\cell>
109+
<value|header-homework>
110+
</cell>|<\cell>
111+
\;
112+
</cell>|<\cell>
113+
<value|header-course>
114+
</cell>>>>
115+
</wide-tabular>>
116+
<associate|page-medium|paper>
117+
<associate|page-odd-footer|<tformat|<cwith|1|-1|1|-1|cell-halign|c>|<tformat|<twith|table-width|1par>|<twith|table-hmode|exact>|<cwith|1|1|1|1|cell-width|0.3par>|<cwith|1|1|1|1|cell-hmode|exact>|<cwith|1|1|3|3|cell-width|0.3par>|<cwith|1|1|3|3|cell-hmode|exact>|<cwith|1|1|2|2|cell-width|0.4par>|<cwith|1|1|2|2|cell-hmode|exact>|<cwith|1|1|1|1|cell-halign|l>|<cwith|1|1|3|3|cell-halign|r>|<table|<row|<cell|>|<cell|<page-the-page>>|<cell|>>>>>>
118+
<associate|page-odd-header|<\wide-tabular>
119+
<tformat|<cwith|1|1|1|1|cell-rborder|0ln>|<cwith|1|1|1|-1|cell-tborder|0ln>|<cwith|1|1|1|-1|cell-bborder|1ln>|<cwith|1|1|1|1|cell-lborder|0ln>|<cwith|1|1|3|3|cell-rborder|0ln>|<cwith|1|1|2|2|cell-halign|c>|<cwith|1|1|3|3|cell-halign|r>|<table|<row|<\cell>
120+
<value|header-homework>
121+
</cell>|<\cell>
122+
\;
123+
</cell>|<\cell>
124+
<value|header-course>
125+
</cell>>>>
126+
</wide-tabular>>
127+
<associate|page-screen-margin|false>
128+
<associate|par-par-sep|0fn>
129+
<associate|par-sep|0.5fn>
130+
<associate|preamble|false>
131+
</collection>
132+
</initial>
133+
134+
<\references>
135+
<\collection>
136+
<associate|auto-1|<tuple|1|1>>
137+
</collection>
138+
</references>
139+
140+
<\auxiliary>
141+
<\collection>
142+
<\associate|toc>
143+
<with|par-left|<quote|1tab>|1<space|2spc>题目:<datoms|<macro|x|<repeat|<arg|x>|<with|font-series|medium|<with|font-size|1|<space|0.05fn>.<space|0.05fn>>>>>|<htab|5mm>><no-break><pageref|auto-1>>
144+
</associate>
145+
</collection>
146+
</auxiliary>

devel/201_94.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# [201_94]
2+
3+
## 如何测试
4+
5+
1. 打开`TeXmacs/tests/tmu/201_94.tmu`.
6+
2. 选中注记点击编辑宏,观察程序是否会crash
7+
8+
## 2026/03/10 修复宏编辑器crash的问题

0 commit comments

Comments
 (0)