Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[201_98] 优化列表功能#3136

Merged
wumoin merged 1 commit intomainMoganLab/mogan:mainfrom
hongwei/201_98/optimize_listMoganLab/mogan:hongwei/201_98/optimize_listCopy head branch name to clipboard
Apr 14, 2026
Merged

[201_98] 优化列表功能#3136
wumoin merged 1 commit intomainMoganLab/mogan:mainfrom
hongwei/201_98/optimize_listMoganLab/mogan:hongwei/201_98/optimize_listCopy head branch name to clipboard

Conversation

@GatsbyUSTC
Copy link
Copy Markdown
Collaborator

No description provided.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Apr 14, 2026

Greptile Summary

本 PR 优化了 TeXmacs 中的列表编辑功能,主要包括:将 - space/+ space/1. space 快捷键改为仅在行首触发创建列表;为 Tab/Shift+Tab 增加在列表项正文内容中触发的支持,并在操作后恢复光标相对位置;以及修复了删除 item marker 后回车仍创建新 item 的问题。

所有发现均为 P2 级别的代码质量建议,不影响合并。

Confidence Score: 5/5

所有问题均为 P2 代码质量建议,不影响功能正确性,可安全合并

核心列表缩进/反缩进逻辑实现完整,边界条件(最外层列表止住、concat 包装处理、光标位置恢复)均已考虑。无 P0/P1 级别问题,仅存在代码重复和菜单提示不一致等维护性建议。

TeXmacs/progs/generic/generic-edit.scm 中本地重定义了 DRD tag list 函数,存在轻微维护风险

Important Files Changed

Filename Overview
TeXmacs/progs/generic/generic-edit.scm 新增了列表 Tab/Shift+Tab 缩进/反缩进核心逻辑;本地重定义了已由 DRD 自动生成的 tag list 函数,存在维护风险;forwards? 参数在 list-tab-context-match? 内部未被使用
TeXmacs/progs/text/text-edit.scm 新增了 blank-text?left-siblings-blank-until? 等辅助函数,改进了 line-start-empty-text?kbd-enter 的列表条件判断,逻辑清晰
TeXmacs/progs/text/text-kbd.scm - space/1. space 改为条件触发,新增 + space 创建无序列表快捷键,改动简洁正确
TeXmacs/progs/text/text-menu.scm 菜单中 itemize-menulist-menu 的快捷键提示仍显示 "- space" 但未反映条件行为,也未加入新增的 "+ space" 快捷键
devel/201_98.md 开发文档更新清晰,详细记录了各阶段改动的 What/Why/How

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["用户按 Tab / Shift+Tab"] --> B["list-tab-context-match?"]
    B -- "未找到 item marker" --> Z["不处理,调用默认行为"]
    B -- "找到 item marker" --> C{"forwards?"}
    C -- "Tab" --> D["find-item-wrapper-and-list"]
    D --> F{"item-index > 0?"}
    F -- "否" --> Z
    F -- "是" --> G["find-previous-item-index"]
    G --> H{"前一项已有子列表?"}
    H -- "是" --> I["复用已有子列表"]
    H -- "否" --> J["新建空子列表"]
    I --> K["附带后置子列表内容并入"]
    J --> K
    K --> L["tree-remove! 当前 item"]
    L --> M["go-to-moved-list-item 恢复光标"]
    C -- "Shift+Tab" --> N["确认 sublist/parent-list/outer-list"]
    N --> P{"outer-list 存在?"}
    P -- "否" --> Z
    P -- "是" --> Q{"items-before-count > 0?"}
    Q -- "非首项" --> R["保留 sublist,插入到其后"]
    Q -- "首项" --> S["删除 sublist,在原位插入"]
    R --> T{"有后续兄弟节点?"}
    S --> T
    T -- "是" --> U["重建同类型 sublist"]
    T -- "否" --> V["go-to-moved-list-item 恢复光标"]
    U --> V
Loading

Comments Outside Diff (1)

  1. TeXmacs/progs/generic/generic-edit.scm, line 169-181 (link)

    P2 本地 tag list 函数与 DRD 生成版本重复定义

    enumerate-tag-listitemize-tag-listdescription-tag-list 这三个函数在 TeXmacs/progs/text/text-drd.scm 中已通过 define-group 自动生成(第 87–97 行),text-edit.scm 等模块直接使用 DRD 版本。此处在 generic-edit.scm 内再次 define 会在本模块产生独立的局部绑定,一旦 text-drd.scm 新增列表变体(如 itemize-square),generic-edit.scm 的 Tab/Shift+Tab 逻辑不会自动跟进,存在维护隐患。

    建议直接使用 DRD 生成的函数,或通过 (:use (text text-drd)) 显式导入后直接调用,不再重复定义。

Reviews (1): Last reviewed commit: "[201_98] 优化列表功能" | Re-trigger Greptile

Comment on lines +261 to +269
(define (list-tab-context-match? forwards?)
(let* ((item (current-list-item-marker))
(enum? (in-enumerate-context?))
(itemize? (in-itemize-context?))
(description? (in-description-context?))
(match? (and item
(or (and (or enum? itemize?) (tree-is? item 'item))
(and description? (tree-is? item 'item*))))))
match?))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 forwards? 参数在函数体内未被使用

list-tab-context-match? 接受 forwards? 参数,但函数体内的判断逻辑完全不依赖该参数。调用侧通过 (and forwards? ...) / (and (not forwards?) ...) 来区分方向,参数传入函数后没有实际作用,容易让读者误以为两个方向有不同的上下文检查逻辑。

建议移除该参数,或添加注释说明为什么保留它(例如保持接口对称性)。

Comment on lines +236 to +243
(define (list-item-marker-node? t)
(or (tree-is? t 'item)
(tree-is? t 'item*)))

(define (list-item-wrapper-node? t)
(and (tree-is? t 'concat)
(> (tree-arity t) 0)
(list-item-marker-node? (tree-ref t 0))))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 list-item-marker-node? / list-item-wrapper-node?text-edit.scm 中同名函数重复

text-edit.scm 中已定义了功能完全相同的 list-item-marker?(第 420 行)和 list-item-wrapper?(第 423 行)。此处以不同名称重复实现相同逻辑,后续若列表节点类型发生变化,需要在两处同步修改。

建议将这两个函数统一到 text-edit.scm 并导出(使用 tm-define),或在 generic-edit.scm 中直接引用 text-edit.scm 的版本。

Comment on lines 404 to 409
(menu-bind itemize-menu
("Default" (make-tmlist 'itemize))
((shortcut "Default" "- space") (make-tmlist 'itemize))
---
("Bullets" (make-tmlist 'itemize-dot))
("Dashes" (make-tmlist 'itemize-minus))
("Arrows" (make-tmlist 'itemize-arrow)))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 菜单快捷键提示未反映新的条件触发行为及 + space 快捷键

itemize-menu(第 405 行)和 list-menu(第 433 行)中仍以 "- space" 作为无序列表的快捷键提示,但此 PR 将该快捷键改为仅在行首触发。此外,新增的 "+ space" 快捷键未在任何菜单中展示,用户无法通过菜单发现该功能。

建议在 itemize-menu 中同步展示 "+ space" 选项,并可考虑在提示文案中说明行首触发条件,与实际行为保持一致。

@wumoin wumoin merged commit 7818ffd into main Apr 14, 2026
1 check passed
@wumoin wumoin deleted the hongwei/201_98/optimize_list branch April 14, 2026 09:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.