From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Dmitry Gutov Newsgroups: gmane.emacs.bugs Subject: bug#59662: 29.0.50; [PATCH] Add treesit--indent-defun Date: Thu, 8 Dec 2022 17:43:54 +0200 Message-ID: References: <5B538888-E454-4F75-B3B8-AB20E10B3E89@gmail.com> <83o7sniokt.fsf@gnu.org> <4D5A1640-4F0F-4C21-8ED6-770B88A870EA@thornhill.no> <83r0xhdluq.fsf@gnu.org> <3e25eadb-3f2b-f92d-8b18-bf1daca91b64@yandex.ru> <83wn78cqz4.fsf@gnu.org> <4d605e69-7df9-6480-c1c5-dcb22abd3bde@yandex.ru> <83y1ri2wnj.fsf@gnu.org> <875yemz55b.fsf@thornhill.no> <83r0xa2tc4.fsf@gnu.org> <87zgbyxohf.fsf@thornhill.no> <837cz22bgd.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="7166"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Cc: larsi@gnus.org, 59662@debbugs.gnu.org, theo@thornhill.no, monnier@iro.umontreal.ca, casouri@gmail.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Dec 08 16:45:34 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1p3J5Z-0001a5-9R for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 08 Dec 2022 16:45:33 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p3J5O-0002aS-T5; Thu, 08 Dec 2022 10:45:22 -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 1p3J55-0002WF-Fd for bug-gnu-emacs@gnu.org; Thu, 08 Dec 2022 10:45:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p3J55-0006AU-0o for bug-gnu-emacs@gnu.org; Thu, 08 Dec 2022 10:45:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1p3J54-0004Gw-NB for bug-gnu-emacs@gnu.org; Thu, 08 Dec 2022 10:45:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Dmitry Gutov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 08 Dec 2022 15:45:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 59662 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 59662-submit@debbugs.gnu.org id=B59662.167051425416395 (code B ref 59662); Thu, 08 Dec 2022 15:45:02 +0000 Original-Received: (at 59662) by debbugs.gnu.org; 8 Dec 2022 15:44:14 +0000 Original-Received: from localhost ([127.0.0.1]:57505 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p3J4H-0004GN-CG for submit@debbugs.gnu.org; Thu, 08 Dec 2022 10:44:13 -0500 Original-Received: from mail-wm1-f49.google.com ([209.85.128.49]:55222) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p3J47-0004Ft-NN for 59662@debbugs.gnu.org; Thu, 08 Dec 2022 10:44:11 -0500 Original-Received: by mail-wm1-f49.google.com with SMTP id o15so1021952wmr.4 for <59662@debbugs.gnu.org>; Thu, 08 Dec 2022 07:44:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :sender:from:to:cc:subject:date:message-id:reply-to; bh=LjHEHs58l1L9jE8QZlaqcfJn9I42R38MpdD8JR4lICI=; b=qKQiH9f3v1IZoljtAyyIsb8hPSmQm+UOPr0ey0z2IaDea9XpZo9LpZMGMzuytuiRrq 6DooZGgMQeqqpL5joPzascOfgw+qcZ72Gk1xT1s8JON5nGU/eZglUfZbj6uOyquXPh3p sXlMo2rZCm9imvh/LwHm0ZMXq2YzF7sy2LRpgOfOh80ZVTJqhzqyC6cEFiWlj2qCQH5u PQy0Fg+a8XCvmP2uJSWwf+nqytg+FcBcVwhgKwUKfc/ZioBqF/8nnrP5ImMXQgHhKzTn BDJkm9lgt7UXHdRCJ9KNFy7VA3l7JAwUR31V8j/1m+4YYkUYVZlBI4limedhz3+0sQse YMrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :sender:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=LjHEHs58l1L9jE8QZlaqcfJn9I42R38MpdD8JR4lICI=; b=fHxpcu8dhBXcMUgtrvA+rUoR9lfF2W6BsyxcXdKfiA4ymSISDlRCsf1o8rsFErMiRY 0ypqxlihgvX8dMfY89oSoQ2xqCnKkaptdNWtjQI3z05ln2Hc3OMfYmBzpJWWTD3zrupv amQNrnpqgn5t8XbzvcLEDPEtll9B9RnGhAJr3tbR7egXKVa3LyIcO1RK1mdxNapi0NPk TJ8dOhVFE0k5S6DrZCdK3KazYb7QqCU81uI4itF0b625lAkK7+EyQvYe/8W1loUjGrbi Egw9Lm6+5ALWBxVETiRWvv2zlVhOf+kUQMXQjYsuKDIL2AJxqKzzOdoIYjAB8iALPweo Jq0Q== X-Gm-Message-State: ANoB5plHsMI2GfY2q8t3WM06jwAuFvdRAXu9vWZXo4GQgGd0MYJ3IYtW pTyFvBc6/nnsNJFIkbydR1w= X-Google-Smtp-Source: AA0mqf5u7h3CKqeBY45A3yfeGUufht2b2JulSBxpio7S5vAu8z5WyNBQJptpdbsQ74pUftbZnRdSgg== X-Received: by 2002:a05:600c:354e:b0:3cf:5d41:b748 with SMTP id i14-20020a05600c354e00b003cf5d41b748mr2316584wmq.36.1670514236750; Thu, 08 Dec 2022 07:43:56 -0800 (PST) Original-Received: from [192.168.0.2] ([46.251.119.176]) by smtp.googlemail.com with ESMTPSA id j42-20020a05600c1c2a00b003c6d21a19a0sm6339982wms.29.2022.12.08.07.43.55 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 08 Dec 2022 07:43:56 -0800 (PST) Content-Language: en-US In-Reply-To: <837cz22bgd.fsf@gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:250313 Archived-At: On 08/12/2022 16:53, Eli Zaretskii wrote: >> Date: Thu, 8 Dec 2022 16:18:17 +0200 >> Cc: monnier@iro.umontreal.ca, larsi@gnus.org, 59662@debbugs.gnu.org, >> casouri@gmail.org >> From: Dmitry Gutov >> >> On 08/12/2022 10:56, Theodor Thornhill wrote: >>> (if (or (and (treesit-available-p) >>> (treesit-ready-p (treesit-language-at (point))) >>> (string-match-p >>> treesit-comment-type-regexp >>> (treesit-node-type (treesit-node-at (point))))) >> >> I was kind of hoping that sometime in the near future our tree-sitter >> code would somehow plug into syntax-ppss (maybe via advice or etc) to >> provide the same results faster. > > It is too early to consider practical code along these lines, we don't > have enough experience with tree-sitter. I'm not even sure it can be > easily factored into the same categories as syntax-ppss uses. I'm fairly certain that tree-sitter contexts could be "dumbed down" into syntax-ppss categories. But that's not the only way: another is to just use tree-sitter to find a "safe place" to call parse-partial-sexp from. That would give us the speed bump together with 100% backward compatibility. > IMO, the way to move to a unified handling is to use tree-sitter > wherever we can, originally as special-cased code, and later refactor > that into generalized APIs, when we know more about how to define and > use them. syntax-ppss is used in a lot of places. A "free" improvement like the above wouldn't hurt. >> So my preference would be to check in the implementation as-is (if >> everybody agrees with the behavior), and then migrate it to new helpers >> (in case plugging into syntax-ppss won't be automatic). >> >> But I don't really mind the code you posted, if somebody (e.g. Eli) is >> going to insist on it. It just doesn't seem critical from the >> performance POV, and the variable treesit-comment-type-regexp seems to >> be a little out of place. But then again, if the helpers will be put in >> prog-mode.el, the var will be there as well. > > I don't insist, but it sounds like the logical thing to do. So unless > you feel strongly against that, I'd say let's add that part. This is, > after all, an experiment, so let's experiment. I'm not going to object. Doubly so if somebody else wants to finish up the patch and commit it with NEWS and documentation updates. ;-)