I am reviewing some code in emacs that has a series of for loops that span several pages. The indentations done by the author are poor so it is not easy to tell where loops begi
Here is a modification of https://github.com/nschum/highlight-parentheses.el/blob/master/highlight-parentheses.el, which will permit you to scroll up or down without deleting the overlays. You can add additional this-command
statements to suit your needs.
(defun hl-paren-highlight ()
"Highlight the parentheses around point."
(unless
(or
(eq this-command 'mwheel-scroll)
(eq this-command 'scroll-up)
(eq this-command 'scroll-down))
(unless (= (point) hl-paren-last-point)
(setq hl-paren-last-point (point))
(let ((overlays hl-paren-overlays)
pos1 pos2
(pos (point)))
(save-excursion
(condition-case err
(while (and (setq pos1 (cadr (syntax-ppss pos1)))
(cdr overlays))
(move-overlay (pop overlays) pos1 (1+ pos1))
(when (setq pos2 (scan-sexps pos1 1))
(move-overlay (pop overlays) (1- pos2) pos2)
))
(error nil))
(goto-char pos))
(dolist (ov overlays)
(move-overlay ov 1 1))))))