emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Temporarily select-window, without updating mode-line face and curso


From: Eli Zaretskii
Subject: Re: Temporarily select-window, without updating mode-line face and cursor fill?
Date: Sun, 02 May 2021 09:49:34 +0300

> From: JD Smith <jdtsmith@gmail.com>
> Date: Sat, 1 May 2021 16:32:22 -0400
> Cc: emacs-devel@gnu.org
> 
> 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"))))

I think your are doing premature optimization here.  Which alternative
method of counting lines you thought would be too slow?

> The operative bits of the “move within” look like:
> 
>    (when (/= targ start)
>       (forward-line (- targ start))
>       (recenter))

forward-line works on the current buffer, it doesn't care about the
window, AFAIK.

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

Sure, but the event gives you the window, and through it the buffer of
that window, so I see no particular reason to make the window
selected.

Alternatively, you could try doing this as mwheel.el does it.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]