[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/hl-block-mode 54ab1d6aba 60/64: Fix bracket display highli
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/hl-block-mode 54ab1d6aba 60/64: Fix bracket display highlighting a character next to (point) |
Date: |
Thu, 7 Jul 2022 12:00:10 -0400 (EDT) |
branch: elpa/hl-block-mode
commit 54ab1d6aba717d03f0706fdfc85aa3078547acb0
Author: Campbell Barton <ideasman42@gmail.com>
Commit: Campbell Barton <ideasman42@gmail.com>
Fix bracket display highlighting a character next to (point)
The fall-back for a missing end makes sense for a tinted
background but not for single bracket highlighting.
---
hl-block-mode.el | 25 +++++++++++++++----------
1 file changed, 15 insertions(+), 10 deletions(-)
diff --git a/hl-block-mode.el b/hl-block-mode.el
index db99379e04..c4e82ef3d0 100644
--- a/hl-block-mode.el
+++ b/hl-block-mode.el
@@ -106,7 +106,9 @@ PT is typically the '(point)'."
(t
(ignore-errors (elt (syntax-ppss pt) 1))))))
(when beg
- (let ((end (or (ignore-errors (scan-sexps beg 1)) pt)))
+ ;; Note that `end' may be nil for un-matched brackets.
+ ;; The caller must handle this case.
+ (let ((end (ignore-errors (scan-sexps beg 1))))
(cons beg end)))))
@@ -166,7 +168,7 @@ Inverse of `color-values'."
(- (aref a 2) (* tint (aref b 2)))))
-(defun hl-block--overlay-create-color-tint (block-list)
+(defun hl-block--overlay-create-color-tint (block-list end-fallback)
"Update the overlays based on the cursor location.
Argument BLOCK-LIST represents start-end ranges of braces."
(let*
@@ -179,8 +181,12 @@ Argument BLOCK-LIST represents start-end ranges of braces."
;; Iterator.
(i 0))
(pcase-let ((`(,beg-prev . ,end-prev) (pop block-list)))
+ (unless end-prev ;; May be `nil' for un-matched brackets.
+ (setq end-prev end-fallback))
(while block-list
(pcase-let ((`(,beg . ,end) (pop block-list)))
+ (unless end ;; May be `nil' for un-matched brackets.
+ (setq end end-fallback))
(let
(
(elem-overlay-beg (make-overlay beg beg-prev))
@@ -219,14 +225,13 @@ Argument BLOCK-LIST represents start-end ranges of
braces."
;; hl-block-bracket-face
(while block-list
(pcase-let ((`(,beg . ,end) (pop block-list)))
- (let
- (
- (elem-overlay-beg (make-overlay beg (1+ beg)))
- (elem-overlay-end (make-overlay (1- end) end)))
+ (let ((elem-overlay-beg (make-overlay beg (1+ beg))))
(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-beg hl-block--overlay)
+ (when end ;; May be `nil' for un-matched brackets.
+ (let ((elem-overlay-end (make-overlay (1- end) end)))
+ (overlay-put elem-overlay-end 'face hl-block-bracket-face)
+ (push elem-overlay-end hl-block--overlay)))))))
;; ---------------------------------------------------------------------------
@@ -263,7 +268,7 @@ Argument BLOCK-LIST represents start-end ranges of braces."
(reverse block-list))
(t
(cons (cons (point-min) (point-max)) block-list))))
- (hl-block--overlay-create-color-tint block-list))
+ (hl-block--overlay-create-color-tint block-list (point)))
((eq hl-block-style 'bracket)
(hl-block--overlay-create-bracket block-list))
(t
- [nongnu] elpa/hl-block-mode 877e14c064 01/64: Initial block highlighting mode., (continued)
- [nongnu] elpa/hl-block-mode 877e14c064 01/64: Initial block highlighting mode., ELPA Syncer, 2022/07/07
- [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 <=
- [nongnu] elpa/hl-block-mode 395c7315b7 11/64: Add option to match different bracket types, ELPA Syncer, 2022/07/07
- [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