|
From: | JD Smith |
Subject: | Re: Temporarily select-window, without updating mode-line face and cursor fill? |
Date: | Sat, 1 May 2021 16:32:22 -0400 |
Sure, thanks. I compute line positions at a number of points (window-start, window-end, and point-max) inside a mode line :eval form. To compute line numbers at these positions, for speed in very long files, I’m actually using: (defun mlscroll-fast-line-number-at-pos (pos) (save-excursion (goto-char pos) (string-to-number (format-mode-line "%l")))) The operative bits of the “move within” look like: (when (/= targ start) (forward-line (- targ start)) (recenter)) During normal automatic mode-line update, the selected window is automatically bound correctly while the mode line string is computed (without updating the mode line face, I might add!). But during the mouse event callback, I must use the starting window of the mouse event (a press) as the window to target, since the user could click on any of them. I believe I can re-task all of the “computing lines” code to take a window argument, i.e. to avoid actually selecting the window itself. But less clear is how to move forward and back a given number of lines (forward-line) and recenter in an unselected window, without selecting it temporarily and causing the mode line face flashing. |
[Prev in Thread] | Current Thread | [Next in Thread] |