diff --git a/TeXmacs/plugins/mgs/progs/data/mgs.scm b/TeXmacs/plugins/mgs/progs/data/mgs.scm deleted file mode 100644 index 20652e3572..0000000000 --- a/TeXmacs/plugins/mgs/progs/data/mgs.scm +++ /dev/null @@ -1,142 +0,0 @@ - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; -;; MODULE : data/mgs.scm -;; DESCRIPTION : Mogan Scheme (.mgs) data format -;; COPYRIGHT : (C) 2003 Joris van der Hoeven -;; -;; This software falls under the GNU general public license version 3 or later. -;; It comes WITHOUT ANY WARRANTY WHATSOEVER. For details, see the file LICENSE -;; in the root directory or . -;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -(texmacs-module (data mgs)) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; Scheme format for TeXmacs (no information loss) -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -(define (mgs-recognizes? s) - (and (string? s) (string-starts? s "(document (TeXmacs"))) - -(define-format mgs - (:name "Mogan Scheme") - (:suffix "mgs") - (:must-recognize mgs-recognizes?)) - -(define (format-mgs-string str) - ;; Parsing the string to an S-expression - (define (parse-string s) - (call-with-input-string s (lambda (port) (read port)))) - - (define indent-cache (make-vector 50 #f)) - - (define (get-indent n) - (if (< n 50) - (let ((cached (vector-ref indent-cache n))) - (if cached - cached - (let ((spaces (make-string n #\space))) - (vector-set! indent-cache n spaces) - spaces))) - (make-string n #\space))) - - (define (has-more-than-2? lst) - (and (pair? lst) (pair? (cdr lst)))) - - (define (every pred lst) - (or (null? lst) - (and (pred (car lst)) - (every pred (cdr lst))))) - - (define (simple-structure? expr) - (define (simple-element? x) - (or (not (pair? x)) - (every (lambda (e) (not (pair? e))) (cdr x)))) - (cond - ((not (pair? expr)) #t) - (else (every simple-element? (cdr expr))))) - - (define (expr-total-string-length expr) - (cond - ((null? expr) 0) - ((string? expr) (string-length expr)) - ((pair? expr) (+ (expr-total-string-length (car expr)) - (expr-total-string-length (cdr expr)))) - (else 0))) - - (define (format-expr expr indent) - (cond - ((null? expr) "()") - ((string? expr) (format #f "~s" expr)) - ((number? expr) (number->string expr)) - ((symbol? expr) (symbol->string expr)) - ((pair? expr) - (let* ((head (car expr)) - (body (cdr expr)) - (is-symbol-head? (symbol? head)) - (has-enough-elems? (has-more-than-2? body)) - (is-simple-struct? (simple-structure? expr)) - (simple-and-short? (and is-simple-struct? - (<= (expr-total-string-length expr) 100))) - (should-format? (and is-symbol-head? - has-enough-elems? - (not simple-and-short?)))) - (string-append - "(" (format-expr head indent) - (if (null? body) - ")" - (let ((new-indent (+ indent 2))) - (string-append - (if should-format? "\n" " ") - (format-body body should-format? new-indent) - ")")))))))) - - (define (format-body body should-format? indent) - (string-join - (map - (lambda (rest-expr) - (string-append - (if should-format? (get-indent indent) "") - (format-expr rest-expr indent))) - body) - (if should-format? "\n" " "))) - - ;; Return the original string when an error occurs - (catch #t - (lambda () - (let ((expr (parse-string str))) - (format-expr expr 0))) - (lambda args str))) - -(define (texmacs->mgs t . opts) - (if (null? opts) (set! opts '())) - (let* ((options (if (list-1? opts) (car opts) opts)) - (do-format? (== (and (assoc-ref options "texmacs->mgs:formatted") - (get-preference "texmacs->mgs:formatted")) - "on")) - (stm-str (texmacs->stm (herk-tree->utf8-tree t)))) - (if do-format? - (format-mgs-string stm-str) - stm-str))) - -(define (mgs->texmacs text) - (utf8-tree->herk-tree (stm->texmacs text))) - -(define (mgs-snippet->texmacs text) - (utf8-tree->herk-tree (stm-snippet->texmacs text))) - -(converter texmacs-tree mgs-document - (:function-with-options texmacs->mgs) - (:option "texmacs->mgs:formatted" "off")) - -(converter mgs-document texmacs-tree - (:function mgs->texmacs)) - -(converter texmacs-tree mgs-snippet - (:function-with-options texmacs->mgs) - (:option "texmacs->mgs:formatted" "off")) - -(converter mgs-snippet texmacs-tree - (:function mgs-snippet->texmacs)) diff --git a/TeXmacs/progs/init-research.scm b/TeXmacs/progs/init-research.scm index 057b9bc01e..4ed3a316ba 100644 --- a/TeXmacs/progs/init-research.scm +++ b/TeXmacs/progs/init-research.scm @@ -525,7 +525,6 @@ (lazy-format (data image) postscript pdf svg gif jpeg png ppm tif webp xpm) (lazy-format (convert rewrite init-rewrite) texmacs verbatim) -(lazy-format (data mgs) mgs) (lazy-format (data stm) stm) (lazy-format (data stem) stem) (lazy-format (data tmu) tmu) diff --git a/TeXmacs/progs/texmacs/menus/edit-menu.scm b/TeXmacs/progs/texmacs/menus/edit-menu.scm index 2ecdf6073b..dd7314b5da 100644 --- a/TeXmacs/progs/texmacs/menus/edit-menu.scm +++ b/TeXmacs/progs/texmacs/menus/edit-menu.scm @@ -23,10 +23,7 @@ (with l (filter (lambda (x) (or (with-developer-tool?) - (and (not (string=? x "mgs")) - (not (string=? x "stm")) - (not (string=? x "stem")) - ) ;and + (and (not (string=? x "stm")) (not (string=? x "stem"))) ) ;or ) ;lambda (cvs "texmacs-snippet" "-snippet" #t) diff --git a/TeXmacs/progs/texmacs/menus/file-menu.scm b/TeXmacs/progs/texmacs/menus/file-menu.scm index 46560be45e..9f5f0b8208 100644 --- a/TeXmacs/progs/texmacs/menus/file-menu.scm +++ b/TeXmacs/progs/texmacs/menus/file-menu.scm @@ -175,10 +175,7 @@ (filter (lambda (x) (and (not (in? x (image-formats))) (or (with-developer-tool?) - (and (not (string=? x "mgs")) - (not (string=? x "stm")) - (not (string=? x "stem")) - ) ;and + (and (not (string=? x "stm")) (not (string=? x "stem"))) ) ;or ) ;and ) ;lambda @@ -221,10 +218,7 @@ (not (string=? x "latex")) (not (string=? x "latex-class")) (or (with-developer-tool?) - (and (not (string=? x "mgs")) - (not (string=? x "stm")) - (not (string=? x "stem")) - ) ;and + (and (not (string=? x "stm")) (not (string=? x "stem"))) ) ;or ) ;and ) ;lambda diff --git a/TeXmacs/progs/texmacs/menus/preferences-menu.scm b/TeXmacs/progs/texmacs/menus/preferences-menu.scm index 26d670b69e..7357892d0a 100644 --- a/TeXmacs/progs/texmacs/menus/preferences-menu.scm +++ b/TeXmacs/progs/texmacs/menus/preferences-menu.scm @@ -243,9 +243,7 @@ ("1.4" "1.4") ("1.5" "1.5") ("1.6" "1.6") - ("1.7" "1.7")))) - (-> "TeXmacs -> Mogan Scheme" - (toggle "Formatted Mogan Scheme" "texmacs->mgs:formatted"))) + ("1.7" "1.7"))))) (-> "Mathematics" (-> "Keyboard" (item ("Enforce brackets to match" (toggle-matching-brackets))) diff --git a/TeXmacs/progs/texmacs/menus/preferences-widgets.scm b/TeXmacs/progs/texmacs/menus/preferences-widgets.scm index b1ec859df7..9a26dd8333 100644 --- a/TeXmacs/progs/texmacs/menus/preferences-widgets.scm +++ b/TeXmacs/progs/texmacs/menus/preferences-widgets.scm @@ -856,18 +856,6 @@ ;; Mogan Scheme ---------- -(tm-widget (mogan-scheme-preferences-widget) - ====== - (bold (text "TeXmacs -> Mogan Scheme")) - === - (aligned (meti (hlist // (text "Use the Formatted Mogan Scheme")) - (toggle (set-boolean-preference "texmacs->mgs:formatted" answer) - (get-boolean-preference "texmacs->mgs:formatted") - ) ;toggle - ) ;meti - ) ;aligned -) ;tm-widget - ;; All converters ---------- (tm-widget (conversion-preferences-widget) @@ -880,9 +868,6 @@ (tab (text "Pdf") (centered (dynamic (pdf-preferences-widget)))) ) ;assuming (tab (text "Image") (centered (dynamic (image-preferences-widget)))) - (tab (text "Mogan Scheme") - (centered (dynamic (mogan-scheme-preferences-widget))) - ) ;tab ) ;tabs ) ;padded === diff --git a/TeXmacs/progs/texmacs/texmacs/tm-files.scm b/TeXmacs/progs/texmacs/texmacs/tm-files.scm index 8a451259e4..10c68c12c9 100644 --- a/TeXmacs/progs/texmacs/texmacs/tm-files.scm +++ b/TeXmacs/progs/texmacs/texmacs/tm-files.scm @@ -740,7 +740,7 @@ ;; ;; 逻辑 ;; ---- -;; 只允许本地、非 tmfs、非 web 且格式为 texmacs/stm/mgs/tmu 的文档备份; +;; 只允许本地、非 tmfs、非 web 且格式为 texmacs/stm/tmu 的文档备份; ;; 位于 get-texmacs-path 目录或子目录下的内置只读文件直接跳过。 ;; ;; 注意 @@ -752,7 +752,7 @@ (not (url-rooted-web? name)) (not (url-rooted-tmfs? name)) (not (auto-backup-texmacs-path-buffer? name)) - (in? (auto-backup-format name) '("texmacs" "stm" "mgs" "tmu" "stem")) + (in? (auto-backup-format name) '("texmacs" "stm" "tmu" "stem")) ) ;and ) ;tm-define diff --git a/devel/1131.md b/devel/1131.md index 98a0f2a89d..f5728ac596 100644 --- a/devel/1131.md +++ b/devel/1131.md @@ -80,3 +80,32 @@ S-expression 解析器 `moebius/moebius/data/scheme_der.cpp` 中的 `string_to_s - `moebius/moebius/data/scheme_der.cpp` - `TeXmacs/plugins/python/packages/code/python.stem` - `TeXmacs/tests/stem_python_equiv.scm`(新增等价性测试) + +## 2026/06/29 移除 mgs 格式 + +### What +彻底移除 `mgs` 文件格式及相关 UI 配置,`stem` 作为继任格式继续保留。 + +### Why +- `stem` 已完全替代 `mgs`,两者功能重叠。 +- `mgs` 的格式化转换逻辑不成熟,且已在 `stem` 中去除。 +- 减少菜单、偏好设置和格式白名单中的冗余条目。 + +### How +- 删除 `TeXmacs/plugins/mgs/progs/data/mgs.scm` 及空目录 `TeXmacs/plugins/mgs`。 +- 在 `TeXmacs/progs/init-research.scm` 中移除 `(lazy-format (data mgs) mgs)`。 +- 在 `src/Texmacs/Data/new_buffer.cpp` 的 `attach_subformat` 中移除 `"mgs"` 判断。 +- 在 `TeXmacs/progs/texmacs/texmacs/tm-files.scm` 的自动备份白名单与注释中移除 `mgs`。 +- 在 `TeXmacs/progs/texmacs/menus/file-menu.scm`、`edit-menu.scm` 的开发者工具隐藏列表中移除 `"mgs"`。 +- 在 `TeXmacs/progs/texmacs/menus/preferences-menu.scm` 中移除 "TeXmacs -> Mogan Scheme" 子菜单。 +- 在 `TeXmacs/progs/texmacs/menus/preferences-widgets.scm` 中移除 `mogan-scheme-preferences-widget` 及其在 Conversion 标签页中的 Tab。 + +### 涉及文件 +- `TeXmacs/plugins/mgs/progs/data/mgs.scm`(删除) +- `TeXmacs/progs/init-research.scm` +- `src/Texmacs/Data/new_buffer.cpp` +- `TeXmacs/progs/texmacs/texmacs/tm-files.scm` +- `TeXmacs/progs/texmacs/menus/file-menu.scm` +- `TeXmacs/progs/texmacs/menus/edit-menu.scm` +- `TeXmacs/progs/texmacs/menus/preferences-menu.scm` +- `TeXmacs/progs/texmacs/menus/preferences-widgets.scm` diff --git a/src/Texmacs/Data/new_buffer.cpp b/src/Texmacs/Data/new_buffer.cpp index 145e36ab00..f0152b5643 100644 --- a/src/Texmacs/Data/new_buffer.cpp +++ b/src/Texmacs/Data/new_buffer.cpp @@ -460,8 +460,7 @@ attach_buffer_notifier (url name) { tree attach_subformat (tree t, url u, string fm) { - if ((fm == "texmacs") || (fm == "stm") || (fm == "mgs") || (fm == "stem")) - return t; + if ((fm == "texmacs") || (fm == "stm") || (fm == "stem")) return t; if (!format_exists (fm)) return t; string s = suffix (u);