`beginning/end-of-defun` doesn't work if point is in docstring or regex
维护者通常 3 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 45/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 技术栈
- emacs-lisp
调研方向
从 treesit-end-of-defun 和 treesit-beginning-of-defun 开始,在启用 markdown-inline 或 regex 嵌入式解析器的情况下重现该问题,并将 point 放在 docstring 或 regex 内部。完成的标准是,beginning/end-of-defun 能从这些位置到达外层的 Clojure defun,并且 CIDER 可以在那里求值 forms 而不会发生错误导航。
由索引模型根据 Issue 内容生成。
描述
Expected behavior
Executing C-M-e (end-of-defun) or C-M-a (beginning-of-defun) from any place inside of a defun navigates to a proper position.
Actual behavior
Point is not moved or moved to some random place inside of a docstring or a regex.
Steps to reproduce the problem
The issue is reproducible only if any of the embedded parsers is enabled (either markdown-inline or regex). When end-of-defun is called Emacs delegates its execution to treesit-end-of-defun, which tries to operate on "things", but if parser at point is not clojure it tries to navigate to the end of defun of embedded parser.
It also affects CIDER: currently it's not possible to evaluate form if point is in a docstring, because CIDER uses end-of-defun internally.
Possible solutions
We can either defun custom clojure-ts-[beginning|end]-of-defun functions and remap treesit-* versions or we can add advice before treesit-* functions to jump out of an embedded node before using an actual navigation command:
(defun clojure-ts--ensure-not-embedded (&rest args)
(when (and (derived-mode-p 'clojure-ts-mode)
(not (equal (treesit-language-at (point)) 'clojure)))
(backward-up-list 1 t)))
(advice-add 'treesit-end-of-defun :before #'clojure-ts--ensure-not-embedded)
(advice-add 'treesit-beginning-of-defun :before #'clojure--ts-ensure-not-embedded)
I tested both options locally, both work fine and solve the issue.
- 主要语言
- Emacs Lisp
- 星标
- 192
- 派生
- 21
- 平均合并
- 2 天 14 小时
- 30 天内合并 PR
- 23
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
clojure-emacs/clojure-ts-mode 的其他 Issue
-
难度 3/5 1-2 天 新手友好度 35/100
clojure-emacs/clojure-ts-mode#143 · 1 个 reaction ·
维护者通常 3 天内回复
-
难度 3/5 1-2 天 新手友好度 48/100
clojure-emacs/clojure-ts-mode#142 · 4 条评论 ·
维护者通常 3 天内回复
-
难度 3/5 1-2 天 新手友好度 48/100
clojure-emacs/clojure-ts-mode#135 · 5 条评论 ·
维护者通常 3 天内回复
-
bug
难度 3/5 1-2 天 新手友好度 45/100
clojure-emacs/clojure-ts-mode#129 · 1 条评论 ·
维护者通常 3 天内回复
-
难度 4/5 3-5 天 新手友好度 35/100
clojure-emacs/clojure-ts-mode#117 · 2 条评论 ·
维护者通常 3 天内回复
查看 clojure-emacs/clojure-ts-mode 的全部 Issue
相似的 Issue
-
难度 1/5 1 小时以内 新手友好度 88/100
py-econometrics/pyfixest#2114 ·
维护者通常 1 天内回复
-
Verify the Linux Python quick start from a fresh Ubuntu checkout可能已有人在做 @romanv9 今天认领。 未关闭documentation good first issue help wanted
难度 2/5 1-3 小时 新手友好度 62/100
R0Y00/Xbox2Windows#652 · 1 条评论 ·
维护者通常 1 天内回复
-
documentation good first issue
难度 2/5 1-3 小时 新手友好度 72/100
Haseeb-MernStack/commune#138 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 62/100
-
难度 2/5 1-3 小时 新手友好度 70/100
clojure-emacs/cider#4235 ·
维护者通常 1 天内回复