[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/hl-block-mode 59458a4b2b 54/64: Initialize brackets from t
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/hl-block-mode 59458a4b2b 54/64: Initialize brackets from the syntax table |
Date: |
Thu, 7 Jul 2022 12:00:09 -0400 (EDT) |
branch: elpa/hl-block-mode
commit 59458a4b2b0991f990777f19ae2300a5b475764b
Author: Campbell Barton <ideasman42@gmail.com>
Commit: Campbell Barton <ideasman42@gmail.com>
Initialize brackets from the syntax table
This causes elisp brackets to work by default,
since the default bracket isn't considered a bracket,
which falls back to all brackets.
---
hl-block-mode.el | 30 +++++++++++++++++++++++++-----
readme.rst | 4 +++-
2 files changed, 28 insertions(+), 6 deletions(-)
diff --git a/hl-block-mode.el b/hl-block-mode.el
index be0f9ba3f5..4801784654 100644
--- a/hl-block-mode.el
+++ b/hl-block-mode.el
@@ -40,8 +40,8 @@
;; Custom Variables
(defcustom hl-block-bracket ?{
- "Character to use as a starting bracket (defaults to '{').
-Set to nil to use all brackets."
+ "Characters to use as a starting bracket (defaults to '{').
+Set to nil to use all brackets, a list of starting brackets is also supported."
:group 'hl-block-mode
:type 'symbol)
@@ -93,6 +93,8 @@ Useful for languages that use S-expressions to avoid overly
nested highlighting.
;; Internal Variables
(defvar-local hl-block-overlay nil)
+;; Created when the mode is enabled (based on the syntax table).
+(defvar-local hl-block-bracket-local nil)
;; ---------------------------------------------------------------------------
@@ -104,7 +106,7 @@ PT is typically the '(point)'."
(let ((beg (ignore-errors (elt (syntax-ppss pt) 1))))
(when beg
(cond
- ((char-equal hl-block-bracket (char-after beg))
+ ((memq (char-after beg) hl-block-bracket-local)
beg)
(t
(hl-block--syntax-prev-bracket (1- beg)))))))
@@ -116,7 +118,7 @@ PT is typically the '(point)'."
(
(beg
(cond
- (hl-block-bracket
+ (hl-block-bracket-local
(hl-block--syntax-prev-bracket pt))
(t
(ignore-errors (elt (syntax-ppss pt) 1))))))
@@ -392,12 +394,30 @@ Argument BLOCK-LIST represents start-end ranges of
braces."
(defun hl-block-mode-enable ()
"Turn on 'hl-block-mode' for the current buffer."
- (hl-block--time-buffer-local-enable))
+ (hl-block--time-buffer-local-enable)
+
+ ;; Setup brackets:
+ ;; Keep as nil to match all brackets.
+ (setq hl-block-bracket-local nil)
+ (when hl-block-bracket
+ (let
+ (
+ (bracket-list
+ (cond
+ ((listp hl-block-bracket)
+ hl-block-bracket)
+ (t
+ (list hl-block-bracket)))))
+ (while bracket-list
+ (let ((ch (pop bracket-list)))
+ (when (eq ?\( (char-syntax ch))
+ (push ch hl-block-bracket-local)))))))
(defun hl-block-mode-disable ()
"Turn off 'hl-block-mode' for the current buffer."
(hl-block--overlay-clear)
(kill-local-variable 'hl-block-overlay)
+ (kill-local-variable 'hl-block-bracket-local)
(hl-block--time-buffer-local-disable))
(defun hl-block-mode-turn-on ()
diff --git a/readme.rst b/readme.rst
index 88b7770b64..c661ee6763 100644
--- a/readme.rst
+++ b/readme.rst
@@ -14,7 +14,9 @@ Options
=======
``hl-block-bracket``: ``{``.
- (symbol) bracket to use, set to ``nil`` to match all bracket types.
+ (character) bracket to use, set to ``nil`` to match all bracket types.
+
+ A list of characters is also supported.
``hl-block-delay``: ``0.2``
(float) delay in seconds until the drawing the block scope.
``hl-block-multi-line``: ``t``
- [nongnu] elpa/hl-block-mode f763fff94e 09/64: Follow lisp and emacs-lisp conventions, (continued)
- [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
- [nongnu] elpa/hl-block-mode 326e026b66 13/64: Use character literal for '{', ELPA Syncer, 2022/07/07
- [nongnu] elpa/hl-block-mode 9f39593c4f 19/64: make hl-bock-mode lighter customizable, ELPA Syncer, 2022/07/07
- [nongnu] elpa/hl-block-mode 00914d2938 22/64: Reduce default delay to 200ms, ELPA Syncer, 2022/07/07
- [nongnu] elpa/hl-block-mode 74b5a89360 23/64: FIx typo, ELPA Syncer, 2022/07/07
- [nongnu] elpa/hl-block-mode 0f1abe46d5 27/64: Apply auto-format, ELPA Syncer, 2022/07/07
- [nongnu] elpa/hl-block-mode 59cdbd4d27 39/64: Use "push" instead of add-to-list, ELPA Syncer, 2022/07/07
- [nongnu] elpa/hl-block-mode 0ea43d3202 34/64: Cleanup: disable auto-load for internal function, ELPA Syncer, 2022/07/07
- [nongnu] elpa/hl-block-mode 27e3ab4195 42/64: Cleanup: minor naming changes, ELPA Syncer, 2022/07/07
- [nongnu] elpa/hl-block-mode 59458a4b2b 54/64: Initialize brackets from the syntax table,
ELPA Syncer <=
- [nongnu] elpa/hl-block-mode 81c692d654 55/64: Cleanup: define a group with defgroup, ELPA Syncer, 2022/07/07
- [nongnu] elpa/hl-block-mode a165ce51fb 56/64: Fix bracket draw style highlighting point-min/max, ELPA Syncer, 2022/07/07
- [nongnu] elpa/hl-block-mode 5f532fef33 12/64: Cleanup: indentation, ELPA Syncer, 2022/07/07
- [nongnu] elpa/hl-block-mode 6a8f871d7a 28/64: Add .elisp-autofmt to enable auto-formatting, ELPA Syncer, 2022/07/07
- [nongnu] elpa/hl-block-mode c85c9335f7 07/64: Cleanup: warnings, docs, ELPA Syncer, 2022/07/07
- [nongnu] elpa/hl-block-mode 6dc75e71b0 29/64: Fix global-hl-block-mode activating with the minibuffer, ELPA Syncer, 2022/07/07
- [nongnu] elpa/hl-block-mode 6c74034246 30/64: Update URL, ELPA Syncer, 2022/07/07
- [nongnu] elpa/hl-block-mode 717b4f743c 33/64: Cleanup: use group for hl-block-mode, ELPA Syncer, 2022/07/07
- [nongnu] elpa/hl-block-mode 618c0a78ef 53/64: Correct bracket face, ELPA Syncer, 2022/07/07
- [nongnu] elpa/hl-block-mode b2f1c058be 61/64: Cleanup: remove redundant group, ELPA Syncer, 2022/07/07