`beginning/end-of-defun` doesn't work if point is in docstring or regex
メンテナーはふだん 3 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 45/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 停滞
- 技術スタック
- emacs-lisp
調査の方向性
treesit-end-of-defun と treesit-beginning-of-defun から始め、markdown-inline または regex の埋め込みパーサーを有効にした状態で問題を再現し、docstring または regex の内部に point を置きます。完了の条件は、beginning/end-of-defun がそれらの位置から外側の Clojure defun に到達し、CIDER が誤ったナビゲーションなしにそこでフォームを評価できることです。
索引モデルが 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時間
- マージ済み PR(30日)
- 23
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
clojure-emacs/clojure-ts-mode のほかの issue
-
難易度 3/5 1〜2日 初心者へのやさしさ 35/100
clojure-emacs/clojure-ts-mode#143 · リアクション 1 件 ·
メンテナーはふだん 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 日以内に返信