emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

feature/tree-sitter 1bed1f0b8e 3/3: Add tree-sitter indent preset "point


From: Yuan Fu
Subject: feature/tree-sitter 1bed1f0b8e 3/3: Add tree-sitter indent preset "point-min"
Date: Mon, 7 Nov 2022 05:15:05 -0500 (EST)

branch: feature/tree-sitter
commit 1bed1f0b8e9095d66f905ed7b409a397f1972262
Author: Yuan Fu <casouri@gmail.com>
Commit: Yuan Fu <casouri@gmail.com>

    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 50dbec35e4..8a0b5a12a1 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 83f9dd1b7f..9f4814b603 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.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]