all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Yuan Fu <casouri@gmail.com>, Theodor Thornhill <theo@thornhill.no>
Cc: 62825@debbugs.gnu.org
Subject: bug#62825: 29.0.90; c-ts-mode doesn't recognize DEFUN functions
Date: Fri, 14 Apr 2023 09:59:42 +0300	[thread overview]
Message-ID: <83v8hzeyox.fsf@gnu.org> (raw)
In-Reply-To: <831qkngdyx.fsf@gnu.org> (message from Eli Zaretskii on Fri, 14 Apr 2023 09:44:22 +0300)

> 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.





  reply	other threads:[~2023-04-14  6:59 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 [this message]
2023-04-14 20:19   ` Yuan Fu
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

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

  git send-email \
    --in-reply-to=83v8hzeyox.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=62825@debbugs.gnu.org \
    --cc=casouri@gmail.com \
    --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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.