Add new variable 'up-list-function' for 'treesit-up-list'

* lisp/emacs-lisp/lisp.el (up-list-function): New variable (bug#73404).
(up-list-default-function): New function.
(up-list): Split part to 'up-list-default-function'.

* lisp/treesit.el (treesit-up-list): New function.
(treesit-major-mode-setup): Set 'up-list-function' to
'treesit-up-list'.
This commit is contained in:
Juri Linkov 2024-12-29 19:57:28 +02:00
parent 3c50edb2b5
commit ec8dd27f00
3 changed files with 44 additions and 1 deletions

View file

@ -239,6 +239,10 @@ On error, location of point is unspecified."
(interactive "^p\nd\nd")
(up-list (- (or arg 1)) escape-strings no-syntax-crossing))
(defvar up-list-function nil
"If non-nil, `up-list' delegates to this function.
Should take the same arguments and behave similarly to `up-list'.")
(defun up-list (&optional arg escape-strings no-syntax-crossing)
"Move forward out of one level of parentheses.
This command will also work on other parentheses-like expressions
@ -255,6 +259,12 @@ end of a list broken across multiple strings.
On error, location of point is unspecified."
(interactive "^p\nd\nd")
(if up-list-function
(funcall up-list-function arg escape-strings no-syntax-crossing)
(up-list-default-function arg escape-strings no-syntax-crossing)))
(defun up-list-default-function (&optional arg escape-strings no-syntax-crossing)
"Default function for `up-list-function'."
(or arg (setq arg 1))
(let ((inc (if (> arg 0) 1 -1))
(pos nil))