]> git.eshelyaron.com Git - emacs.git/commit
Support defun navigation for DEFUN in c-ts-mode (bug#64442)
authorYuan Fu <casouri@gmail.com>
Thu, 10 Aug 2023 21:27:29 +0000 (14:27 -0700)
committerYuan Fu <casouri@gmail.com>
Sat, 19 Aug 2023 21:55:32 +0000 (14:55 -0700)
commitbaeb2d71ae7720c5335cd11aefa752f24374fa92
tree84a9625a5a41e75928cf7bbcabb53a7ce2f231f0
parent781ddd7e7d87de150d74d6d8615c25e68b42275b
Support defun navigation for DEFUN in c-ts-mode (bug#64442)

Before this change, beginning/end-of-defun just ignores DEFUN in
c-ts-mode. After this change, beginning/end-of-defun can recognize
DEFUN, but a DEFUN definition is considered two defuns. Eg,
beginning/end-of-defun will stop at (1) (2) and (3) in the following
snippet:

(1)DEFUN ("treesit-node-parser",
       Ftreesit_node_parser, Streesit_node_parser,
       1, 1, 0,
       doc: /* Return the parser to which NODE belongs.  */)
  (Lisp_Object node)
(2){
  CHECK_TS_NODE (node);
  return XTS_NODE (node)->parser;
}
(3)

Ideally we want point to only stop at (1) and (3), but that'll be a
lot harder to do.

* lisp/progmodes/c-ts-mode.el:
(c-ts-mode--defun-valid-p): Refactor to take in account of DEFUN body.
(c-ts-mode--emacs-defun-body-p): New function.
(c-ts-base-mode): Add DEFUN and DEFUN body to recognized types.
(c-ts-mode--emacs-defun-at-point): Now that we recognize both parts of
a DEFUN as defun, c-ts-mode--emacs-defun-at-point needs to be updated
to adapt to it.
lisp/progmodes/c-ts-mode.el