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.bugs Subject: bug#64442: 29.0.92; treesit-beginning-of-defun fails in DEFUN functions in C Date: Thu, 6 Jul 2023 23:15:00 -0700 Message-ID: References: <83a5wcncj8.fsf@gnu.org> <83pm57lxbo.fsf@gnu.org> Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3731.600.7\)) 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="26606"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 64442@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Jul 07 08:16:21 2023 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 1qHelR-0006mE-Mm for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 07 Jul 2023 08:16:21 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qHel9-0007Gx-7i; Fri, 07 Jul 2023 02:16:03 -0400 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 1qHel8-0007GY-5P for bug-gnu-emacs@gnu.org; Fri, 07 Jul 2023 02:16:02 -0400 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 1qHel7-0004R9-Tx for bug-gnu-emacs@gnu.org; Fri, 07 Jul 2023 02:16:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qHel7-0007Ny-LY for bug-gnu-emacs@gnu.org; Fri, 07 Jul 2023 02:16:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Yuan Fu Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 07 Jul 2023 06:16:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 64442 X-GNU-PR-Package: emacs Original-Received: via spool by 64442-submit@debbugs.gnu.org id=B64442.168871052128336 (code B ref 64442); Fri, 07 Jul 2023 06:16:01 +0000 Original-Received: (at 64442) by debbugs.gnu.org; 7 Jul 2023 06:15:21 +0000 Original-Received: from localhost ([127.0.0.1]:42428 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qHekS-0007My-Ud for submit@debbugs.gnu.org; Fri, 07 Jul 2023 02:15:21 -0400 Original-Received: from mail-pg1-f178.google.com ([209.85.215.178]:47199) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qHekQ-0007Mh-57 for 64442@debbugs.gnu.org; Fri, 07 Jul 2023 02:15:19 -0400 Original-Received: by mail-pg1-f178.google.com with SMTP id 41be03b00d2f7-53482b44007so889507a12.2 for <64442@debbugs.gnu.org>; Thu, 06 Jul 2023 23:15:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1688710512; x=1691302512; 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=08RYeE6/ufI6QAHdu22FvGda11GYAk4LSuZnOFnsGCM=; b=iZMIDd2PB4le4XPDyr9Cgj8Kyi1l4fnaqXBRy3wJx8G4gtMx5ih8K/GVoepZO28+cz xRkZJdWVwFggwxVK4erW/OqC4jrlX3swVh3bJKbxmCIMueh0SOBTBe6NjmUgbYg4DhHF Ewy4ibvp7ncPP3gVihkB9nBNk5eqppGR0NenMgqG0i0aRqRPq6OdDPlek59ZZkb5ZvWs iMX4MG4z54xLvvGsaKKIHWLYEnoEmNXMsPaNIIx2OBxYhncn0WldSBK5oEPU+x49i97S ukfZ/9emK+s4jva9aJUUnXAiShBIHY2ZKdYTtJtrbgv+zz9BG+Lu21MUbdmDrAH1DHVx 9Zrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688710512; x=1691302512; 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=08RYeE6/ufI6QAHdu22FvGda11GYAk4LSuZnOFnsGCM=; b=FRj7mzcj398uC28nPpQLummb0LUmePuAS0pBNwB0RAfWBYc6HTo2/HifP/izS6y73C 67qPwkA0OWsyJyZUisR8QaKOxqrJBh8uQMBF6wiEPCHJfDQBCu4eG15W08mjNS4r5ZAB gtJm1rWSXRR8pF+KZsqtiOtqY71Zs6yiZRKyRS5WCmeMLVgx+mY+aa53C8gfiJD3zcHq 5aobaCKcocjnipdemcOS8vzRiLnKqIbsYTW+aMF5oEXvWsaIxS2r4qtyb9E4dLhee46c ymzkDIJpbWSuBDgPqZok7jetsSaj/Z/pnD8HTCm7Lx941kdSlwGDpIo8w4MWv2WTxlH8 73uw== X-Gm-Message-State: ABy/qLa7A3cD6pYreOQIID+fhig68Gq+lVqVN+aqtJDHrXIEezEqVr0f uK0bve7FnFSb0gvvh428nELopMpN/BM= X-Google-Smtp-Source: APBJJlGOsQexFtcNowI79bzKCVhsHVAySoPrI16UqCzV1G9FSCCu5KQELocwBAjKckaVT3BLYNMKow== X-Received: by 2002:a05:6a20:605:b0:12d:1d8f:6af8 with SMTP id 5-20020a056a20060500b0012d1d8f6af8mr2916040pzl.18.1688710512036; Thu, 06 Jul 2023 23:15:12 -0700 (PDT) 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 j21-20020a170902c3d500b001993a1fce7bsm2368520plj.196.2023.07.06.23.15.11 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 06 Jul 2023 23:15:11 -0700 (PDT) In-Reply-To: <83pm57lxbo.fsf@gnu.org> X-Mailer: Apple Mail (2.3731.600.7) 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:264703 Archived-At: > On Jul 4, 2023, at 4:39 AM, Eli Zaretskii wrote: >=20 >> From: Yuan Fu >> Date: Tue, 4 Jul 2023 01:41:22 -0700 >> Cc: 64442@debbugs.gnu.org >>=20 >> The problem with DEFUN=E2=80=99s is that a DEFUN is really made of = two nodes in the parse tree. One for the DEFUN part, one for the body, = and there isn=E2=80=99t a parent node that encloses the two.=20 >>=20 >> The defun movement functions are not designed to handle a construct = made of two adjacent nodes. They can find a node, go to the = beginning/end of it; they can=E2=80=99t find a node, and go to the end = of the next node. >>=20 >> It sounds easy to add some hack to handle it, but really isn=E2=80=99t.= Defun movement need to support forward/backward to beg/end, that=E2=80=99= s four movement types; >=20 > Why cannot we look for a top-level expression_statement node which is > a call_expression whose function identifier is "DEFUN" and whose > position is between the place where C-M-a was invoked and the place > where it does find a defun? It=E2=80=99s gonna be ugly, but I can take a jab at it this weekend. = I=E2=80=99m thinking of a wrapper function that tries to detect DEFUN = before falling back to the ordinary tree-sitter defun movement function. >=20 >> on top of that you have nested defun=E2=80=99s. >=20 > DEFUN's cannot be nested, so we don't need to consider that. Yeah, in general C sources don=E2=80=99t have nested defuns, only C++ = ones do. I was trying to illustrate that it=E2=80=99s hard to extend = existing defun movement framework such that it handles this special = case. The best solution I can think of is what I described above. Yuan=