From 71f2e9275e9de8db68409cbddc5d0c7c321ea2ce Mon Sep 17 00:00:00 2001 From: Yuki Date: Mon, 2 Feb 2026 11:37:09 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E5=8F=82=E8=80=83=E6=96=87=E7=8C=AE?= =?UTF-8?q?=E5=BC=B9=E7=AA=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TeXmacs/progs/text/text-edit.scm | 16 ---------------- TeXmacs/progs/text/text-menu.scm | 8 +------- 2 files changed, 1 insertion(+), 23 deletions(-) diff --git a/TeXmacs/progs/text/text-edit.scm b/TeXmacs/progs/text/text-edit.scm index 67f073362d..2ee8d219f8 100644 --- a/TeXmacs/progs/text/text-edit.scm +++ b/TeXmacs/progs/text/text-edit.scm @@ -542,22 +542,6 @@ (n (if (== (url-suffix r) "bib") (url-unglue r 4) r))) (url->string n)))) -(tm-define (make-bib file-name) - (:argument file-name "Bibliography file") - (let* ((name (normalized-bib-name file-name)) - (aux (if (context-has? "bib-prefix") (get-env "bib-prefix") "bib")) - (style (if (context-has? "bib-style") (get-env "bib-style") "tm-gbt7714-2015"))) - (if (not (make-return-after)) - (insert-go-to `(bibliography ,aux ,style ,name (document "")) - '(3 0 0))))) - -(tm-define (make-database-bib) - (with aux (if (context-has? "bib-prefix") (get-env "bib-prefix") "bib") - (with style (if (context-has? "bib-style") (get-env "bib-style") "tm-gbt7714-2015") - (if (not (make-return-after)) - (insert-go-to `(bibliography ,aux ,style "" (document "")) - '(3 0 0)))))) - (tm-define (automatic-section-context? t) (tree-in? t (automatic-section-tag-list))) diff --git a/TeXmacs/progs/text/text-menu.scm b/TeXmacs/progs/text/text-menu.scm index 51ae87c8b6..c88c91cc03 100644 --- a/TeXmacs/progs/text/text-menu.scm +++ b/TeXmacs/progs/text/text-menu.scm @@ -468,13 +468,7 @@ (menu-bind automatic-menu ("Table of contents" (make-aux "table-of-contents" "toc-prefix" "toc")) - (assuming (get-boolean-preference "gui:new bibliography dialogue") - ("Bibliography" (open-bibliography-inserter))) - (assuming (not (get-boolean-preference "gui:new bibliography dialogue")) - (if (with-database-tool?) - ("Bibliography" (make-database-bib))) - (if (not (with-database-tool?)) - ("Bibliography" (choose-file make-bib "Bibliography file" "tmbib")))) + ("Bibliography" (open-bibliography-inserter)) ("Index" (make-aux "the-index" "index-prefix" "idx")) ("Glossary" (make-aux "the-glossary" "glossary-prefix" "gly")) ;;("List of figures" (make-aux* "the-glossary*" "figure-list-prefix" "figure" "List of figures")) From 8e67a52543e9da9389c9da5fe2294e98756088ea Mon Sep 17 00:00:00 2001 From: Yuki Date: Thu, 5 Feb 2026 11:11:19 +0800 Subject: [PATCH 2/4] wip --- TeXmacs/plugins/lang/dic/en_US/zh_CN.scm | 5 +++ .../latex/progs/bibtex/bib-widgets.scm | 43 ++++++++++++------- .../progs/texmacs/menus/preferences-tools.scm | 4 -- .../texmacs/menus/preferences-widgets.scm | 8 ---- 4 files changed, 33 insertions(+), 27 deletions(-) diff --git a/TeXmacs/plugins/lang/dic/en_US/zh_CN.scm b/TeXmacs/plugins/lang/dic/en_US/zh_CN.scm index c49d61857f..fc3c86dd82 100644 --- a/TeXmacs/plugins/lang/dic/en_US/zh_CN.scm +++ b/TeXmacs/plugins/lang/dic/en_US/zh_CN.scm @@ -106,6 +106,7 @@ ("Use CSS for more advanced formatting" "使用 CSS 进行更高级的格式化") ("Use high resolution icons" "使用高分辨率图标") ("Use line wrapping for lines which are longer than 80 characters" "自动换行超过 80 个字符的行") +("Use relative path" "使用相对路径") ("Use retina fonts" "使用适配视网膜屏的字体") ("Use the Formatted Mogan Scheme" "使用格式化后的 Mogan Scheme") ("Windows Bitmap" "Windows位图") @@ -1169,6 +1170,7 @@ ("Insert the recognized LaTeX code into the document" "仅将识别后的LaTeX代码插入文档") ("Insert the image and the recognized LaTeX code into the document" "将图片与识别后的LaTeX代码插入文档") ("Insert only the picture into the document" "仅将图片插入文档") +("Inserting bibliography in %1" "在 %1 中插入参考文献") ("insertion" "嵌入") ("inside mathematics" "在数学模式中") ("interactive command" "") @@ -1438,12 +1440,14 @@ ("mode dependent icons" "模式工具栏") ("mode" "模式") ("modifier" "") +("Modifying bibliography for %1" "在 %1 中修改参考文献") ("modify cell alignment" "改变单元格对齐") ("modify cell border" "") ("modify cell padding" "") ("modify cell size" "改变单元格大小") ("modify table border" "") ("modify table padding" "") +("modify" "修改") ("mogan" "墨干") ("mongolian" "") ("month" "月") @@ -2387,6 +2391,7 @@ ("Unknown" "未知") ("up" "") ("up" "上") +("Update buffer" "更新缓冲区") ("update from web" "") ("update image links" "") ("update this buffer" "更新此文档") diff --git a/TeXmacs/plugins/latex/progs/bibtex/bib-widgets.scm b/TeXmacs/plugins/latex/progs/bibtex/bib-widgets.scm index 3ee9599c06..5e509b4261 100644 --- a/TeXmacs/plugins/latex/progs/bibtex/bib-widgets.scm +++ b/TeXmacs/plugins/latex/progs/bibtex/bib-widgets.scm @@ -1,8 +1,9 @@ + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; MODULE : bib-widgets.scm ;; DESCRIPTION : Widgets for bibliography -;; COPYRIGHT : (C) 2014 Miguel de Benito Delgado +;; COPYRIGHT : (C) 2014 Miguel de Benito Delgado 2026 Yuki Lu ;; ;; 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 @@ -15,10 +16,11 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (texmacs-module (bibtex bib-widgets) - (:use (bibtex bib-complete) (generic document-edit))) + (:use (bibtex bib-complete) (bibtex bib-utils) (generic document-edit))) (define bibwid-url (string->url "")) (define bibwid-style "tm-plain") +(define bibwid-default-style "tm-plain") (define bibwid-use-relative? #t) (define bibwid-update-buffer? #t) (define bibwid-buffer (string->url "")) @@ -30,8 +32,15 @@ (set! bibwid-url (url-append (url-head bibwid-buffer) u))) (else (set! bibwid-url u)))) +(define (safe-bib-standard-styles) + (catch #t (lambda () (bib-standard-styles)) + (lambda (key . args) '("tm-plain")))) + (define (bibwid-set-style answer) - (set! bibwid-style answer) + (let ((styles (safe-bib-standard-styles))) + (if (and (string? answer) (in? answer styles)) + (set! bibwid-style answer) + (set! bibwid-style bibwid-default-style))) (refresh-now "bibwid-preview")) (define (bibwid-output-content t style) @@ -43,15 +52,19 @@ (mini-paragraph "480px" ,(bib-process "bib" style (tree->stree t)))))) (define (bibwid-output) - (with style (if (== "tm-" (string-take bibwid-style 3)) + (with style (if (and (>= (string-length bibwid-style) 3) + (== "tm-" (string-take bibwid-style 3))) (string-drop bibwid-style 3) bibwid-style) - (eval `(use-modules (bibtex ,(string->symbol style)))) + (when (== style "") + (set! style bibwid-default-style)) + (catch #t (lambda () (eval `(use-modules (bibtex ,(string->symbol style))))) + (lambda (key . args) (noop))) (with u (if (and bibwid-use-relative? (not (url-rooted? bibwid-url))) (url-append (url-head bibwid-buffer) bibwid-url) bibwid-url) - (with t (if (url-exists? u) - (parse-bib (string-load u)) + (with t (if (url-exists? u) + (parse-bib (string-load u)) (tree "")) (stree->tree (bibwid-output-content t style)))))) @@ -82,8 +95,8 @@ (bibwid-set-filename bibwid-url)) (tm-widget (bibwid-preview) - (resize ("520px" "520px" "9999px") ("100px" "100px" "9999px") - (scrollable + (resize '("520px" "520px" "9999px") '("100px" "100px" "9999px") + (scrollable (refreshable "bibwid-preview" (texmacs-output (bibwid-output) @@ -106,18 +119,18 @@ ("" (choose-file bibwid-set-filename "Choose" "tmbib")))))) === (hlist - ;(balloon "Use relative path:" "Select this to use a path relative to the current document. You can use this to be able to move around the folder containing your document and the bibliography.") (text "Use relative path:") // - (toggle (bibwid-set-relative answer) bibwid-use-relative?) + (toggle (bibwid-set-relative answer) + bibwid-use-relative?) // // - (text "Update buffer:") // + (text "Update buffer:") // (toggle (set! bibwid-update-buffer? answer) bibwid-update-buffer?) - /// + // // (text "Style:") // // - (enum (bibwid-set-style answer) (bib-standard-styles) + (enum (bibwid-set-style answer) (safe-bib-standard-styles) bibwid-style "10em")) - === === === + === (hlist // (dynamic (bibwid-preview)) //) === (bottom-buttons >>> diff --git a/TeXmacs/progs/texmacs/menus/preferences-tools.scm b/TeXmacs/progs/texmacs/menus/preferences-tools.scm index 956221de70..62a272ae33 100644 --- a/TeXmacs/progs/texmacs/menus/preferences-tools.scm +++ b/TeXmacs/progs/texmacs/menus/preferences-tools.scm @@ -42,10 +42,6 @@ (meti (hlist // (text "Use native menubar")) (toggle (set-boolean-preference "use native menubar" answer) (get-boolean-preference "use native menubar")))) - (meti (hlist // (text "New bibliography dialogue")) - (toggle - (set-boolean-preference "gui:new bibliography dialogue" answer) - (get-boolean-preference "gui:new bibliography dialogue"))) (meti (hlist // (text "Program bracket matching")) (toggle (set-boolean-preference "prog:highlight brackets" answer) (get-boolean-preference "prog:highlight brackets"))) diff --git a/TeXmacs/progs/texmacs/menus/preferences-widgets.scm b/TeXmacs/progs/texmacs/menus/preferences-widgets.scm index 64fcc36088..86cb463a43 100644 --- a/TeXmacs/progs/texmacs/menus/preferences-widgets.scm +++ b/TeXmacs/progs/texmacs/menus/preferences-widgets.scm @@ -828,10 +828,6 @@ pretty-val : string (meti (hlist // (text "New style page breaking")) (toggle (set-boolean-preference "new style page breaking" answer) (get-boolean-preference "new style page breaking"))) - (meti (hlist // (text "New bibliography dialogue")) - (toggle - (set-boolean-preference "gui:new bibliography dialogue" answer) - (get-boolean-preference "gui:new bibliography dialogue"))) (meti (hlist // (text "Encryption")) (toggle (set-boolean-preference "experimental encryption" answer) (get-boolean-preference "experimental encryption"))) @@ -879,10 +875,6 @@ pretty-val : string (meti (hlist // (text "New style page breaking")) (toggle (set-boolean-preference "new style page breaking" answer) (get-boolean-preference "new style page breaking"))) - ;;(meti (hlist // (text "New bibliography dialogue")) - ;; (toggle - ;; (set-boolean-preference "gui:new bibliography dialogue" answer) - ;; (get-boolean-preference "gui:new bibliography dialogue"))) (meti (hlist // (text "Program bracket matching")) (toggle (set-boolean-preference "prog:highlight brackets" answer) (get-boolean-preference "prog:highlight brackets"))) From 54bab2c5ff6ae6aab9edf7c5a18931bec3ddadb6 Mon Sep 17 00:00:00 2001 From: Yuki Date: Thu, 5 Feb 2026 12:03:31 +0800 Subject: [PATCH 3/4] wip --- TeXmacs/plugins/latex/progs/bibtex/bib-widgets.scm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/TeXmacs/plugins/latex/progs/bibtex/bib-widgets.scm b/TeXmacs/plugins/latex/progs/bibtex/bib-widgets.scm index 5e509b4261..f24a837b87 100644 --- a/TeXmacs/plugins/latex/progs/bibtex/bib-widgets.scm +++ b/TeXmacs/plugins/latex/progs/bibtex/bib-widgets.scm @@ -128,8 +128,8 @@ bibwid-update-buffer?) // // (text "Style:") // // - (enum (bibwid-set-style answer) (safe-bib-standard-styles) - bibwid-style "10em")) + (verb (enum (bibwid-set-style answer) (safe-bib-standard-styles) + bibwid-style "10em"))) === (hlist // (dynamic (bibwid-preview)) //) === From 77f8f55ffb9b4d513d672487bc3c51cc2834ce76 Mon Sep 17 00:00:00 2001 From: Yuki Date: Mon, 9 Feb 2026 14:35:16 +0800 Subject: [PATCH 4/4] wip --- .../latex/progs/bibtex/bib-widgets.scm | 2 +- devel/204_25.md | 20 +++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/TeXmacs/plugins/latex/progs/bibtex/bib-widgets.scm b/TeXmacs/plugins/latex/progs/bibtex/bib-widgets.scm index f24a837b87..67e590113c 100644 --- a/TeXmacs/plugins/latex/progs/bibtex/bib-widgets.scm +++ b/TeXmacs/plugins/latex/progs/bibtex/bib-widgets.scm @@ -146,7 +146,7 @@ (set! bibwid-buffer (current-buffer)) (let ((u (current-bib-file #f)) (s (current-bib-style #f)) - (name (url-tail bibwid-buffer))) + (name (buffer-get-title bibwid-buffer))) (if (and (not (url-none? u)) (!= s "")) (with msg (replace "Modifying bibliography for %1" name) (bibwid-set-url u) diff --git a/devel/204_25.md b/devel/204_25.md index 7660361a07..b08dc30276 100644 --- a/devel/204_25.md +++ b/devel/204_25.md @@ -11,6 +11,26 @@ - 空文件测试:从网上选取一些bib文件,并复制标准的参考文献格式,使用 插入 -> 自动 -> 参考文献,然后最下方工具栏的右侧样式里,选择tm-gbt7714-2015-author-year,对比生成效果 - 补充测试 - 测试文档:Texmacs/tests/tmu/204_25_supplement.tmu +- 弹窗测试 + - 点击参考文献按钮 + - 插入测试 + +## 2026/02/09 参考文献功能使用弹窗 +### What +```scheme + (assuming (get-boolean-preference "gui:new bibliography dialogue") + ("Bibliography" (open-bibliography-inserter))) + (assuming (not (get-boolean-preference "gui:new bibliography dialogue")) + (if (with-database-tool?) + ("Bibliography" (make-database-bib))) + (if (not (with-database-tool?)) + ("Bibliography" (choose-file make-bib "Bibliography file" "tmbib")))) +``` +简化为 +``` +("Bibliography" (open-bibliography-inserter)) +``` +删去首选项选择,改为直接使用,修复部分问题 ## 2026/02/03 优化参考文献样式 ### What