From 1bed1f0b8e9095d66f905ed7b409a397f1972262 Mon Sep 17 00:00:00 2001 From: Yuan Fu Date: Mon, 7 Nov 2022 02:00:04 -0800 Subject: [PATCH] Add tree-sitter indent preset "point-min" * doc/lispref/modes.texi (Parser-based Indentation): Update manual. * lisp/treesit.el (treesit-simple-indent-presets): Add preset. Update docstring. --- doc/lispref/modes.texi | 5 +++++ lisp/treesit.el | 7 ++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/doc/lispref/modes.texi b/doc/lispref/modes.texi index 50dbec35e47..8a0b5a12a10 100644 --- a/doc/lispref/modes.texi +++ b/doc/lispref/modes.texi @@ -4937,6 +4937,11 @@ This anchor is a function that is called with 3 arguments: @var{node}, This anchor is a function that is called with 3 arguments: @var{node}, @var{parent}, and @var{bol}, and returns the first non-whitespace charater on the previous line. + +@item point-min +This anchor is a function is called with 3 arguments: @var{node}, +@var{parent}, and @var{bol}, and returns the beginning of the buffer. +This is useful as the beginning of the buffer is always at column 0. @end ftable @end defvar diff --git a/lisp/treesit.el b/lisp/treesit.el index 83f9dd1b7f1..9f4814b6033 100644 --- a/lisp/treesit.el +++ b/lisp/treesit.el @@ -998,6 +998,7 @@ See `treesit-simple-indent-presets'.") (goto-char bol) (forward-line -1) (skip-chars-forward " \t")))) + (cons 'point-min (lambda (&rest _) (point-min))) ;; TODO: Document. (cons 'and (lambda (&rest fns) (lambda (node parent bol &rest _) @@ -1082,7 +1083,11 @@ no-indent prev-line - The first non-whitespace charater on the previous line.") + The first non-whitespace charater on the previous line. + +point-min + + Returns the beginning of buffer, which is always at column 0.") (defun treesit--simple-indent-eval (exp) "Evaluate EXP. -- 2.39.5