Created
August 8, 2020 02:41
-
-
Save lawlist/5bca55b088f4f00d67ea219365f94002 to your computer and use it in GitHub Desktop.
Draft of recentering while running isearch.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defvar my-isearch-window-start '(nil 0) | |
"Record the `selected-window' and the Y-axis coordinate of point each time that | |
`isearch-update' calls `my-isearch-update-recenter' (via an advice). The value | |
of this variable will be a cons cell with the CAR being the `selected-window' and | |
the CDR being the Y-axis coordinate of point.") | |
(defun my-isearch-update-recenter () | |
(let* ((win (selected-window)) | |
(pt (point)) | |
(y (cdr (nth 2 (posn-at-point pt win)))) | |
(same-y-p (and y | |
(eq win (car my-isearch-window-start)) | |
(= y (cdr my-isearch-window-start))))) | |
(when (and y (not same-y-p)) | |
(recenter) | |
(setq my-isearch-window-start (cons win y))))) | |
(advice-add 'isearch-update :before 'my-isearch-update-recenter) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment