mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-03-15 19:31:29 -07:00
Improve treesit list navigation support for #if/#endif (bug#73404)
* lisp/treesit.el (treesit--forward-list-with-default): Improve to better support the case when point is inside an opening/closing node with a name longer than 1 character such as "#if" and "#endif". (treesit-navigate-thing): No need to check for thing 'list' since list commands now use other functions. * lisp/progmodes/c-ts-mode.el (c-ts-mode--thing-settings): Add more preproc nodes such as #if/#endif and #ifdef/#endif and their variants to the 'list' thing.
This commit is contained in:
parent
fafcc8458e
commit
db4bf410f2
2 changed files with 17 additions and 9 deletions
|
|
@ -1153,6 +1153,14 @@ if `c-ts-mode-emacs-sources-support' is non-nil."
|
|||
(sexp (not ,(rx (or "{" "}" "[" "]" "(" ")" ","))))
|
||||
(list
|
||||
,(regexp-opt '("preproc_params"
|
||||
"preproc_if"
|
||||
"preproc_ifdef"
|
||||
"preproc_if_in_field_declaration_list"
|
||||
"preproc_ifdef_in_field_declaration_list"
|
||||
"preproc_if_in_enumerator_list"
|
||||
"preproc_ifdef_in_enumerator_list"
|
||||
"preproc_if_in_enumerator_list_no_comma"
|
||||
"preproc_ifdef_in_enumerator_list_no_comma"
|
||||
"preproc_parenthesized_expression"
|
||||
"preproc_argument_list"
|
||||
"attribute_declaration"
|
||||
|
|
|
|||
|
|
@ -2489,11 +2489,13 @@ ARG is described in the docstring of `forward-list'."
|
|||
(funcall default-function inc)
|
||||
(point))
|
||||
(scan-error nil)))
|
||||
(parent (treesit-thing-at (point) pred t))
|
||||
(sibling (if (> arg 0)
|
||||
(treesit-thing-next (point) pred)
|
||||
(treesit-thing-prev (point) pred)))
|
||||
(current (when default-pos
|
||||
(treesit-thing-at (point) pred t))))
|
||||
(treesit-thing-prev (point) pred))))
|
||||
(when (and parent sibling
|
||||
(not (treesit-node-enclosed-p sibling parent)))
|
||||
(setq sibling nil))
|
||||
;; Use the default function only if it doesn't go
|
||||
;; over the sibling and doesn't go out of the current group.
|
||||
(or (when (and default-pos
|
||||
|
|
@ -2501,10 +2503,10 @@ ARG is described in the docstring of `forward-list'."
|
|||
(if (> arg 0)
|
||||
(<= default-pos (treesit-node-start sibling))
|
||||
(>= default-pos (treesit-node-end sibling))))
|
||||
(or (null current)
|
||||
(or (null parent)
|
||||
(if (> arg 0)
|
||||
(<= default-pos (treesit-node-end current))
|
||||
(>= default-pos (treesit-node-start current)))))
|
||||
(< default-pos (treesit-node-end parent))
|
||||
(> default-pos (treesit-node-start parent)))))
|
||||
(goto-char default-pos))
|
||||
(when sibling
|
||||
(goto-char (if (> arg 0)
|
||||
|
|
@ -3078,9 +3080,7 @@ function is called recursively."
|
|||
(if (eq tactic 'restricted)
|
||||
(setq pos (funcall
|
||||
advance
|
||||
(cond ((and (null next) (null prev)
|
||||
(not (eq thing 'list)))
|
||||
parent)
|
||||
(cond ((and (null next) (null prev)) parent)
|
||||
((> arg 0) next)
|
||||
(t prev))))
|
||||
;; For `nested', it's a bit more work:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue