unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Yuan Fu <casouri@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 62825@debbugs.gnu.org, Theodor Thornhill <theo@thornhill.no>
Subject: bug#62825: 29.0.90; c-ts-mode doesn't recognize DEFUN functions
Date: Fri, 14 Apr 2023 13:19:41 -0700	[thread overview]
Message-ID: <E23597F9-F868-4D04-B814-52B43427DA3D@gmail.com> (raw)
In-Reply-To: <83v8hzeyox.fsf@gnu.org>



> On Apr 13, 2023, at 11:59 PM, Eli Zaretskii <eliz@gnu.org> wrote:
> 
>> Date: Fri, 14 Apr 2023 09:44:22 +0300
>> From: Eli Zaretskii <eliz@gnu.org>
>> 
>> 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.
>> 
>> 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.
>> 
>> Please fix this ASAP, this is a bad regression for those, like myself,
>> who want to use c-ts-mode.
> 
> 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:
> 
>  (expression_statement
>   (call_expression
>    function: 
>     (call_expression function: (identifier) <<<<<<<<<<<<<<<<<<<
>      arguments: 
>       (argument_list (
> (string_literal " ")
> , (identifier) , (identifier) , (number_literal) , (number_literal) ,
>      (number_literal)
> , (identifier)
> (ERROR :)
> (comment) )))
>    arguments: 
>     (argument_list ( (identifier)
>      (ERROR (identifier))
>      , (identifier)
>      (ERROR (identifier))
>      )))
>   ;)
> 
> 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’s 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






  reply	other threads:[~2023-04-14 20:19 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-14  6:44 bug#62825: 29.0.90; c-ts-mode doesn't recognize DEFUN functions Eli Zaretskii
2023-04-14  6:59 ` Eli Zaretskii
2023-04-14 20:19   ` Yuan Fu [this message]
2023-04-15  7:48     ` Eli Zaretskii
2023-04-16  5:37 ` Yuan Fu
2023-04-16  8:14   ` Eli Zaretskii
2023-04-19 19:11     ` Yuan Fu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=E23597F9-F868-4D04-B814-52B43427DA3D@gmail.com \
    --to=casouri@gmail.com \
    --cc=62825@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=theo@thornhill.no \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).