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#62825: 29.0.90; c-ts-mode doesn't recognize DEFUN functions Date: Fri, 14 Apr 2023 13:19:41 -0700 Message-ID: References: <831qkngdyx.fsf@gnu.org> <83v8hzeyox.fsf@gnu.org> Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3731.500.231\)) 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="34331"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 62825@debbugs.gnu.org, Theodor Thornhill To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Apr 14 22:20:17 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 1pnPu4-0008h5-Rs for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 14 Apr 2023 22:20:16 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pnPtt-00056d-SO; Fri, 14 Apr 2023 16:20:05 -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 1pnPtr-000558-Hb for bug-gnu-emacs@gnu.org; Fri, 14 Apr 2023 16:20:03 -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 1pnPtr-00072Z-99 for bug-gnu-emacs@gnu.org; Fri, 14 Apr 2023 16:20:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pnPtq-0001G7-LX for bug-gnu-emacs@gnu.org; Fri, 14 Apr 2023 16:20: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: Fri, 14 Apr 2023 20:20:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 62825 X-GNU-PR-Package: emacs Original-Received: via spool by 62825-submit@debbugs.gnu.org id=B62825.16815036014826 (code B ref 62825); Fri, 14 Apr 2023 20:20:02 +0000 Original-Received: (at 62825) by debbugs.gnu.org; 14 Apr 2023 20:20:01 +0000 Original-Received: from localhost ([127.0.0.1]:47795 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pnPtp-0001Fj-6W for submit@debbugs.gnu.org; Fri, 14 Apr 2023 16:20:01 -0400 Original-Received: from mail-pj1-f49.google.com ([209.85.216.49]:52879) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pnPtn-0001FU-EO for 62825@debbugs.gnu.org; Fri, 14 Apr 2023 16:19:59 -0400 Original-Received: by mail-pj1-f49.google.com with SMTP id hg12so5014472pjb.2 for <62825@debbugs.gnu.org>; Fri, 14 Apr 2023 13:19:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1681503593; x=1684095593; 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=KbGWXMksJOhUN/i4M8mA0gjy8Ub+UoA9zUWRY/3J3w0=; b=KOkvNduR0sZkIOBYlNIk/LJoTDpxkE014Y/a2FZM7Kw6s+6cklPyM4jJ3g3HvmRBhH 13Tgr4Q9E8cF1476M5D1/dC/PxsK3iG+dgua9DIBjuGXgXMDn8XhUv02A2U0ZTSUzZdf 4e/GpEsQHuW+MB2F2Uv2trrWqlg0yycDOCu5MBruBbCazdQKczW6Netoewny2arMdgX4 aIaauNF9WfUcCLfFmfg0YjnQjiDtNHhoDXs6J28k2hrGqZDoM5RBhM8GBTmK9+zS0ixo oAca4yeOYgwYO7hRkU0b2q3QI2y4oOOKEV0RzKSBlU7NnoDpEvmIvrC0pBe4gAL5Gmbi CYvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681503593; x=1684095593; 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=KbGWXMksJOhUN/i4M8mA0gjy8Ub+UoA9zUWRY/3J3w0=; b=Gx2lL+Cx81Rj9nEvEMndxfwxw9bHNMig6oT/DtyaN05krzeOjNnCK7ip7SZybmxyUp 94opio4IW2Oa8W6+/aj1B/QMJ0JOcMJ7QLfAzG5klRdlbEMiP0luvJLrZrA6IxRPaZtt h+AMPkKKS+pYnwSUu2QS3ic9a27nOL9F3RGKSLELHI2UC5HG4jBWe1ugaan6yVP7sKre OrZiw0JuZRgTn7zWGFkkVSk6O1vX7aEgC9NvbNqMFGcLAOhjbY79pA0re9Szc3pIFZeH fhDk/CBXLnKO67KYdH4KsroDri2lH3BGdu4nbR54JXQLzn/PrTcNmlFEcaxqAdORbzS2 lXUQ== X-Gm-Message-State: AAQBX9f07tcEwd+7cdoEs/ti4oM8VKysBO3wr/TBFoTX5MrF+TAfswwC PqF4JcIdUT2xk26B5Q0oFnE= X-Google-Smtp-Source: AKy350a/M0uCkfrLmz4jispHpt26ox2+WRc/u+dCrgT3q4kQc/Qf0lALu5hBgya2XLZCVBzE/1H5YA== X-Received: by 2002:a17:902:ea03:b0:1a6:8442:545d with SMTP id s3-20020a170902ea0300b001a68442545dmr4360392plg.0.1681503593178; Fri, 14 Apr 2023 13:19:53 -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 je13-20020a170903264d00b001a50dcd10c8sm3413099plb.277.2023.04.14.13.19.52 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 14 Apr 2023 13:19:52 -0700 (PDT) In-Reply-To: <83v8hzeyox.fsf@gnu.org> X-Mailer: Apple Mail (2.3731.500.231) 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:259978 Archived-At: > On Apr 13, 2023, at 11:59 PM, Eli Zaretskii wrote: >=20 >> Date: Fri, 14 Apr 2023 09:44:22 +0300 >> From: Eli Zaretskii >>=20 >> Evaluating '(treesit-defun-at-point)' inside a function defined via >> the DEFUN macro yields nil, when the buffer is under c-ts-mode. This >> gets in the way of significant functionalities, like >> c-ts-mode-indent-defun and generating ChangeLog-style log entries >> using "C-x 4 a" and the likes. >>=20 >> To reproduce, visit any of the Emacs C source files, like treesit.c, >> with c-ts-mode, move point to a function defined via DEFUN, and type >> "C-x 4 a". The resulting ChangeLog entry will have the file name, = but >> not the expected function name in parentheses. >>=20 >> Please fix this ASAP, this is a bad regression for those, like = myself, >> who want to use c-ts-mode. >=20 > Using treesit-explore-mode I see that c-ts-mode regards DEFUN > functions as a sequence of 2 expression_statement nodes. Here's the > tree corresponding to the DEFUN macro call: >=20 > (expression_statement > (call_expression > function:=20 > (call_expression function: (identifier) <<<<<<<<<<<<<<<<<<< > arguments:=20 > (argument_list ( > (string_literal " ") > , (identifier) , (identifier) , (number_literal) , (number_literal) , > (number_literal) > , (identifier) > (ERROR :) > (comment) ))) > arguments:=20 > (argument_list ( (identifier) > (ERROR (identifier)) > , (identifier) > (ERROR (identifier)) > ))) > ;) >=20 > The identifier node on the line indicated with "<<<<<" is "DEFUN", so > maybe we can recognize this. The body of the DEFUN is another > compound_statement node, following the DEFUN's node. Ok, I fixed indent-defund and add-log. Because a DEFUN is made of two = nodes in the parse tree rather than one, it=E2=80=99s a bit hard to = incorporate it into the normal treesit-defun-at-point, etc, functions. = And we probably have to fix DEFUN case-by-case. Yuan