Emacs: prevent cursor movement when scrolling off of the screen

前端 未结 3 365
抹茶落季
抹茶落季 2021-01-23 04:10

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

3条回答
  •  走了就别回头了
    2021-01-23 05:06

    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))))))
    

提交回复
热议问题