** Functions and variables to move by program sexps
-*** New function 'forward-sexp-default-function'.
-The previous implementation of 'forward-sexp' is moved into its
-own function, to be bound by 'forward-sexp-function'.
-
*** New function 'treesit-forward-sexp'.
Tree-sitter conditionally sets 'forward-sexp-function' for major modes
that have defined 'sexp' in 'treesit-thing-settings' to enable
(goto-char (or (scan-sexps (point) arg) (buffer-end arg)))
(if (< arg 0) (backward-prefix-chars)))
-(defvar forward-sexp-function #'forward-sexp-default-function
+(defvar forward-sexp-function nil
;; FIXME:
;; - for some uses, we may want a "sexp-only" version, which only
;; jumps over a well-formed sexp, rather than some dwimish thing
"No next sexp"
"No previous sexp"))))
(or arg (setq arg 1))
- (funcall (or forward-sexp-function
- #'forward-sexp-default-function)
- arg)))
+ (if forward-sexp-function
+ (funcall forward-sexp-function arg)
+ (forward-sexp-default-function arg))))
(defun backward-sexp (&optional arg interactive)
"Move backward across one balanced expression (sexp).
(let ((arg (or arg 1))
(pred (or treesit-sexp-type-regexp 'sexp)))
(or (when (treesit-node-match-p (treesit-node-at (point)) 'text t)
- (funcall #'forward-sexp-default-function arg)
+ (forward-sexp-default-function arg)
t)
(if (> arg 0)
(treesit-end-of-thing pred (abs arg) 'restricted)