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: JD Smith
Subject: Re: Temporarily select-window, without updating mode-line face and cursor fill?
Date: Sat, 1 May 2021 18:17:46 -0400

> Please explain in more detail why do you think you need to select the
> window.  What are those "line offsets", and why "move within it"
> requires to select the window?


Update: I managed to avoid selecting the window by using a somewhat more 
complex line move, based on set-window-start:

    (when (/= targ start)
      (set-window-start
       win
       (with-current-buffer (window-buffer win)
         (save-excursion
           (goto-char wstart)
           (forward-line (- targ start))
           (point)))))

Here wstart is the window start in the target window.  I presume 
with-current-buffer in the same buffer and set-window-start in the selected 
window is pretty efficient.  I also modified my fast line number function to 
work with a non-selected window as well (also somewhat convoluted, feedback 
welcome):

(defun mlscroll-fast-line-number-at-pos (pos &optional win)
  "Line number at position.
Compute line number at position POS. Uses fast mode-line
formatting.  If WIN is non-nil, find line number at position within
that window."
  (string-to-number
   (if win
       (let ((old (window-point win)))
         (set-window-point win pos)
         (prog1
             (format-mode-line "%l" 0 win)
           (set-window-point win old)))
         (save-excursion
           (goto-char pos)
           (format-mode-line "%l" 0)))))


reply via email to

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