GNU bug report logs -
#60256
29.0.60; Maybe improve tree sitter default treesit-language-at function
Previous Next
Reported by: Wilhelm H Kirschbaum <wilhelm <at> floatpays.co.za>
Date: Thu, 22 Dec 2022 10:35:02 UTC
Severity: normal
Tags: wontfix
Found in version 29.0.60
Done: Stefan Kangas <stefankangas <at> gmail.com>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 60256 in the body.
You can then email your comments to 60256 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#60256
; Package
emacs
.
(Thu, 22 Dec 2022 10:35:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Wilhelm H Kirschbaum <wilhelm <at> floatpays.co.za>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Thu, 22 Dec 2022 10:35:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
We can detect the language from treesit-parser-included-ranges, so
instead of taking the first parser from the list what about taking
the
first parser within known ranges?
diff --git a/lisp/treesit.el b/lisp/treesit.el
index 6407669118..f08bb1cd40 100644
--- a/lisp/treesit.el
+++ b/lisp/treesit.el
@@ -136,8 +136,20 @@ treesit-language-at
parser in `treesit-parser-list', or nil if there is no parser."
(if treesit-language-at-point-function
(funcall treesit-language-at-point-function position)
- (when-let ((parser (car (treesit-parser-list))))
- (treesit-parser-language parser))))
+ (let ((language-in-range
+ (cl-loop
+ for parser in (treesit-parser-list)
+ do (setq range
+ (cl-loop
+ for range in (treesit-parser-included-ranges
parser)
+ if (and (>= point (car range)) (<= point (cdr
range)))
+ return parser))
+ if range
+ return (treesit-parser-language parser))))
+ (if (null language-in-range)
+ (when-let ((parser (car (treesit-parser-list))))
+ (treesit-parser-language parser))
+ language-in-range))))
Maybe there is a better way of doing this, but seems like it can
be
generic enough to make this work without having to set
treesit-language-at-point-function for the majority of the cases.
Wilhelm
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#60256
; Package
emacs
.
(Sat, 24 Dec 2022 07:26:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 60256 <at> debbugs.gnu.org (full text, mbox):
> From: Wilhelm H Kirschbaum <wilhelm <at> floatpays.co.za>
> Date: Thu, 22 Dec 2022 12:30:09 +0200
>
>
> We can detect the language from treesit-parser-included-ranges, so
> instead of taking the first parser from the list what about taking
> the first parser within known ranges?
Yuan, any comments?
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#60256
; Package
emacs
.
(Sat, 24 Dec 2022 22:44:01 GMT)
Full text and
rfc822 format available.
Message #11 received at 60256 <at> debbugs.gnu.org (full text, mbox):
Eli Zaretskii <eliz <at> gnu.org> writes:
>> From: Wilhelm H Kirschbaum <wilhelm <at> floatpays.co.za>
>> Date: Thu, 22 Dec 2022 12:30:09 +0200
>>
>>
>> We can detect the language from treesit-parser-included-ranges, so
>> instead of taking the first parser from the list what about taking
>> the first parser within known ranges?
>
> Yuan, any comments?
Yeah, sorry for the delay. I don’t think it’s worth it, because (1) I
expect major modes with multiple langauges to implement
treesit-language-at-point-function which takes care of all the work, and
(2) in the rare case where there are multiple languages and no
treesit-language-at-point-function, using the first language whose range
spans point (this patch) is not necessarily correct: the host language (eg, HTML
among HTML, CSS & JavaScript) always covers the whole buffer, only
embedded languages has ranges.
Yuan
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#60256
; Package
emacs
.
(Sun, 25 Dec 2022 06:41:02 GMT)
Full text and
rfc822 format available.
Message #14 received at 60256 <at> debbugs.gnu.org (full text, mbox):
tags 60256 wontfix
thanks
> From: Yuan Fu <casouri <at> gmail.com>
> Date: Sat, 24 Dec 2022 14:43:18 -0800
> Cc: Wilhelm Hugo Kirschbaum <wilhelm <at> floatpays.co.za>,
> 60256 <at> debbugs.gnu.org
>
>
> Yeah, sorry for the delay. I don’t think it’s worth it, because (1) I
> expect major modes with multiple langauges to implement
> treesit-language-at-point-function which takes care of all the work, and
> (2) in the rare case where there are multiple languages and no
> treesit-language-at-point-function, using the first language whose range
> spans point (this patch) is not necessarily correct: the host language (eg, HTML
> among HTML, CSS & JavaScript) always covers the whole buffer, only
> embedded languages has ranges.
OK, thanks.
Added tag(s) wontfix.
Request was from
Eli Zaretskii <eliz <at> gnu.org>
to
control <at> debbugs.gnu.org
.
(Sun, 25 Dec 2022 06:41:02 GMT)
Full text and
rfc822 format available.
Reply sent
to
Stefan Kangas <stefankangas <at> gmail.com>
:
You have taken responsibility.
(Sat, 02 Sep 2023 16:42:01 GMT)
Full text and
rfc822 format available.
Notification sent
to
Wilhelm H Kirschbaum <wilhelm <at> floatpays.co.za>
:
bug acknowledged by developer.
(Sat, 02 Sep 2023 16:42:02 GMT)
Full text and
rfc822 format available.
Message #21 received at 60256-done <at> debbugs.gnu.org (full text, mbox):
Eli Zaretskii <eliz <at> gnu.org> writes:
> tags 60256 wontfix
> thanks
>
>> From: Yuan Fu <casouri <at> gmail.com>
>> Date: Sat, 24 Dec 2022 14:43:18 -0800
>> Cc: Wilhelm Hugo Kirschbaum <wilhelm <at> floatpays.co.za>,
>> 60256 <at> debbugs.gnu.org
>>
>>
>> Yeah, sorry for the delay. I don’t think it’s worth it, because (1) I
>> expect major modes with multiple langauges to implement
>> treesit-language-at-point-function which takes care of all the work, and
>> (2) in the rare case where there are multiple languages and no
>> treesit-language-at-point-function, using the first language whose range
>> spans point (this patch) is not necessarily correct: the host language (eg, HTML
>> among HTML, CSS & JavaScript) always covers the whole buffer, only
>> embedded languages has ranges.
>
> OK, thanks.
I'm therefore closing this bug report.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Sun, 01 Oct 2023 11:24:22 GMT)
Full text and
rfc822 format available.
This bug report was last modified 1 year and 222 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.