emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/highlight-parentheses ac0fc4e 13/49: Protect against doubl


From: ELPA Syncer
Subject: [nongnu] elpa/highlight-parentheses ac0fc4e 13/49: Protect against double initialization of mode.
Date: Sun, 15 Aug 2021 03:57:44 -0400 (EDT)

branch: elpa/highlight-parentheses
commit ac0fc4e79a261b60def3261185c6cabad9da90e8
Author: Nikolaj Schumacher <git@nschum.de>
Commit: Nikolaj Schumacher <git@nschum.de>

    Protect against double initialization of mode.
---
 highlight-parentheses.el | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/highlight-parentheses.el b/highlight-parentheses.el
index 2f4c2b5..5451fd5 100644
--- a/highlight-parentheses.el
+++ b/highlight-parentheses.el
@@ -32,6 +32,8 @@
 ;;
 ;;; Change Log:
 ;;
+;;    Protect against double initialization (if used in `c-mode-hook').
+;;
 ;; 2013-03-22 (1.0.2)
 ;;    Fixed bug causing last color not to be displayed.
 ;;
@@ -117,14 +119,13 @@ This is used to prevent analyzing the same context over 
and over.")
 (define-minor-mode highlight-parentheses-mode
   "Minor mode to highlight the surrounding parentheses."
   nil " hl-p" nil
-  (if highlight-parentheses-mode
-      (progn
-        (hl-paren-create-overlays)
-        (add-hook 'post-command-hook 'hl-paren-highlight nil t))
-    (mapc 'delete-overlay hl-paren-overlays)
-    (kill-local-variable 'hl-paren-overlays)
-    (kill-local-variable 'hl-paren-last-point)
-    (remove-hook 'post-command-hook 'hl-paren-highlight t)))
+  (mapc 'delete-overlay hl-paren-overlays)
+  (kill-local-variable 'hl-paren-overlays)
+  (kill-local-variable 'hl-paren-last-point)
+  (remove-hook 'post-command-hook 'hl-paren-highlight t)
+  (when highlight-parentheses-mode
+    (hl-paren-create-overlays)
+    (add-hook 'post-command-hook 'hl-paren-highlight nil t)))
 
 ;;; overlays 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]