emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[nongnu] elpa/hl-block-mode 395c7315b7 11/64: Add option to match differ


From: ELPA Syncer
Subject: [nongnu] elpa/hl-block-mode 395c7315b7 11/64: Add option to match different bracket types
Date: Thu, 7 Jul 2022 12:00:01 -0400 (EDT)

branch: elpa/hl-block-mode
commit 395c7315b71db4467965f4b0ead388e3eda6a933
Author: Campbell Barton <ideasman42@gmail.com>
Commit: Campbell Barton <ideasman42@gmail.com>

    Add option to match different bracket types
---
 hl-block-mode.el | 24 ++++++++++++++++--------
 readme.rst       | 12 +++++++++---
 2 files changed, 25 insertions(+), 11 deletions(-)

diff --git a/hl-block-mode.el b/hl-block-mode.el
index 83a9eade1c..6dd12c7f3e 100644
--- a/hl-block-mode.el
+++ b/hl-block-mode.el
@@ -36,6 +36,12 @@
 
 (require 'seq)
 
+(defcustom hl-block-bracket 123
+  "Character to use as a starting bracket (defaults to '{').
+Set to nil to use all brackets."
+  :group 'hl-block-mode
+  :type  'symbol)
+
 (defcustom hl-block-delay 0.3
   "Idle time before highlighting."
   :group 'hl-block-mode
@@ -46,27 +52,29 @@
   :group 'hl-block-mode
   :type  'float)
 
-(defun hl-block--syntax-prev-curly-brace (pt)
+(defun hl-block--syntax-prev-bracket (pt)
   "A versiong of 'syntax-ppss' to match curly braces.
 PT is typically the '(point)'."
   (let ((start (ignore-errors (elt (syntax-ppss pt) 1))))
     (when start
-      (if (char-equal ?{ (char-after start))
+      (if (char-equal hl-block-bracket (char-after start))
           start
-        (hl-block--syntax-prev-curly-brace (1- start))))))
+        (hl-block--syntax-prev-bracket (1- start))))))
 
 (defun hl-block--find-all-ranges (pt)
   "Return a list of ranges starting from PT, outer-most to inner-most."
   (let* ((start
-          ;; (ignore-errors (elt (syntax-ppss pt) 1)))  ;; works for lisp
-          (hl-block--syntax-prev-curly-brace pt))
+           ;; find brackets
+           (if hl-block-bracket
+               (hl-block--syntax-prev-bracket pt)
+             (ignore-errors (elt (syntax-ppss pt) 1))))
          (end
           (when start (or (ignore-errors (scan-sexps start 1)) pt)))
-         (range_prev
+         (range-prev
           (when start (hl-block--find-all-ranges start))))
     (when start
-      (if range_prev
-          (cons (list start end) range_prev)
+      (if range-prev
+          (cons (list start end) range-prev)
         (list (list start end))))))
 
 (defun hl-block--color-values-as-string (r g b)
diff --git a/readme.rst b/readme.rst
index 9c4a59c9a7..7b4812b3d5 100644
--- a/readme.rst
+++ b/readme.rst
@@ -9,10 +9,16 @@ This is a minor mode for highlighting blocks by scope.
 Options
 -------
 
-:hl-block-delay: (float) delay in seconds until the drawing the block scope.
-:hl-block-color-tint: (color) color tint for each level.
+:hl-block-bracket:
+   (symbol) bracket to use, ``{`` by default,
+   set to ``nil`` to match all bracket types.
+:hl-block-delay:
+   (float) delay in seconds until the drawing the block scope.
+:hl-block-color-tint:
+   (color) color tint for each level.
 
 TODO
 ----
 
-- Configurable brackets: currently only ``{}`` brackets are used.
+- Optionally, update instantly (without any delay).
+- Avoid updating overlays when highlights havn't moved.



reply via email to

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