GNU bug report logs - #60256
29.0.60; Maybe improve tree sitter default treesit-language-at function

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Reported by: Wilhelm H Kirschbaum <wilhelm@HIDDEN>; Keywords: wontfix; dated Thu, 22 Dec 2022 10:35:02 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.
Added tag(s) wontfix. Request was from Eli Zaretskii <eliz@HIDDEN> to control <at> debbugs.gnu.org. Full text available.

Message received at 60256 <at> debbugs.gnu.org:


Received: (at 60256) by debbugs.gnu.org; 25 Dec 2022 06:40:45 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Dec 25 01:40:45 2022
Received: from localhost ([127.0.0.1]:47454 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1p9Kgf-0001W6-HM
	for submit <at> debbugs.gnu.org; Sun, 25 Dec 2022 01:40:45 -0500
Received: from eggs.gnu.org ([209.51.188.92]:40256)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>)
 id 1p9Kgd-0001Vi-L8; Sun, 25 Dec 2022 01:40:44 -0500
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1p9KgX-0004Kz-FP; Sun, 25 Dec 2022 01:40:37 -0500
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From:
 Date; bh=vOJyOGI7PhRGhVELfvMicIDWuZm40n768SRkmrYMZW0=; b=eTXf1CX76bR2SbDAWnR0
 vxsti8MYKYJBetqDCLcU6VPYHdsz7CfU2aQC35FpIzowHOgXHZ934LmsP1LlbdGCtXZwHHJZdo5qE
 iEAChGgR9VBjpde6QpfFzK5uKu8r5q++U3YiKWVXibUXkkZ165JltCh9xEyAlgCbTFWNkg7+QH8HE
 OaLbjGmLft1Dgn2oj8JRWsqzTto32VFQSnV23FTuMOw6We1/Jq0pbwPLWQslP9nOPXEOC3CgyOd9m
 X/vl9fRBe7mxsfmTMFJreZvPAso2X3AeUasr1gf4MaoH40ChlawNs4beBQZpNy/KgroPYWXJCb8JF
 8uf+6hJCHHVdCA==;
Received: from [87.69.77.57] (helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1p9KgW-0004uI-BT; Sun, 25 Dec 2022 01:40:37 -0500
Date: Sun, 25 Dec 2022 08:40:35 +0200
Message-Id: <83h6xk3s0s.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Yuan Fu <casouri@HIDDEN>
In-Reply-To: <ABFC83CF-9758-41BF-9993-210F507CC9C8@HIDDEN> (message from
 Yuan Fu on Sat, 24 Dec 2022 14:43:18 -0800)
Subject: Re: bug#60256: 29.0.60; Maybe improve tree sitter default 
 treesit-language-at function
References: <ABFC83CF-9758-41BF-9993-210F507CC9C8@HIDDEN>
MIME-version: 1.0
Content-type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 60256
Cc: 60256 <at> debbugs.gnu.org, wilhelm@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

tags 60256 wontfix
thanks

> From: Yuan Fu <casouri@HIDDEN>
> Date: Sat, 24 Dec 2022 14:43:18 -0800
> Cc: Wilhelm Hugo Kirschbaum <wilhelm@HIDDEN>,
>  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.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#60256; Package emacs. Full text available.

Message received at 60256 <at> debbugs.gnu.org:


Received: (at 60256) by debbugs.gnu.org; 24 Dec 2022 22:43:29 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Dec 24 17:43:29 2022
Received: from localhost ([127.0.0.1]:47271 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1p9DEn-00089e-CI
	for submit <at> debbugs.gnu.org; Sat, 24 Dec 2022 17:43:29 -0500
Received: from mail-pf1-f171.google.com ([209.85.210.171]:42835)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <casouri@HIDDEN>) id 1p9DEl-00089L-9H
 for 60256 <at> debbugs.gnu.org; Sat, 24 Dec 2022 17:43:27 -0500
Received: by mail-pf1-f171.google.com with SMTP id 65so5352654pfx.9
 for <60256 <at> debbugs.gnu.org>; Sat, 24 Dec 2022 14:43:27 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
 h=to:cc:date:message-id:subject:mime-version
 :content-transfer-encoding:from:from:to:cc:subject:date:message-id
 :reply-to; bh=4WZDx4WracP7yGdvWM5jdMaOClVxXIpuUcUTCCAXB64=;
 b=j+waXLQj6RN/ahum0BPwN1XWuMjlFdiKGPx2cd33ZwBcXBZbhfBuvzJdf6N4TbXgVQ
 T9NQRH7yaHAoenYsatCGsO04fx5qnP5RNtTPM0xghNtqk5DzoiX+l/DjCBPeqb5b3Vh4
 Orm9yUykUg3vS5nHR8ekQGYA+GWnminEh37ns5RwQOQwknbMH8po/sW2VF/wCChX3O9c
 vKvlz79NZKMZ84OX6q87XXVu/ezD7R/8Im79/GDCyscgtCwuyHX2GiQddNO5hCd4g/eU
 uupEsRUj71Va/3FDigzbSFjzGVVbDLnGzwYrS40QxbtTCMLbu6OZhKizhMUeihL0WZsi
 yQPA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20210112;
 h=to:cc:date:message-id:subject:mime-version
 :content-transfer-encoding:from:x-gm-message-state:from:to:cc
 :subject:date:message-id:reply-to;
 bh=4WZDx4WracP7yGdvWM5jdMaOClVxXIpuUcUTCCAXB64=;
 b=YLfyEUR1OQBNIzHqFN08HYBu2aiR7wHf9K+MHc++pqkRFEMF+msWuIVG1Lj+Hp1XPc
 r8oxBmNJqlqam4tBA03SQig8NwITMg/rBi2Z6d9/QiiKqbZBHf4vBI+46oedzZBTxcLC
 l7Wk8vtHWvGv9mtCRHLHKjJbp7crlifWl5Rg0L6k4Vtu3CD8TAwfTgj0wX3oJBp8zXRk
 M0qDsCCYSQ2V/FVfCOCbB8c+vHhBs0p13htx9e4Ab8la9VSOXPnApuFdEr736lGsimHp
 5eG09JiMsoDSDYcPuzWWpM9YhTzQa8ZbLTD2MaSH1llzYpW15Ki8VjWeTwL6kDAKiL+u
 9SPw==
X-Gm-Message-State: AFqh2krv/r5JsN6ZXhLM5c7qfmFy950bOZeVX6vR1lVH69ISRyurpUFa
 cpVOzyeF8kd5MwyPUoMYrhI=
X-Google-Smtp-Source: AMrXdXum0VHFdENSidjCuOHHRZ1CRMFlnTJi3hOPrwF69vSym0AV7cLTP9Q88CHtGfLie0oRQozqxA==
X-Received: by 2002:a62:1ec7:0:b0:575:d195:ddb6 with SMTP id
 e190-20020a621ec7000000b00575d195ddb6mr14755443pfe.25.1671921801467; 
 Sat, 24 Dec 2022 14:43:21 -0800 (PST)
Received: from smtpclient.apple (cpe-172-117-161-177.socal.res.rr.com.
 [172.117.161.177]) by smtp.gmail.com with ESMTPSA id
 x124-20020a623182000000b005779110635asm4564932pfx.51.2022.12.24.14.43.20
 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128);
 Sat, 24 Dec 2022 14:43:21 -0800 (PST)
From: Yuan Fu <casouri@HIDDEN>
Content-Type: text/plain;
	charset=utf-8
Content-Transfer-Encoding: quoted-printable
Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.1.1\))
Subject: Re: bug#60256: 29.0.60; Maybe improve tree sitter default 
 treesit-language-at function
Message-Id: <ABFC83CF-9758-41BF-9993-210F507CC9C8@HIDDEN>
Date: Sat, 24 Dec 2022 14:43:18 -0800
To: Eli Zaretskii <eliz@HIDDEN>
X-Mailer: Apple Mail (2.3696.120.41.1.1)
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 60256
Cc: 60256 <at> debbugs.gnu.org, Wilhelm Hugo Kirschbaum <wilhelm@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)


Eli Zaretskii <eliz@HIDDEN> writes:

>> From: Wilhelm H Kirschbaum <wilhelm@HIDDEN>
>> Date: Thu, 22 Dec 2022 12:30:09 +0200
>>=20
>>=20
>> We can detect the language from treesit-parser-included-ranges, so
>> instead of taking the first parser from the list what about taking=20
>> the first parser within known ranges?
>
> Yuan, any comments?

Yeah, sorry for the delay. I don=E2=80=99t think it=E2=80=99s 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@HIDDEN:
bug#60256; Package emacs. Full text available.

Message received at 60256 <at> debbugs.gnu.org:


Received: (at 60256) by debbugs.gnu.org; 24 Dec 2022 07:25:24 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Dec 24 02:25:24 2022
Received: from localhost ([127.0.0.1]:41386 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1p8yuJ-0002Zb-O6
	for submit <at> debbugs.gnu.org; Sat, 24 Dec 2022 02:25:24 -0500
Received: from eggs.gnu.org ([209.51.188.92]:34072)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1p8yuH-0002ZT-JE
 for 60256 <at> debbugs.gnu.org; Sat, 24 Dec 2022 02:25:22 -0500
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1p8yuB-000210-UH; Sat, 24 Dec 2022 02:25:15 -0500
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date:
 mime-version; bh=mHceVH4iWsLEjp12fr159lFRTturpjQ9Eqi19tJ3FF0=; b=Ok9TtltvDFK4
 02kx58YabxCRylg8xjD1S5l+2f2kTH21eopIlszp7aHKpLKXctMKz+fPwICjK47xF54DJLSOiZyVH
 SQRfwE4lZcP7TwcaqWsLHTe/6p+1s+oz0UdgwUqyuQSeefZOyIpWTI807WKzvZ1lwoEaDs45Q8EQW
 xR6Z3jqNkiFf/jd6eDChe54+0X/YIQSvlKK8vyP45HZd5m5BPNHdQoh17NPhOQsKuKDl4xY2Bot8U
 Y2rVusLkFjlB0itNhOZbbB+qZbgiEKjz/vkS0ehBrjRppDDPwq4OXOAAWO4afAwg4HHA5jp0QdYaQ
 VSOREIDDzrORPfi3uXGM9g==;
Received: from [87.69.77.57] (helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1p8yu9-0005eb-NW; Sat, 24 Dec 2022 02:25:15 -0500
Date: Sat, 24 Dec 2022 09:25:12 +0200
Message-Id: <83sfh55kmf.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Wilhelm H Kirschbaum <wilhelm@HIDDEN>, Yuan Fu <casouri@HIDDEN>
In-Reply-To: <87h6xnenhl.fsf@HIDDEN> (message from Wilhelm H Kirschbaum on
 Thu, 22 Dec 2022 12:30:09 +0200)
Subject: Re: bug#60256: 29.0.60;
 Maybe improve tree sitter default treesit-language-at function
References: <87h6xnenhl.fsf@HIDDEN>
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 60256
Cc: 60256 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> From: Wilhelm H Kirschbaum <wilhelm@HIDDEN>
> 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@HIDDEN:
bug#60256; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 22 Dec 2022 10:34:09 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Dec 22 05:34:09 2022
Received: from localhost ([127.0.0.1]:57554 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1p8Its-0005iO-L1
	for submit <at> debbugs.gnu.org; Thu, 22 Dec 2022 05:34:09 -0500
Received: from lists.gnu.org ([209.51.188.17]:44904)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <wilhelm@HIDDEN>) id 1p8Itq-0005iI-Gi
 for submit <at> debbugs.gnu.org; Thu, 22 Dec 2022 05:34:07 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10])
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <wilhelm@HIDDEN>)
 id 1p8Itp-0005pm-Uv
 for bug-gnu-emacs@HIDDEN; Thu, 22 Dec 2022 05:34:06 -0500
Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.90_1) (envelope-from <wilhelm@HIDDEN>)
 id 1p8Ito-0004DH-Ab
 for bug-gnu-emacs@HIDDEN; Thu, 22 Dec 2022 05:34:05 -0500
Received: by mail-wm1-x336.google.com with SMTP id m19so1077961wms.5
 for <bug-gnu-emacs@HIDDEN>; Thu, 22 Dec 2022 02:34:03 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=floatpays.co.za; s=google;
 h=mime-version:message-id:date:subject:to:user-agent:from:from:to:cc
 :subject:date:message-id:reply-to;
 bh=1OKogxL7PDRwfpCbmGQoOxMFLjFUM2piF3671XkNOqY=;
 b=OiclP1CFDNDwlT74HoBopxJRylMHQHQqtCCbgmZ37CSiPnBY9ycTlbVf2jB0mTSFJS
 Sm5tcgYhV304Ckbj49SRnoafDZYZrx2PmQW8YGrcOgjFAYAldEuV6N8oRzfjDZCdzw8o
 3/5j5ZIFXIJ/uS+hrB7CTzfZosBNjsUYqGos8=
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20210112;
 h=mime-version:message-id:date:subject:to:user-agent:from
 :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;
 bh=1OKogxL7PDRwfpCbmGQoOxMFLjFUM2piF3671XkNOqY=;
 b=uJgi4ZPaUB1x1bcCtG/B+J7Ksd8HHU7hA/hbZPaCuE6JAFmM26D1JSK54EJZnhSaHC
 kWb/xoi+PhFk1fbG/GMvYjX07LDsiOuSXwBH/rYzvp/e2c03QJs1JIp4UW73hwZznpV8
 5v0MjKZNcQgMi/1IHt2l/jqjs4TsSy5MFtFXUe3rVUbwT7gO0HOXXxyKXNE6+bbMCGCQ
 1F8cG5OyzVf3+b4wV0XY/pu8xcvNohSSy0UO4yKqdfQzqhOcauwhbnA6DN1Jt7NhQkT2
 QQSrNbSXkQHXM17gak/ksokJ51MdQPDaWgLc/7j3G41UUgvNem58kKvg5baLYe23VrtG
 I5tg==
X-Gm-Message-State: AFqh2kqC60NheCqzVdZOsEqiBW2KTpjgPh80y07SnBO+Ir+qiuJSTeLx
 AncdlQmIBSSBtyg+gP5hCnFZutoCt+54RD6P
X-Google-Smtp-Source: AMrXdXv6MDLKWfVS3estSW6MgaBX3ZJN0GvZ+HVO3gFj/gpSKhNVurXUtJotvi/lLqqYU3D2nXMSNg==
X-Received: by 2002:a05:600c:4fd4:b0:3d3:4877:e556 with SMTP id
 o20-20020a05600c4fd400b003d34877e556mr4080866wmq.29.1671705241811; 
 Thu, 22 Dec 2022 02:34:01 -0800 (PST)
Received: from melissa.local ([2c0f:ef18:1431:0:b09:9616:db04:c248])
 by smtp.gmail.com with ESMTPSA id
 i9-20020a05600c354900b003d33ab317dasm798572wmq.14.2022.12.22.02.34.00
 for <bug-gnu-emacs@HIDDEN>
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Thu, 22 Dec 2022 02:34:01 -0800 (PST)
From: Wilhelm H Kirschbaum <wilhelm@HIDDEN>
X-Google-Original-From: Wilhelm H Kirschbaum <wkirschbaum@HIDDEN>
User-agent: mu4e 1.9.3; emacs 29.0.60
To: bug-gnu-emacs@HIDDEN
Subject: 29.0.60; Maybe improve tree sitter default treesit-language-at
 function
Date: Thu, 22 Dec 2022 12:30:09 +0200
Message-ID: <87h6xnenhl.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; format=flowed
Received-SPF: pass client-ip=2a00:1450:4864:20::336;
 envelope-from=wilhelm@HIDDEN; helo=mail-wm1-x336.google.com
X-Spam_score_int: -20
X-Spam_score: -2.1
X-Spam_bar: --
X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
 RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001,
 SPF_PASS=-0.001 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: -1.3 (-)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.3 (--)


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




Acknowledgement sent to Wilhelm H Kirschbaum <wilhelm@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#60256; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Sun, 25 Dec 2022 06:45:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.