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: Tue, 4 Jul 2023 01:41:22 -0700 Message-ID: References: <83a5wcncj8.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="5793"; 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 Tue Jul 04 10:42:23 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 1qGbc7-0001FO-GC for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 04 Jul 2023 10:42:23 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qGbbt-0001yJ-Bk; Tue, 04 Jul 2023 04:42:09 -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 1qGbbn-0001tB-E9 for bug-gnu-emacs@gnu.org; Tue, 04 Jul 2023 04:42:04 -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 1qGbbn-0000D7-4Q for bug-gnu-emacs@gnu.org; Tue, 04 Jul 2023 04:42:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qGbbm-0001nn-KD for bug-gnu-emacs@gnu.org; Tue, 04 Jul 2023 04:42:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Yuan Fu Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 04 Jul 2023 08:42:02 +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.16884601076906 (code B ref 64442); Tue, 04 Jul 2023 08:42:02 +0000 Original-Received: (at 64442) by debbugs.gnu.org; 4 Jul 2023 08:41:47 +0000 Original-Received: from localhost ([127.0.0.1]:34997 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qGbbX-0001nK-6E for submit@debbugs.gnu.org; Tue, 04 Jul 2023 04:41:47 -0400 Original-Received: from mail-pf1-f170.google.com ([209.85.210.170]:58387) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qGbbS-0001n1-3p for 64442@debbugs.gnu.org; Tue, 04 Jul 2023 04:41:45 -0400 Original-Received: by mail-pf1-f170.google.com with SMTP id d2e1a72fcca58-668704a5b5bso4100688b3a.0 for <64442@debbugs.gnu.org>; Tue, 04 Jul 2023 01:41:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1688460096; x=1691052096; 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=dA5hh/Qn/H6AsS924MDXD9EQqAR8/e4vvhelI2e0feY=; b=PF/tJhQGNYGVVJIKdRBYQ3pGZaILBBlYUVBwsu/g4xjAobjfAfeB924pERGv4S1CCV i5WCNvdPG+PsGyMGOL7gVax1kdb7/4Gfi1qu9ykC4Jy2hmW/vx4VyTsdgILQD/AwCQUI yz3FwDHzbkxBkGAhirv9sSeJIH7AOuAc5hRPFDYdD+8fQCidmpkDYURAz7iPYzx71u4b SZ9FOM2Htaj44vUHSDAb13Yq//lZEUQf7SfHa3Mhl/ZuKL6Th4XHwVLNh9DsdE+B5am+ wMua9/5vgsEXIZoRUWtV8kkZzkqHzn+kaUNRjY54hM9PpIY3ptx+4PsnhAvnmWQPY5m2 +8+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688460096; x=1691052096; 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=dA5hh/Qn/H6AsS924MDXD9EQqAR8/e4vvhelI2e0feY=; b=UJDnoUKYO6vvpyatQHISJrtpO1ja7zdxFEwGFi9Xz5RcGZgweOWLePW6vSxjvneCim OXW0hV7aHiX9jw64k2duZ89p9HcpzRDUwA/1UTNvBDlYfGj7/q9WS00JL/K9ylwHsFpk pcNeSsYJRArR5pDBH8+WD2N+BnvVg2unBhe1QdnBGwf2o2Q/C4SuG8JTtAS3LX7lcXtM pMyeZ8K14IykfYA+GrVgzB3KAbCgJcrx9rg2VVcEelSNYQmKgw98KYq/nfq1tA+ncWz2 K9aVNAaooIqPELey6actWzR2j3YYpGC19rMEoujYpw1F/r5U4Qrr5b2uF3ADuttx0evH SHUA== X-Gm-Message-State: AC+VfDxuhyPb7I0Ua9jWhD+wiEXSC0JK8BKLM8J184T+UFfbbG4Ch1/z i8A81U2qcztx6BjNIXYEXB/1B7zfUZQ= X-Google-Smtp-Source: ACHHUZ55luJV07ieiQ9b330vCzJfPCqLeWdmNZbxvaV5ag2yz1Hq11YZShRCKXRxltOOqD6aHVJ94A== X-Received: by 2002:a05:6a20:6a0c:b0:127:6bda:a2ae with SMTP id p12-20020a056a206a0c00b001276bdaa2aemr17165011pzk.10.1688460095677; Tue, 04 Jul 2023 01:41:35 -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 c184-20020a621cc1000000b0066875f17266sm5706210pfc.135.2023.07.04.01.41.35 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 04 Jul 2023 01:41:35 -0700 (PDT) In-Reply-To: <83a5wcncj8.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:264567 Archived-At: > On Jul 3, 2023, at 10:13 AM, Eli Zaretskii wrote: >=20 > To reproduce: >=20 > emacs -Q > C-x C-f src/dispnew.c RET > M-x c-ts-mode RET > C-u 220 M-g g > C-M-a >=20 > Observe that instead of going to the beginning of > dump-redisplay-history, the function to which line 220 of dispnew.c > belongs, point goes to the beginning of the previous function, which > happens to be add_frame_display_history. >=20 > Can we please fix treesit-beginning-of-defun such that it recognizes C > functions defined via DEFUN? I=E2=80=99ve tried it when I was fixing fontification for DEFUN, but = ultimately gave up. The tree-sitter defun movement functions searches = for defun nodes bottom-up, and goes to the beginning or end of that = node.=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 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. 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=99s= four movement types; on top of that you have nested defun=E2=80=99s. Yuan=