[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/highlight-parentheses c38885b 31/49: Merge pull request #1
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/highlight-parentheses c38885b 31/49: Merge pull request #18 from Bad-ptr/master |
Date: |
Sun, 15 Aug 2021 03:57:47 -0400 (EDT) |
branch: elpa/highlight-parentheses
commit c38885bba4f174c0a2cad3a60fe12b7cf8699aa1
Merge: a821a31 69c694a
Author: Tassilo Horn <tsdh@gnu.org>
Commit: GitHub <noreply@github.com>
Merge pull request #18 from Bad-ptr/master
Delete overlays when needed, face attributes for parens.
---
highlight-parentheses.el | 58 +++++++++++++++++++++++++++++++++++-------------
1 file changed, 43 insertions(+), 15 deletions(-)
diff --git a/highlight-parentheses.el b/highlight-parentheses.el
index 1f40161..bdffd37 100644
--- a/highlight-parentheses.el
+++ b/highlight-parentheses.el
@@ -50,15 +50,22 @@
(defcustom hl-paren-colors
'("firebrick1" "IndianRed1" "IndianRed3" "IndianRed4")
"List of colors for the highlighted parentheses.
-The list starts with the the inside parentheses and moves outwards."
- :type '(repeat color)
+The list starts with the inside parentheses and moves outwards."
+ :type '(choice (repeat color) function)
:set 'hl-paren-set
:group 'highlight-parentheses)
(defcustom hl-paren-background-colors nil
"List of colors for the background highlighted parentheses.
-The list starts with the the inside parentheses and moves outwards."
- :type '(repeat color)
+The list starts with the inside parentheses and moves outwards."
+ :type '(choice (repeat color) function)
+ :set 'hl-paren-set
+ :group 'highlight-parentheses)
+
+(defcustom hl-paren-attributes nil
+ "List of face attributes for the highlighted parentheses.
+The list starts with the inside parentheses and moves outwards."
+ :type '(choice plist function)
:set 'hl-paren-set
:group 'highlight-parentheses)
@@ -83,6 +90,9 @@ This is used to prevent analyzing the same context over and
over.")
"A timer initiating the movement of the `hl-paren-overlays'.")
(make-variable-buffer-local 'hl-paren-timer)
+(defun* hl-paren-delete-overlays (&optional (overlays hl-paren-overlays))
+ (mapc #'delete-overlay overlays))
+
(defun hl-paren-highlight ()
"Highlight the parentheses around point."
(unless (= (point) hl-paren-last-point)
@@ -99,7 +109,7 @@ This is used to prevent analyzing the same context over and
over.")
(move-overlay (pop overlays) (1- pos2) pos2)))
(error nil))
(goto-char pos))
- (mapc #'delete-overlay overlays))))
+ (hl-paren-delete-overlays overlays))))
(defcustom hl-paren-delay 0.137
"Fraction of seconds after which the `hl-paren-overlays' are adjusted.
@@ -120,17 +130,21 @@ overlays when scrolling or moving point by pressing and
holding
(define-minor-mode highlight-parentheses-mode
"Minor mode to highlight the surrounding parentheses."
nil " hl-p" nil
- (mapc 'delete-overlay hl-paren-overlays)
+ (hl-paren-delete-overlays)
(kill-local-variable 'hl-paren-overlays)
(kill-local-variable 'hl-paren-last-point)
(remove-hook 'post-command-hook 'hl-paren-initiate-highlight t)
+ (remove-hook 'before-revert-hook 'hl-paren-delete-overlays)
+ (remove-hook 'change-major-mode-hook 'hl-paren-delete-overlays)
(when (and highlight-parentheses-mode
;; Don't enable in *Messages* buffer.
;; https://github.com/tsdh/highlight-parentheses.el/issues/14
(not (eq major-mode 'messages-buffer-mode))
(not (string= (buffer-name) "*Messages*")))
(hl-paren-create-overlays)
- (add-hook 'post-command-hook 'hl-paren-initiate-highlight nil t)))
+ (add-hook 'post-command-hook 'hl-paren-initiate-highlight nil t)
+ (add-hook 'before-revert-hook 'hl-paren-delete-overlays)
+ (add-hook 'change-major-mode-hook 'hl-paren-delete-overlays)))
;;;###autoload
(define-globalized-minor-mode global-highlight-parentheses-mode
@@ -140,17 +154,31 @@ overlays when scrolling or moving point by pressing and
holding
;;; overlays
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun hl-paren-create-overlays ()
- (let ((fg hl-paren-colors)
- (bg hl-paren-background-colors)
+ (let ((fg (if (functionp hl-paren-colors)
+ (funcall hl-paren-colors)
+ hl-paren-colors))
+ (bg (if (functionp hl-paren-background-colors)
+ (funcall hl-paren-background-colors)
+ hl-paren-background-colors))
+ (attr (if (functionp hl-paren-attributes)
+ (funcall hl-paren-attributes)
+ hl-paren-attributes))
attributes)
- (while (or fg bg)
+ (while (or fg bg attr)
(setq attributes (face-attr-construct 'hl-paren-face))
- (when (car fg)
- (setq attributes (plist-put attributes :foreground (car fg))))
+ (let ((car-fg (car fg))
+ (car-bg (car bg))
+ (car-attr (car attr)))
+ (loop for (key . (val . _rest)) on car-attr by #'cddr
+ do (setq attributes
+ (plist-put attributes key val)))
+ (when car-fg
+ (setq attributes (plist-put attributes :foreground car-fg)))
+ (when car-bg
+ (setq attributes (plist-put attributes :background car-bg))))
(pop fg)
- (when (car bg)
- (setq attributes (plist-put attributes :background (car bg))))
(pop bg)
+ (pop attr)
(dotimes (i 2) ;; front and back
(push (make-overlay 0 0 nil t) hl-paren-overlays)
(overlay-put (car hl-paren-overlays) 'font-lock-face attributes)))
@@ -160,7 +188,7 @@ overlays when scrolling or moving point by pressing and
holding
(dolist (buffer (buffer-list))
(with-current-buffer buffer
(when hl-paren-overlays
- (mapc 'delete-overlay hl-paren-overlays)
+ (hl-paren-delete-overlays)
(setq hl-paren-overlays nil)
(hl-paren-create-overlays)
(let ((hl-paren-last-point -1)) ;; force update
- [nongnu] elpa/highlight-parentheses fdabfda 47/49: Remove cl-lib dependency since it's included in Emacs 24.3 anyhow; release 2.0.2, (continued)
- [nongnu] elpa/highlight-parentheses fdabfda 47/49: Remove cl-lib dependency since it's included in Emacs 24.3 anyhow; release 2.0.2, ELPA Syncer, 2021/08/15
- [nongnu] elpa/highlight-parentheses 9a99a4b 42/49: Fix custom type error of highlight-parentheses-attributes, ELPA Syncer, 2021/08/15
- [nongnu] elpa/highlight-parentheses 3b4d2c6 46/49: Add .elpaignore, ELPA Syncer, 2021/08/15
- [nongnu] elpa/highlight-parentheses bef1bc2 14/49: Add configuration for travis-ci., ELPA Syncer, 2021/08/15
- [nongnu] elpa/highlight-parentheses e653594 15/49: Add README with travis build state., ELPA Syncer, 2021/08/15
- [nongnu] elpa/highlight-parentheses d421e15 17/49: Add globalized highlight-parentheses-mode, ELPA Syncer, 2021/08/15
- [nongnu] elpa/highlight-parentheses 8869fba 21/49: Fix slowdown by moving overlays less often., ELPA Syncer, 2021/08/15
- [nongnu] elpa/highlight-parentheses 5e1fa9d 22/49: Make overlays front-advancing, ELPA Syncer, 2021/08/15
- [nongnu] elpa/highlight-parentheses 9b9137b 24/49: New defcustom: hl-paren-delay (see issue #12), ELPA Syncer, 2021/08/15
- [nongnu] elpa/highlight-parentheses ebf8827 25/49: Fix Travis build incidator, ELPA Syncer, 2021/08/15
- [nongnu] elpa/highlight-parentheses c38885b 31/49: Merge pull request #18 from Bad-ptr/master,
ELPA Syncer <=
- [nongnu] elpa/highlight-parentheses 73b4aa7 34/49: Added angle brackets!, ELPA Syncer, 2021/08/15
- [nongnu] elpa/highlight-parentheses 69c694a 30/49: Allow hl-paren- -[background-]colors, -attributes to be functions, ELPA Syncer, 2021/08/15
- [nongnu] elpa/highlight-parentheses f0bd58c 35/49: Merge pull request #20 from tprk77/master, ELPA Syncer, 2021/08/15
- [nongnu] elpa/highlight-parentheses 21fd617 41/49: Update README, ELPA Syncer, 2021/08/15
- [nongnu] elpa/highlight-parentheses b335e9e 49/49: Don't exclude README.md from ELPA package, ELPA Syncer, 2021/08/15
- [nongnu] elpa/highlight-parentheses 59ff08a 23/49: Merge pull request #11 from tsdh/master, ELPA Syncer, 2021/08/15
- [nongnu] elpa/highlight-parentheses ba48dac 36/49: Remove deprecated cl.el, fix compiler/linter nag, version bump, ELPA Syncer, 2021/08/15
- [nongnu] elpa/highlight-parentheses 72283a2 45/49: Add highlight-parentheses property to our overlays, ELPA Syncer, 2021/08/15
- [nongnu] elpa/highlight-parentheses d871467 43/49: Adapt URL to sr.ht, ELPA Syncer, 2021/08/15
- [nongnu] elpa/highlight-parentheses 23fe07f 39/49: Add LICENSE and screenshot, ELPA Syncer, 2021/08/15