|
|
|
|
@ -96,6 +96,9 @@ Color attributes might be overriden by `hl-paren-colors' and |
|
|
|
|
This is used to prevent analyzing the same context over and over.") |
|
|
|
|
(make-variable-buffer-local 'hl-paren-last-point) |
|
|
|
|
|
|
|
|
|
(defvar hl-paren-timer nil |
|
|
|
|
"A timer initiating the movement of the `hl-paren-overlays'.") |
|
|
|
|
|
|
|
|
|
(defun hl-paren-highlight () |
|
|
|
|
"Highlight the parentheses around point." |
|
|
|
|
(unless (= (point) hl-paren-last-point) |
|
|
|
|
@ -109,13 +112,18 @@ This is used to prevent analyzing the same context over and over.") |
|
|
|
|
(cdr overlays)) |
|
|
|
|
(move-overlay (pop overlays) pos1 (1+ pos1)) |
|
|
|
|
(when (setq pos2 (scan-sexps pos1 1)) |
|
|
|
|
(move-overlay (pop overlays) (1- pos2) pos2) |
|
|
|
|
)) |
|
|
|
|
(move-overlay (pop overlays) (1- pos2) pos2))) |
|
|
|
|
(error nil)) |
|
|
|
|
(goto-char pos)) |
|
|
|
|
(dolist (ov overlays) |
|
|
|
|
(move-overlay ov 1 1))))) |
|
|
|
|
|
|
|
|
|
(defun hl-paren-initiate-highlight () |
|
|
|
|
"Move the `hl-paren-overlays' after a short fraction of time." |
|
|
|
|
(when hl-paren-timer |
|
|
|
|
(cancel-timer hl-paren-timer)) |
|
|
|
|
(setq hl-paren-timer (run-at-time 0.23 nil #'hl-paren-highlight))) |
|
|
|
|
|
|
|
|
|
;;;###autoload |
|
|
|
|
(define-minor-mode highlight-parentheses-mode |
|
|
|
|
"Minor mode to highlight the surrounding parentheses." |
|
|
|
|
@ -123,10 +131,10 @@ This is used to prevent analyzing the same context over and over.") |
|
|
|
|
(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) |
|
|
|
|
(remove-hook 'post-command-hook 'hl-paren-initiate-highlight t) |
|
|
|
|
(when highlight-parentheses-mode |
|
|
|
|
(hl-paren-create-overlays) |
|
|
|
|
(add-hook 'post-command-hook 'hl-paren-highlight nil t))) |
|
|
|
|
(add-hook 'post-command-hook 'hl-paren-initiate-highlight nil t))) |
|
|
|
|
|
|
|
|
|
;;;###autoload |
|
|
|
|
(define-globalized-minor-mode global-highlight-parentheses-mode |
|
|
|
|
@ -148,7 +156,7 @@ This is used to prevent analyzing the same context over and over.") |
|
|
|
|
(setq attributes (plist-put attributes :background (car bg)))) |
|
|
|
|
(pop bg) |
|
|
|
|
(dotimes (i 2) ;; front and back |
|
|
|
|
(push (make-overlay 0 0) hl-paren-overlays) |
|
|
|
|
(push (make-overlay 0 0 nil t) hl-paren-overlays) |
|
|
|
|
(overlay-put (car hl-paren-overlays) 'face attributes))) |
|
|
|
|
(setq hl-paren-overlays (nreverse hl-paren-overlays)))) |
|
|
|
|
|
|
|
|
|
|