emacs-diffs
[Top][All Lists]
Advanced

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

emacs-29 893c344b4e4: Fix the use of adaptive-fill-regexp in treesit ind


From: Yuan Fu
Subject: emacs-29 893c344b4e4: Fix the use of adaptive-fill-regexp in treesit indent preset
Date: Sun, 22 Oct 2023 00:13:54 -0400 (EDT)

branch: emacs-29
commit 893c344b4e4787949f65c842536e0a5597e537c8
Author: Yuan Fu <casouri@gmail.com>
Commit: Yuan Fu <casouri@gmail.com>

    Fix the use of adaptive-fill-regexp in treesit indent preset
    
    * lisp/treesit.el (treesit-simple-indent-presets):
    adaptive-fill-regexp don't have a capture group (the group in the
    default value is supposed to be a non-capture group), so don't use the
    group. Also, in the second diff hunk, replace looking-at with
    looking-at-p so it doesn't override match data that we use later.
---
 lisp/treesit.el | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/lisp/treesit.el b/lisp/treesit.el
index 18a6131b71d..c37e7b6b5b7 100644
--- a/lisp/treesit.el
+++ b/lisp/treesit.el
@@ -1217,8 +1217,10 @@ See `treesit-simple-indent-presets'.")
 
                     (goto-char bol)
                     (setq this-line-has-prefix
-                          (and (looking-at adaptive-fill-regexp)
-                               (match-string 1)))
+                          (and (looking-at-p adaptive-fill-regexp)
+                               (not (string-match-p
+                                     (rx bos (* whitespace) eos)
+                                     (match-string 0)))))
 
                     (forward-line -1)
                     (and (>= (point) comment-start-bol)
@@ -1226,7 +1228,7 @@ See `treesit-simple-indent-presets'.")
                          (looking-at adaptive-fill-regexp)
                          ;; If previous line is an empty line, don't
                          ;; indent.
-                         (not (looking-at (rx (* whitespace) eol)))
+                         (not (looking-at-p (rx (* whitespace) eol)))
                          ;; Return the anchor.  If the indenting line
                          ;; has a prefix and the previous line also
                          ;; has a prefix, indent to the beginning of



reply via email to

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