[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.
- [nongnu] elpa/hl-block-mode 6f9dfee5f7 26/64: Cleanup: use two space indentation, (continued)
- [nongnu] elpa/hl-block-mode 6f9dfee5f7 26/64: Cleanup: use two space indentation, ELPA Syncer, 2022/07/07
- [nongnu] elpa/hl-block-mode 5436b8b210 41/64: Cleanup: minor changes to internal logic, ELPA Syncer, 2022/07/07
- [nongnu] elpa/hl-block-mode cceb66c9d7 16/64: Declare hl-block-overlay as a local variable, ELPA Syncer, 2022/07/07
- [nongnu] elpa/hl-block-mode 913447abd7 15/64: Fix typo, ELPA Syncer, 2022/07/07
- [nongnu] elpa/hl-block-mode ed833baa1a 21/64: add global mode to usage docs, ELPA Syncer, 2022/07/07
- [nongnu] elpa/hl-block-mode 6310fc8563 05/64: Create LICENSE, ELPA Syncer, 2022/07/07
- [nongnu] elpa/hl-block-mode f957c01cf8 06/64: Docs: add missing sections to header, ELPA Syncer, 2022/07/07
- [nongnu] elpa/hl-block-mode 054dc21949 08/64: Enforce use of spaces for indentation, ELPA Syncer, 2022/07/07
- [nongnu] elpa/hl-block-mode bb35a6c56b 47/64: Add hl-block-single-level & hl-block-style, ELPA Syncer, 2022/07/07
- [nongnu] elpa/hl-block-mode 54ab1d6aba 60/64: Fix bracket display highlighting a character next to (point), ELPA Syncer, 2022/07/07
- [nongnu] elpa/hl-block-mode 395c7315b7 11/64: Add option to match different bracket types,
ELPA Syncer <=
- [nongnu] elpa/hl-block-mode ed4a599ead 38/64: Cleanup: quiet checkdoc & package lint warnings, ELPA Syncer, 2022/07/07
- [nongnu] elpa/hl-block-mode 497b0ac639 48/64: Cleanup: re-order custom settings, ELPA Syncer, 2022/07/07
- [nongnu] elpa/hl-block-mode 859d3cac49 51/64: readme: update example, ELPA Syncer, 2022/07/07
- [nongnu] elpa/hl-block-mode da2870d1d7 24/64: Update readme.rst, ELPA Syncer, 2022/07/07
- [nongnu] elpa/hl-block-mode 82f42045c1 31/64: Enable lexical binding, ELPA Syncer, 2022/07/07
- [nongnu] elpa/hl-block-mode dc5b0153bb 35/64: Cleanup: byte-code compilation warnings, ELPA Syncer, 2022/07/07
- [nongnu] elpa/hl-block-mode 4e28df960d 40/64: Remove local variables when disabling the mode, ELPA Syncer, 2022/07/07
- [nongnu] elpa/hl-block-mode d47c372b06 03/64: Update readme.rst, ELPA Syncer, 2022/07/07
- [nongnu] elpa/hl-block-mode f763fff94e 09/64: Follow lisp and emacs-lisp conventions, ELPA Syncer, 2022/07/07
- [nongnu] elpa/hl-block-mode b98c83d8cb 14/64: Add global-hl-block-mode, ELPA Syncer, 2022/07/07