From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.devel Subject: Re: [Emacs-diffs] master 51f0ccc: Put follow-mode's engine on pre-redisplay-hook instead of post-command-hook Date: Wed, 3 Oct 2018 13:14:11 +0000 Message-ID: <20181003131411.GB16238@ACM> References: <20181003105358.19923.64797@vcs0.savannah.gnu.org> <20181003105359.AA7EC204E8@vcs0.savannah.gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: blaine.gmane.org 1538572737 7327 195.159.176.226 (3 Oct 2018 13:18:57 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 3 Oct 2018 13:18:57 +0000 (UTC) User-Agent: Mutt/1.10.1 (2018-07-13) Cc: emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Oct 03 15:18:52 2018 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1g7h3E-0001q4-Cr for ged-emacs-devel@m.gmane.org; Wed, 03 Oct 2018 15:18:52 +0200 Original-Received: from localhost ([::1]:48769 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g7h5K-0000iS-Nb for ged-emacs-devel@m.gmane.org; Wed, 03 Oct 2018 09:21:02 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:45753) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g7h4e-0000fx-Sv for emacs-devel@gnu.org; Wed, 03 Oct 2018 09:20:21 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g7h4Z-0005h9-Ri for emacs-devel@gnu.org; Wed, 03 Oct 2018 09:20:20 -0400 Original-Received: from colin.muc.de ([193.149.48.1]:55473 helo=mail.muc.de) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1g7h4Z-0005fc-JC for emacs-devel@gnu.org; Wed, 03 Oct 2018 09:20:15 -0400 Original-Received: (qmail 4965 invoked by uid 3782); 3 Oct 2018 13:20:12 -0000 Original-Received: from acm.muc.de (p5B147319.dip0.t-ipconnect.de [91.20.115.25]) by colin.muc.de (tmda-ofmipd) with ESMTP; Wed, 03 Oct 2018 15:20:11 +0200 Original-Received: (qmail 16881 invoked by uid 1000); 3 Oct 2018 13:14:11 -0000 Content-Disposition: inline In-Reply-To: X-Delivery-Agent: TMDA/1.1.12 (Macallan) X-Primary-Address: acm@muc.de X-detected-operating-system: by eggs.gnu.org: FreeBSD 9.x [fuzzy] X-Received-From: 193.149.48.1 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 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.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:230197 Archived-At: Hello, Stefan. On Wed, Oct 03, 2018 at 08:20:30 -0400, Stefan Monnier wrote: > Hi Alan, > > Put follow-mode's engine on pre-redisplay-hook instead of > > post-command-hook > Yay! > > +(defun follow-pre-redisplay-function (wins) > > + (if (or (eq wins t) > > + (null wins) > > + (and (listp wins) > > + (memq (selected-window) wins))) > > + (follow-post-command-hook))) > I'm not sure it's possible for (selected-window) not to be memq of wins, > but even if it is, it's likely to be extremely rare. So the above (or ...) > is probably just a complicated way to say `t`. Maybe. But it looks safe, and keeps rigidly to the contract of pre-redisplay-function. > > +;; The magic little box. This function was formerly called after every > > +;; command. It is now called before each redisplay operation (see > > +;; `follow-pre-redisplay-function' above), and at the end of several > > +;; search/replace commands. It retains its historical name. > I wonder why this is still needed. There are interfaces like `isearch-update-post-hook' that need a function with no arguments. Isearch calls this hook at the end of a search operation, and this allows follow-mode to resynchronise the windows before a redisplay. I tried removing this interface, hoping that the pre-redisplay-function would do everything properly anyway, but it didn't - a search caused the LH window to scroll rather than moving point to the RH window. Also the windows have to be aligned before lazy highlighting takes place. So `isearch-update-post-hook' and friends stay. Also, for debugging follow-adjust-window, it is helpful to put follow-pre-redisplay-function temporarily on post-command-hook, allowing edebug to work. Let me save you the bother of telling me I could just make the wins argument &optional. ;-) I've just noticed that. > Stefan -- Alan Mackenzie (Nuremberg, Germany).