@ -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. " )
This is used to prevent analyzing the same context over and over. " )
( make-variable-buffer-local 'hl-paren-last-point )
( 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 ( )
( defun hl-paren-highlight ( )
" Highlight the parentheses around point. "
" Highlight the parentheses around point. "
( unless ( = ( point ) hl-paren-last-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 ) )
( cdr overlays ) )
( move-overlay ( pop overlays ) pos1 ( 1+ pos1 ) )
( move-overlay ( pop overlays ) pos1 ( 1+ pos1 ) )
( when ( setq pos2 ( scan-sexps pos1 1 ) )
( when ( setq pos2 ( scan-sexps pos1 1 ) )
( move-overlay ( pop overlays ) ( 1- pos2 ) pos2 )
( move-overlay ( pop overlays ) ( 1- pos2 ) pos2 ) ) )
) )
( error nil ) )
( error nil ) )
( goto-char pos ) )
( goto-char pos ) )
( dolist ( ov overlays )
( dolist ( ov overlays )
( move-overlay ov 1 1 ) ) ) ) )
( 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
;;;###autoload
( define-minor-mode highlight-parentheses-mode
( define-minor-mode highlight-parentheses-mode
" Minor mode to highlight the surrounding parentheses. "
" 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 )
( mapc 'delete-overlay hl-paren-overlays )
( kill-local-variable 'hl-paren-overlays )
( kill-local-variable 'hl-paren-overlays )
( kill-local-variable 'hl-paren-last-point )
( 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
( when highlight-parentheses-mode
( hl-paren-create-overlays )
( 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
;;;###autoload
( define-globalized-minor-mode global-highlight-parentheses-mode
( define-globalized-minor-mode global-highlight-parentheses-mode