[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/hl-block-mode 2fb1cc165b 57/64: Simplify local bracket var
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/hl-block-mode 2fb1cc165b 57/64: Simplify local bracket variable use |
Date: |
Thu, 7 Jul 2022 12:00:10 -0400 (EDT) |
branch: elpa/hl-block-mode
commit 2fb1cc165b24c45f1a0d1ae1453008a920c6436a
Author: Campbell Barton <ideasman42@gmail.com>
Commit: Campbell Barton <ideasman42@gmail.com>
Simplify local bracket variable use
---
hl-block-mode.el | 51 +++++++++++++++++++++++----------------------------
1 file changed, 23 insertions(+), 28 deletions(-)
diff --git a/hl-block-mode.el b/hl-block-mode.el
index 4c013e0e49..f7da776ad3 100644
--- a/hl-block-mode.el
+++ b/hl-block-mode.el
@@ -41,7 +41,7 @@
(defgroup hl-block nil "Highlight nested blocks or brackets." :group
'convenience)
-(defcustom hl-block-bracket ?{
+(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)
@@ -82,10 +82,7 @@ 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)
-
+(defvar-local hl-block--overlay nil)
;; ---------------------------------------------------------------------------
;; Internal Bracket Functions
@@ -96,7 +93,7 @@ PT is typically the '(point)'."
(let ((beg (ignore-errors (elt (syntax-ppss pt) 1))))
(when beg
(cond
- ((memq (char-after beg) hl-block-bracket-local)
+ ((memq (char-after beg) hl-block-bracket)
beg)
(t
(hl-block--syntax-prev-bracket (1- beg)))))))
@@ -108,7 +105,7 @@ PT is typically the '(point)'."
(
(beg
(cond
- (hl-block-bracket-local
+ (hl-block-bracket
(hl-block--syntax-prev-bracket pt))
(t
(ignore-errors (elt (syntax-ppss pt) 1))))))
@@ -210,8 +207,8 @@ Argument BLOCK-LIST represents start-end ranges of braces."
(overlay-put elem-overlay-beg 'face hl-face)
(overlay-put elem-overlay-end 'face hl-face))
- (push elem-overlay-beg hl-block-overlay)
- (push elem-overlay-end hl-block-overlay)
+ (push elem-overlay-beg hl-block--overlay)
+ (push elem-overlay-end hl-block--overlay)
(setq beg-prev beg)
(setq end-prev end))
(setq i (1+ i)))))))
@@ -232,8 +229,8 @@ Argument BLOCK-LIST represents start-end ranges of braces."
(elem-overlay-end (make-overlay (1- end) end)))
(overlay-put elem-overlay-beg 'face hl-block-bracket-face)
(overlay-put elem-overlay-end 'face hl-block-bracket-face)
- (push elem-overlay-end hl-block-overlay)
- (push elem-overlay-beg hl-block-overlay)))))
+ (push elem-overlay-end hl-block--overlay)
+ (push elem-overlay-beg hl-block--overlay)))))
;; ---------------------------------------------------------------------------
@@ -241,8 +238,8 @@ Argument BLOCK-LIST represents start-end ranges of braces."
(defun hl-block--overlay-clear ()
"Clear all overlays."
- (mapc 'delete-overlay hl-block-overlay)
- (setq hl-block-overlay nil))
+ (mapc 'delete-overlay hl-block--overlay)
+ (setq hl-block--overlay nil))
(defun hl-block--overlay-refresh ()
@@ -388,26 +385,24 @@ Argument BLOCK-LIST represents start-end ranges of
braces."
;; 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)))
+ (let ((bracket-orig hl-block-bracket))
+ ;; 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)))
(when (eq ?\( (char-syntax ch))
- (push ch hl-block-bracket-local)))))))
+ (push ch hl-block-bracket)))))))
(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)
+ (kill-local-variable 'hl-block--overlay)
+ (kill-local-variable 'hl-block-bracket)
(hl-block--time-buffer-local-disable))
(defun hl-block-mode-turn-on ()
- [nongnu] elpa/hl-block-mode 9c5ee70df6 17/64: Cleanup: checkdoc warnings, (continued)
- [nongnu] elpa/hl-block-mode 9c5ee70df6 17/64: Cleanup: checkdoc warnings, ELPA Syncer, 2022/07/07
- [nongnu] elpa/hl-block-mode 83059c1050 18/64: Cleanup: use package prefix, ELPA Syncer, 2022/07/07
- [nongnu] elpa/hl-block-mode 047f9a972c 20/64: fix byte-compile nag, ELPA Syncer, 2022/07/07
- [nongnu] elpa/hl-block-mode 05a8c5119c 32/64: readme: link to melpa, tweaks to syntax highlighting, ELPA Syncer, 2022/07/07
- [nongnu] elpa/hl-block-mode 72840769e9 37/64: Cleanup: remove use of 'post-command-hook', ELPA Syncer, 2022/07/07
- [nongnu] elpa/hl-block-mode 4a73d23ae2 43/64: Cleanup: over wide doc-string, ELPA Syncer, 2022/07/07
- [nongnu] elpa/hl-block-mode bd54144b34 49/64: Cleanup: re-organize sections, ELPA Syncer, 2022/07/07
- [nongnu] elpa/hl-block-mode 333490cf2d 45/64: Add hl-block-multi-line option, ELPA Syncer, 2022/07/07
- [nongnu] elpa/hl-block-mode 3c49f80ada 50/64: Cleanup: replace 'if' with 'cond', ELPA Syncer, 2022/07/07
- [nongnu] elpa/hl-block-mode f2ec1f167a 46/64: Correct type of hl-block-color-tint, ELPA Syncer, 2022/07/07
- [nongnu] elpa/hl-block-mode 2fb1cc165b 57/64: Simplify local bracket variable use,
ELPA Syncer <=
- [nongnu] elpa/hl-block-mode 7e0452c768 64/64: Change URL to codeberg, ELPA Syncer, 2022/07/07
- [nongnu] elpa/hl-block-mode a1c03970a0 59/64: Remove unnecessary requirement `seq`, ELPA Syncer, 2022/07/07
- [nongnu] elpa/hl-block-mode d7e274c3f1 04/64: Update readme.rst, ELPA Syncer, 2022/07/07
- [nongnu] elpa/hl-block-mode e7b5b014c9 10/64: Fix: localize hook & timer running when it shouldn't, ELPA Syncer, 2022/07/07
- [nongnu] elpa/hl-block-mode 28c9950a90 25/64: Fix for emacs 27, change in line highlighting, ELPA Syncer, 2022/07/07
- [nongnu] elpa/hl-block-mode c6341f404e 44/64: Cleanup: store range data in cons cells instead of lists, ELPA Syncer, 2022/07/07
- [nongnu] elpa/hl-block-mode e7ab79e713 36/64: Cleanup: add code-sections, ELPA Syncer, 2022/07/07
- [nongnu] elpa/hl-block-mode 7e0c6954f9 52/64: readme: document draw styles, ELPA Syncer, 2022/07/07
- [nongnu] elpa/hl-block-mode d080364c64 58/64: Use a string for hl-block-bracket characters, ELPA Syncer, 2022/07/07
- [nongnu] elpa/hl-block-mode 3dd29cfbf2 63/64: Cleanup: use brief SPDX license, ELPA Syncer, 2022/07/07