Clean up treesit-default-defun-skipper and add comments
* lisp/treesit.el (treesit-default-defun-skipper): Clean up, fix some small issue, add comment.
This commit is contained in:
parent
9371d488be
commit
38c35bf0f6
1 changed files with 11 additions and 7 deletions
|
@ -1744,13 +1744,17 @@ this function depends on `treesit-defun-type-regexp' and
|
||||||
This function tries to move to the beginning of a line, either by
|
This function tries to move to the beginning of a line, either by
|
||||||
moving to the empty newline after a defun, or to the beginning of
|
moving to the empty newline after a defun, or to the beginning of
|
||||||
the current line if the beginning of the defun is indented."
|
the current line if the beginning of the defun is indented."
|
||||||
(cond ((and (looking-at (rx (* (or " " "\\t")) "\n"))
|
;; Moving forward, point at the end of a line and not already on an
|
||||||
(not (looking-at (rx bol))))
|
;; empty line: go to BOL of the next line (which hopefully is an
|
||||||
(goto-char (match-end 0)))
|
;; empty line).
|
||||||
((save-excursion
|
(cond ((and (looking-at (rx (* (or " " "\t")) "\n"))
|
||||||
(skip-chars-backward " \t")
|
(not (bolp)))
|
||||||
(eq (point) (line-beginning-position)))
|
(forward-line 1))
|
||||||
(goto-char (line-beginning-position)))))
|
;; Moving backward, but there are some whitespace (and only
|
||||||
|
;; whitespace) between point and BOL: go back to BOL.
|
||||||
|
((looking-back (rx (+ (or " " "\t")))
|
||||||
|
(line-beginning-position))
|
||||||
|
(beginning-of-line))))
|
||||||
|
|
||||||
;; prev-sibling:
|
;; prev-sibling:
|
||||||
;; 1. end-of-node before pos
|
;; 1. end-of-node before pos
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue