Skip to content

" nodes should not be sexps? - #78

Merged
bbatsov merged 2 commits into
bbatsov:mainfrom
dalz:patch-1
Sep 7, 2026
Merged

" nodes should not be sexps?#78
bbatsov merged 2 commits into
bbatsov:mainfrom
dalz:patch-1

Conversation

@dalz

@dalz dalz commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Right now (treesit-thing-at (point) 'sexp) with point before the opening quote of a string returns the node corresponding to the quote only, which I assume is a bug?

@bbatsov

bbatsov commented Sep 5, 2026

Copy link
Copy Markdown
Owner

Yeah, looks like a bug to me. Can you add some regression tests covering this?

Comment thread neocaml.el Outdated
(sexp (not ,(rx (or "{" "}" "(" ")" "[" "]" "[|" "|]"
"," "." ";" ";;" ":" "::" ":>" "->"
"<-" "=" "|" ".."))))
"<-" "=" "|" ".." "\""))))

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Confirmed on Emacs 31.1 with the stock grammar: before this change (treesit-thing-at (point) 'sexp) at the opening quote returns the bare " node, with it you get the whole string node. C-M-f/C-M-b behave the same either way, so it's mostly thing-at-point-style consumers that notice.

Two more cases worth covering while you're at it:

  • Char literals have the same bug: point before 'a' yields the bare ' node, so "'" should join the exclusion list. That's safe for type variables, since 'a in a type parses as a single type_variable token with no anonymous ' child.
  • {|...|} quoted strings are already fine (the { is excluded and thing-at returns the whole quoted_string), but a regression test for them alongside strings and char literals would pin all three down.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done, lmk if you'd like it done differently

dalz and others added 2 commits September 7, 2026 21:54
treesit-thing-at only exists from Emacs 30, so the new specs are
pending on 29.
@bbatsov
bbatsov merged commit c0bd187 into bbatsov:main Sep 7, 2026
4 checks passed
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