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:55:37 +0300

> From: JD Smith <jdtsmith@gmail.com>
> Date: Sat, 1 May 2021 18:17:46 -0400
> Cc: emacs-devel@gnu.org
> 
> (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)))))

I don't recommend using format-mode-line for counting lines.  Why not
use count-lines instead?



reply via email to

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