From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: Temporarily select-window, without updating mode-line face and cursor fill? Date: Sun, 02 May 2021 09:55:37 +0300 Message-ID: <83eeep8w0m.fsf@gnu.org> References: <56F746A2-B842-421E-8FBF-EA5E93EA26CE@gmail.com> <83pmya8d49.fsf@gnu.org> <904A57C8-C268-412F-815F-782017F47D5D@gmail.com> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="8972"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: JD Smith Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun May 02 08:57:50 2021 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ld634-0002GO-Gn for ged-emacs-devel@m.gmane-mx.org; Sun, 02 May 2021 08:57:50 +0200 Original-Received: from localhost ([::1]:51114 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ld633-0004WC-LJ for ged-emacs-devel@m.gmane-mx.org; Sun, 02 May 2021 02:57:49 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:50400) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ld61F-0002gX-1c for emacs-devel@gnu.org; Sun, 02 May 2021 02:55:58 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:57025) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ld61E-0002NK-QG; Sun, 02 May 2021 02:55:56 -0400 Original-Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:1067 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1ld61E-0004LA-33; Sun, 02 May 2021 02:55:56 -0400 In-Reply-To: <904A57C8-C268-412F-815F-782017F47D5D@gmail.com> (message from JD Smith on Sat, 1 May 2021 18:17:46 -0400) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:268753 Archived-At: > From: JD Smith > 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?