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:49:34 +0300 Message-ID: <83im418wap.fsf@gnu.org> References: <56F746A2-B842-421E-8FBF-EA5E93EA26CE@gmail.com> <83pmya8d49.fsf@gnu.org> <6168853E-E5B1-4247-A0D7-4D4191DCED0A@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="20336"; 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:50:53 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 1ld5wL-0005Eb-1o for ged-emacs-devel@m.gmane-mx.org; Sun, 02 May 2021 08:50:53 +0200 Original-Received: from localhost ([::1]:40832 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ld5wK-0008WD-6I for ged-emacs-devel@m.gmane-mx.org; Sun, 02 May 2021 02:50:52 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:49592) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ld5vQ-0007yG-60 for emacs-devel@gnu.org; Sun, 02 May 2021 02:49:56 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:56962) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ld5vP-0006JJ-8B; Sun, 02 May 2021 02:49:55 -0400 Original-Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:4672 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1ld5vO-0003lg-4L; Sun, 02 May 2021 02:49:55 -0400 In-Reply-To: <6168853E-E5B1-4247-A0D7-4D4191DCED0A@gmail.com> (message from JD Smith on Sat, 1 May 2021 16:32:22 -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:268751 Archived-At: > From: JD Smith > 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.