From: Yuan Fu Date: Fri, 30 Sep 2022 23:54:42 +0000 (-0700) Subject: Change tree-sitter indent anchor preset 'prev-line' X-Git-Tag: emacs-29.0.90~1866 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=e504eabe88727141e70ae9793be71d4285f839a5;p=emacs.git Change tree-sitter indent anchor preset 'prev-line' * doc/lispref/modes.texi: Update manual. * lisp/treesit.el (treesit-simple-indent-presets): Change prev-line to mean bol of prev-line. --- diff --git a/doc/lispref/modes.texi b/doc/lispref/modes.texi index d6797fe04f5..ab83d8712b2 100644 --- a/doc/lispref/modes.texi +++ b/doc/lispref/modes.texi @@ -4820,8 +4820,8 @@ This anchor returns the start of @var{node}, i.e., no indent. prev-line @end example -This anchor returns the start of the first named node on the previous -line. This can be used for indenting an empty line. +This anchor returns the first non-whitespace charater on the previous +line. @end defvar @heading Indentation utilities diff --git a/lisp/treesit.el b/lisp/treesit.el index 001404d88d2..cf586f99783 100644 --- a/lisp/treesit.el +++ b/lisp/treesit.el @@ -522,9 +522,7 @@ See `treesit-simple-indent-presets'.") (save-excursion (goto-char bol) (forward-line -1) - (skip-chars-forward " \t") - (treesit-node-start - (treesit-node-at (point) nil t)))))) + (skip-chars-forward " \t"))))) "A list of presets. These presets that can be used as MATHER and ANCHOR in `treesit-simple-indent-rules'. @@ -585,8 +583,7 @@ no-indent prev-line - Find the named node on the previous line. This can be used when - indenting an empty line: just indent like the previous node.") + The first non-whitespace charater on the previous line.") (defun treesit--simple-apply (fn args) "Apply ARGS to FN.