From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Yuan Fu Newsgroups: gmane.emacs.devel Subject: Re: Tree-sitter modes and nested functions Date: Thu, 1 Dec 2022 18:51:11 -0800 Message-ID: References: Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.1.1\)) 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="24442"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: =?utf-8?Q?Jo=C3=A3o_Paulo_Labegalini_de_Carvalho?= Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Dec 02 03:51:56 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 1p0w9b-00065R-T9 for ged-emacs-devel@m.gmane-mx.org; Fri, 02 Dec 2022 03:51:55 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p0w92-0003y1-1e; Thu, 01 Dec 2022 21:51:20 -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 1p0w90-0003xl-0Z for emacs-devel@gnu.org; Thu, 01 Dec 2022 21:51:18 -0500 Original-Received: from mail-pj1-x1032.google.com ([2607:f8b0:4864:20::1032]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p0w8y-000305-Aq for emacs-devel@gnu.org; Thu, 01 Dec 2022 21:51:17 -0500 Original-Received: by mail-pj1-x1032.google.com with SMTP id x13-20020a17090a46cd00b00218f611b6e9so3949035pjg.1 for ; Thu, 01 Dec 2022 18:51:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=gwrXFJZLa+MuZr7yLsDnmWZQTH9hKj/3MOhESALW5JM=; b=NFWqYXhTa+uId+moLrlwAc4sjJo42kfywlta1UPrj9wmne4CBxBTVeGGfmdoCGAAJE RgMwgTzJFwPLLs+TupqBwJn7D0AMAbIhNso8mn37v5xT1/+FPQsj2xoEioLsL+04Nx4O bICK0YtTaKsLhfMuhXL+I9OlseHix+9pOegwt9IcSu0js6Rb59SFK3ggBrPpksC0/JH7 9yDmlulmJi3/qAcYh8bdT0tkskKbapDnBd7krf/TjSpjl03dl0EdVOcoddLkCDyaALTJ XLfBYOal6J86oASdip0iMqJfHslqDMpZS3CwtmFluaW0SqAGVxvx/l1mEdavRm+tprhG 0TQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=gwrXFJZLa+MuZr7yLsDnmWZQTH9hKj/3MOhESALW5JM=; b=UdT4XCsYTsEcTHMFj0JnZt4PeqSkWVcBMR8JSgnOHw3PSUSmznbcZ5GJQUgUwNaL15 JHmj4gAi8i5nwfhc0PnUTaqOumjSYrZILj/IcWFc2Zszm4NTACLdNP21qfD+4K/P7toV vf6H+JQDYL9fgP4NiGSzTOE7lD2cuwcqF7HGxMO2jIQTYsZMiPj/mdV/Ay7OuTTeBe+g wtxu0sgL7Xa34jVxhBQyz8Gnuew5Rm9IuF+ygvg4prgoqWGTRQfRmXyfqDs1dcDCkpww eYG4gH93ujstzNp9XoMMwM507PV+pl4e+zM45uztbG19Ay2ZLX8tGpog69VbVbZ4u4cz dSaw== X-Gm-Message-State: ANoB5pnvfWy60m6BAraRdX3jftldl4b5zmi4MqTFxQk171pBvlLnf+PV wVzjGM6wb5Z3+ermxo4Rt+U= X-Google-Smtp-Source: AA0mqf5/+5LPYN8jP3PewHafg0vSzX2sbXFjwJC2RJHDc8kclRNVr7YXn3rWQdzlHxN+Yu2Fa48Gxw== X-Received: by 2002:a17:902:9695:b0:189:93d4:db5 with SMTP id n21-20020a170902969500b0018993d40db5mr19982395plp.44.1669949474272; Thu, 01 Dec 2022 18:51:14 -0800 (PST) Original-Received: from smtpclient.apple (cpe-172-117-161-177.socal.res.rr.com. [172.117.161.177]) by smtp.gmail.com with ESMTPSA id c73-20020a624e4c000000b0056bc742d21esm4055145pfb.176.2022.12.01.18.51.12 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Dec 2022 18:51:13 -0800 (PST) In-Reply-To: X-Mailer: Apple Mail (2.3696.120.41.1.1) Received-SPF: pass client-ip=2607:f8b0:4864:20::1032; envelope-from=casouri@gmail.com; helo=mail-pj1-x1032.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, FREEMAIL_FROM=0.001, 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-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:300828 Archived-At: > On Dec 1, 2022, at 1:55 PM, Jo=C3=A3o Paulo Labegalini de Carvalho = wrote: >=20 > Hi, >=20 > While working on code navigation for sh-mode with tree-sitter I think = I found a bug. >=20 > When invoking `treesit-search-forward' the deepest nested function is = returned instead of the first found node. >=20 > ;; Contests of test.py > #!/usr/bin/env python > <---- Point position 1 > def foo(): > def bar(): <---- Point destination 1 > return 21 > return 2 * bar() > <---- Point position 2 > def fuz(): > def bur(): > def buz(): <---- Point destination 2 > return 21 > return buz() + buz() > return 1 * bur() Yeah this is expected, treesit-search-forward searches leaf nodes first = and then parent nodes. If you want to implement beginning/end-of-defun I = suggest taking a look at treesit-defun-type-regexp and = treesit-defun-prefer-top-level. Yuan=