(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"
(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
(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)
(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: