From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Mickey Petersen Newsgroups: gmane.emacs.devel Subject: Re: Status update of tree-sitter features Date: Wed, 28 Dec 2022 15:40:23 +0000 Message-ID: <87mt77cz0x.fsf@fyeah.org> References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="15498"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: mu4e @VERSION@; emacs 30.0.50 Cc: emacs-devel@gnu.org To: Yuan Fu Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Dec 28 16:51:58 2022 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pAYik-0003kI-Dk for ged-emacs-devel@m.gmane-mx.org; Wed, 28 Dec 2022 16:51:58 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pAYhw-0005xv-CK; Wed, 28 Dec 2022 10:51:08 -0500 Original-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 ) id 1pAYhu-0005xl-G1 for emacs-devel@gnu.org; Wed, 28 Dec 2022 10:51:06 -0500 Original-Received: from mail-lo2gbr01on0715.outbound.protection.outlook.com ([2a01:111:f400:fe15::715] helo=GBR01-LO2-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pAYho-00051u-B2 for emacs-devel@gnu.org; Wed, 28 Dec 2022 10:51:05 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HXDCi/sAW7w6D+ZC5nJc+EIXdalJdA4ko5hQmMRFZ4LViOvHT97QtWogVzri4wNdy0tPwUJhvQTw8r+hhoq/eQGm+18yNQF+YDZCRgk5SNfPZl3qGJ8JmYTY2ze1TmmKJLih961FrHZ5ajhD7dTwrc0iEFTeQvOkK9UG3k1hbIzS1+FoxtIBkEe46jpRKuYfAyzGxkepAm6VtvyKCYs3h7iru4gvpJ0weSqMMRppMil4yYXsFbP0KffinXa7keqGVfbA2LpoH/pWw7gC5gcvtC8B45tAc9OwUqAp4MPhCYtJpVq/dQOr9d+3GZs9CPMDjyp97rRYfZfHqorxYpmijw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=TKLmDY9+gngv+4hwp01xx/B0M9oQNO89X7Ygi6GXe28=; b=ituVoCB0QSqbfEJj6rMCtdni+C9AajugpNhpnL5Ma5MKuzhfWXEfGMaG1/awOKLNGJ3X6hCK/axhAw1ObPd+JxkB+wdDv01+qbFqhleNZP4T/9dNVNOBltSGy89IuvH2noNtpZfkVR2WQzzWNC938O5gv3wf8RYErgdYvPi9ML5ujgrG1YOrlEj+e2V8OuU6uNrjDklXbLqHvjMP8Ryl971cSnMBqVlYitO41twjrt8oAVMhXRKN7gHfrDj5peg016zaSvYa/kNGDmgYFE0QcFwARZ70DUj47kSivoGDtK5wNc8WiDmv4yLs+N3j6E386U5j5gFfJsa0rIHMCBAFAw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 178.79.136.144) smtp.rcpttodomain=gnu.org smtp.mailfrom=fyeah.org; dmarc=pass (p=none sp=none pct=100) action=none header.from=fyeah.org; dkim=pass (signature was verified) header.d=fyeah.org; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semantical.onmicrosoft.com; s=selector1-semantical-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=TKLmDY9+gngv+4hwp01xx/B0M9oQNO89X7Ygi6GXe28=; b=syT2mvI2xcCYBXua3weutTUMFPJm8Qyu1GASE78MJ26osdpB6ROqdVvR3ijetznxlFmvSzW+ofEEnMGHizePtlHVgmyexgd3I5MAmKBqyzt1SE6DOeGynmkTw8jPUcgyDydZT29EITrJuCTTpYNK7751HPXypNNrtlH303HK7bU= Original-Received: from LNXP123CA0006.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:d2::18) by CWXP265MB2087.GBRP265.PROD.OUTLOOK.COM (2603:10a6:400:84::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5944.16; Wed, 28 Dec 2022 15:45:56 +0000 Original-Received: from CWLGBR01FT032.eop-gbr01.prod.protection.outlook.com (2603:10a6:600:d2:cafe::d0) by LNXP123CA0006.outlook.office365.com (2603:10a6:600:d2::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5944.17 via Frontend Transport; Wed, 28 Dec 2022 15:45:56 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 178.79.136.144) smtp.mailfrom=fyeah.org; dkim=pass (signature was verified) header.d=fyeah.org;dmarc=pass action=none header.from=fyeah.org; Received-SPF: Pass (protection.outlook.com: domain of fyeah.org designates 178.79.136.144 as permitted sender) receiver=protection.outlook.com; client-ip=178.79.136.144; helo=semantical.co.uk; pr=C Original-Received: from semantical.co.uk (178.79.136.144) by CWLGBR01FT032.mail.protection.outlook.com (10.152.40.160) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5966.17 via Frontend Transport; Wed, 28 Dec 2022 15:45:56 +0000 Original-Received: by semantical.co.uk (Postfix, from userid 5001) id B47EB114003; Wed, 28 Dec 2022 15:45:55 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=fyeah.org; s=fyeah.org; t=1672242355; bh=jY/miCcG5q6XCZvSCTGvgsCYvYATeAuVsy4LTVaXJ+o=; h=References:From:To:Cc:Subject:Date:In-reply-to:From; b=VBWFV1VWKHbu0HKXVJX46T0Rn7vkdjADng+//OvNGbuKnyC8pYsBIuWYCVRQujfkE GJGl0Mpor7BUbgH3suT/GUuEzNrINj6wOzLKINNb1o2K0SBxcYasp/GiGQkq0Dfrak acXySUT9F6H/tLTBqXa8/zi68EGXYZDiEyw4PClE= In-reply-to: X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CWLGBR01FT032:EE_|CWXP265MB2087:EE_ X-MS-Office365-Filtering-Correlation-Id: a3c4b52a-d900-4a8e-856b-08dae8ea9bd3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: hJaTdLMDcNN9SFD9+jExKXA9EtNL71mfiyFxQ8u5atWx/fNjL5E3d/62dKQ6NAyaekVOaQorwQsVs6oGWbCy8XF62eU14M1SxsCrHSZ6rTXFT5ebtf8NYNlNwHs/u9gZ5N7SdYY0Kpo7hnPTYNKpUuoY/DdGg4RHBiK7E61cZ6LdFSk8QOIvfQIywQmvKbwORNuQcQUq1fB1SX4uGeQDG+c+xE4OTUkc8VSZQeF6dMhtbdiyPxKOiTOpRvKoRFjg5Ctds9yqKhqUi7I/NGOmqre4hBnN0jweLcelOqThw9fA7ZzXYu1Np8vdl049GsuL52mSTXt1HtOtUQQmzhNslhcjHNlXms2Gh4WM01P5vuxpkkWfMQ00Us8seB2klfBhFSowHOJpcmkaBUYdaA9GdrJmD9OGCCdCrumuKVw8eD1FzREO8zqMRQVwjqajHZOCKYJXBTvMjrclnTwned/0Xkep+pxkT6BvpqYjZB7NLhciP3R11JumPnLLDHiSdVM42cqc/hsRF8M2vzSaB5gnwMXMu+WTodgrJejgmFRWj25tWGitxWtVyPmJLX1cacDGVVk09dpYD07dh5W3mpn2eZqFlZyIjPPFLbJq1qffhC617uJryCAkO9/BSQwRlWdOzKGIll8vpyf0EkUqadyUsdpWoKgX5otAF9xrinVFYeOn3A5qB8ZjXG/MAftAaTZNepfddfpjvBlFJP6rjiKsj32bARrTT+6e4cdgp/XoHM8OEnf0S+ZuEBIfUOdK1 K9R X-Forefront-Antispam-Report: CIP:178.79.136.144; CTRY:GB; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:semantical.co.uk; PTR:semantical.co.uk; CAT:NONE; SFS:(13230022)(39830400003)(136003)(346002)(396003)(376002)(451199015)(46966006)(36840700001)(7636003)(7596003)(36756003)(26005)(186003)(6266002)(40480700001)(86362001)(2616005)(336012)(82310400005)(478600001)(356005)(316002)(2906002)(6666004)(42186006)(47076005)(83380400001)(41300700001)(8676002)(6862004)(36860700001)(8936002)(4326008)(70586007)(5660300002)(70206006)(38230200001)(79816003)(14776008); DIR:OUT; SFP:1102; X-OriginatorOrg: fyeah.org X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Dec 2022 15:45:56.0201 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a3c4b52a-d900-4a8e-856b-08dae8ea9bd3 X-MS-Exchange-CrossTenant-Id: a4e27e3d-bab0-45e8-8942-e64cf9fbd34f X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=a4e27e3d-bab0-45e8-8942-e64cf9fbd34f; Ip=[178.79.136.144]; Helo=[semantical.co.uk] X-MS-Exchange-CrossTenant-AuthSource: CWLGBR01FT032.eop-gbr01.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CWXP265MB2087 Received-SPF: pass client-ip=2a01:111:f400:fe15::715; envelope-from=mickey@fyeah.org; helo=GBR01-LO2-obe.outbound.protection.outlook.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, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:302006 Archived-At: Yuan Fu writes: > Hi, > > As the complete feature freeze approaching, this is probably the last set= of features added to Emacs 29. I stuffed them in just in time ;-) > > 1. There is a new predicate in the query language, #pred. It=E2=80=99s li= ke #equal and #match. Basically it allows you to filter the captured node w= ith an arbitrary function. Right now there are some queries in the font-loc= k settings that matches a little more than what we actually want. For examp= le, for the property feature, we only want the =E2=80=9Cbb=E2=80=9D in =E2= =80=9Caa.bb=E2=80=9D, but not in =E2=80=9Caa.bb(cc)=E2=80=9D, because the l= atter is a method, not property. The query usually matches both. With this = new predicate we can use a function to filter out the methods. > > If we can ensure that every query only captures the intended nodes, the f= ont-lock queries can be reused for context extraction: using the query for = the variable feature, I can find all the variables in a given region, etc. > Looks useful. But this, I think, goes back to the issue I raised with you i= n an email: that queries are recursive, as each query is (I pressume this i= s how it is done in tree-sitter) applied to each node in the tree. That mak= es it very hard to build a query that pattern matches against nested nodes = only once. It is very hard, when you have recursive queries with self-simil= ar matches, to filter out recursed matches. Particularly when you are writi= ng generic code that merely acts on the output of arbitrary queries. #pred is surely no different to applying `seq-filter' or similar to the que= ry result, no?