1
1
Fork 0

Use a string for hl-block-bracket characters

This commit is contained in:
Campbell Barton 2021-10-06 00:18:09 +11:00
parent 2fb1cc165b
commit d080364c64
2 changed files with 10 additions and 15 deletions

View file

@ -41,10 +41,9 @@
(defgroup hl-block nil "Highlight nested blocks or brackets." :group 'convenience)
(defcustom hl-block-bracket ?\{
"Characters to use as a starting bracket (defaults to '{').
Set to nil to use all brackets, a list of starting brackets is also supported."
:type 'symbol)
(defcustom hl-block-bracket "{"
"Characters to use as a starting bracket. Set to nil to use all brackets."
:type '(or null string))
(defcustom hl-block-delay 0.2 "Idle time to wait before highlighting (in seconds)." :type 'float)
@ -72,7 +71,7 @@ Useful for languages that use S-expressions to avoid overly nested highlighting.
:type 'color)
;; For `bracket' draw style.
(defcustom hl-block-bracket-face '(t (:inverse-video t))
(defcustom hl-block-bracket-face '(:inverse-video t)
"Face used when `hl-block-style' is set to `bracket'."
:type 'face)
@ -384,14 +383,12 @@ Argument BLOCK-LIST represents start-end ranges of braces."
(hl-block--time-buffer-local-enable)
;; Setup brackets:
;; Keep as nil to match all brackets.
(let ((bracket-orig hl-block-bracket))
;; Keep as nil to match all brackets,
;; use a string to convert the string to a list.
(let ((bracket-orig (append hl-block-bracket nil)))
;; Make a local, sanitized version of this variable.
(setq-local hl-block-bracket nil)
(when bracket-orig
;; Support single values.
(unless (listp bracket-orig)
(setq bracket-orig (list bracket-orig)))
;; Filter for recognized values.
(while bracket-orig
(let ((ch (pop bracket-orig)))

View file

@ -13,10 +13,8 @@ Available via `melpa <https://melpa.org/#/hl-block-mode>`__.
Options
=======
``hl-block-bracket``: ``{``.
(character) bracket to use, set to ``nil`` to match all bracket types.
A list of characters is also supported.
``hl-block-bracket``: ``"{"``.
(string or null) bracket to use, set to ``nil`` to match all bracket types.
``hl-block-delay``: ``0.2``
(float) delay in seconds until the drawing the block scope.
``hl-block-multi-line``: ``t``
@ -35,7 +33,7 @@ Options
``'bracket``:
Highlight each bracket using a custom face, without changing the background.
``hl-block-bracket-face``: ``'((t (:inverse-video t)))``
``hl-block-bracket-face``: ``'(t (:inverse-video t))``
The face used to highlight brackets.