unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Tree sitter: allowing access to `ts_tree_get_changed_ranges()' from elisp
@ 2022-11-26 14:57 Simon Pugnet
  2022-11-26 15:32 ` Eli Zaretskii
  0 siblings, 1 reply; 3+ messages in thread
From: Simon Pugnet @ 2022-11-26 14:57 UTC (permalink / raw)
  To: Emacs developers

[-- Attachment #1: Type: text/plain, Size: 1856 bytes --]

Dear Emacs developers,

I'm a contributor to Symex.el 
(<https://github.com/drym-org/symex.el>), a structural editing package 
based on Evil. The core package was originally designed to be used 
with Lisp languages but I have been working on it to add support for 
other languages via Tree Sitter.

This work has been going on for quite a while so I am currently using 
Tuấn-Anh Nguyễn's `elisp-tree-sitter' package 
(<https://github.com/emacs-tree-sitter/elisp-tree-sitter>). As Yuan 
Fu's tree-sitter branch has just been merged I decided this was a good 
time to look into updating Symex.el so that it can use the built-in 
version instead when it's available.

Progress so far has been good and I have a large portion of the 
functionality working with both implementations. However I've just 
found a feature that I'm using in `elisp-tree-sitter' that does not 
seem to be available in the built-in version.

Part of the functionality I use is fetching a list of ranges that have 
been changed between the previous and current parser trees (after an 
editing operation). This is exposed by `elisp-tree-sitter' via the 
`tsc-changed-ranges' function. From the docstring, "…This function 
returns a sequence of ranges whose syntactic structure has changed." I 
can't find an equivalent function exposed by the built-in tree sitter 
library however.

I've checked src/treesit.c and I can see that there is a 
`ts_tree_get_changed_ranges()' function, presumably from the 
underlying tree sitter library. However I don't think this is being 
exposed to elisp. Would it be possible to allow this information to be 
provided to elisp somehow?

Thanks in advance for your help, and apologies if this is already 
available and I have simply missed it.

Kind regards,

-- 
Simon Pugnet
https://www.polaris64.net/

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 861 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Tree sitter: allowing access to `ts_tree_get_changed_ranges()' from elisp
  2022-11-26 14:57 Tree sitter: allowing access to `ts_tree_get_changed_ranges()' from elisp Simon Pugnet
@ 2022-11-26 15:32 ` Eli Zaretskii
  2022-11-26 15:53   ` Simon Pugnet
  0 siblings, 1 reply; 3+ messages in thread
From: Eli Zaretskii @ 2022-11-26 15:32 UTC (permalink / raw)
  To: Simon Pugnet; +Cc: emacs-devel

> From: Simon Pugnet <simon@polaris64.net>
> Date: Sat, 26 Nov 2022 15:57:33 +0100
> 
> I've checked src/treesit.c and I can see that there is a 
> `ts_tree_get_changed_ranges()' function, presumably from the 
> underlying tree sitter library. However I don't think this is being 
> exposed to elisp. Would it be possible to allow this information to be 
> provided to elisp somehow?

It's exposed to Lisp via the parser's after-change notifiers.  See
treesit-parser-add-notifier.



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Tree sitter: allowing access to `ts_tree_get_changed_ranges()' from elisp
  2022-11-26 15:32 ` Eli Zaretskii
@ 2022-11-26 15:53   ` Simon Pugnet
  0 siblings, 0 replies; 3+ messages in thread
From: Simon Pugnet @ 2022-11-26 15:53 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 703 bytes --]

Eli Zaretskii <eliz@gnu.org> writes:

>> From: Simon Pugnet <simon@polaris64.net>
>> Date: Sat, 26 Nov 2022 15:57:33 +0100
>> 
>> I've checked src/treesit.c and I can see that there is a 
>> `ts_tree_get_changed_ranges()' function, presumably from the 
>> underlying tree sitter library. However I don't think this is being 
>> exposed to elisp. Would it be possible to allow this information to 
>> be 
>> provided to elisp somehow?
>
> It's exposed to Lisp via the parser's after-change notifiers.  See
> treesit-parser-add-notifier.

Thank you; yes I can now see that `treesit-parser-add-notifier' should 
allow me to do what I need to do.

Kind regards,

-- 
Simon Pugnet
https://www.polaris64.net/

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 861 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-11-26 15:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-26 14:57 Tree sitter: allowing access to `ts_tree_get_changed_ranges()' from elisp Simon Pugnet
2022-11-26 15:32 ` Eli Zaretskii
2022-11-26 15:53   ` Simon Pugnet

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).