From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.bugs Subject: bug#17453: Isearch doesn't work properly with Follow Mode. Date: Tue, 3 Nov 2015 16:39:55 +0000 Message-ID: <20151103163955.GF2258@acm.fritz.box> References: <87bnbddzpk.fsf@mail.linkov.net> <20151102092853.GA11804@acm.fritz.box> <20151102123512.GB11804@acm.fritz.box> <20151102154445.GD11804@acm.fritz.box> <87h9l46l7o.fsf@mail.linkov.net> <20151103123116.GD2258@acm.fritz.box> <83a8qvw0aq.fsf@gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1446568771 22199 80.91.229.3 (3 Nov 2015 16:39:31 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 3 Nov 2015 16:39:31 +0000 (UTC) Cc: 17453@debbugs.gnu.org, bruce.connor.am@gmail.com, juri@linkov.net To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Nov 03 17:39:20 2015 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1ZtecA-0004j5-1h for geb-bug-gnu-emacs@m.gmane.org; Tue, 03 Nov 2015 17:39:18 +0100 Original-Received: from localhost ([::1]:49719 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ztec9-0003Qp-5p for geb-bug-gnu-emacs@m.gmane.org; Tue, 03 Nov 2015 11:39:17 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:58460) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ztebz-0003Iy-TU for bug-gnu-emacs@gnu.org; Tue, 03 Nov 2015 11:39:13 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ztebu-0003wm-3F for bug-gnu-emacs@gnu.org; Tue, 03 Nov 2015 11:39:07 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:60957) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ztebu-0003wh-0E for bug-gnu-emacs@gnu.org; Tue, 03 Nov 2015 11:39:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1Ztebt-0003kg-US for bug-gnu-emacs@gnu.org; Tue, 03 Nov 2015 11:39:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Alan Mackenzie Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 03 Nov 2015 16:39:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 17453 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 17453-submit@debbugs.gnu.org id=B17453.144656869114354 (code B ref 17453); Tue, 03 Nov 2015 16:39:01 +0000 Original-Received: (at 17453) by debbugs.gnu.org; 3 Nov 2015 16:38:11 +0000 Original-Received: from localhost ([127.0.0.1]:51665 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Zteb5-0003jR-1L for submit@debbugs.gnu.org; Tue, 03 Nov 2015 11:38:11 -0500 Original-Received: from mail.muc.de ([193.149.48.3]:49457) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Zteb1-0003jF-L8 for 17453@debbugs.gnu.org; Tue, 03 Nov 2015 11:38:08 -0500 Original-Received: (qmail 86283 invoked by uid 3782); 3 Nov 2015 16:38:06 -0000 Original-Received: from acm.muc.de (p5B14700A.dip0.t-ipconnect.de [91.20.112.10]) by colin.muc.de (tmda-ofmipd) with ESMTP; Tue, 03 Nov 2015 17:38:05 +0100 Original-Received: (qmail 13461 invoked by uid 1000); 3 Nov 2015 16:39:55 -0000 Content-Disposition: inline In-Reply-To: <83a8qvw0aq.fsf@gnu.org> User-Agent: Mutt/1.5.23 (2014-03-12) X-Delivery-Agent: TMDA/1.1.12 (Macallan) X-Primary-Address: acm@muc.de X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:108362 Archived-At: Hello, Eli. On Tue, Nov 03, 2015 at 05:49:17PM +0200, Eli Zaretskii wrote: > PLEASE let's keep emacs-devel out of this?? OK. > > Date: Tue, 3 Nov 2015 12:31:16 +0000 > > From: Alan Mackenzie > > Cc: 17453@debbugs.gnu.org, Artur Malabarba , > > emacs-devel > > This is complicated. Ideally, the Follow Mode windows should be > > synchronised in FM's post-command-hook, not isearch's. It is not > > isearch's job to realign windows. follow-post-command-hook both realigns > > windows and choses an appropriate window to put point in. We should let > > it. > Once again, if some code in Isearch calls the same function that is > used in follow-post-command-hook, the above is not an issue. > Moreover, saving some calls to the hook will make Emacs more > responsive. (Right now, using Follow mode is a pain due to the hook: > even a simple C-f is annoyingly slow.) The follow-post-command-hook will run anyway. If Isearch directly invokes that Follow Mode function, f-p-c-h will be run a second time. That's one of the reasons I want to avoid it. > > What I'm proposing is to schedule the timer always, and do the checks > > (for whether we need to start a new lazy highlight loop) in the function > > that the timer triggers. The advantage is that when the timer triggers, > > redisplay will already have taken place[*] > I don't think you can count on that: if there's a ripe timer, it will > be processed before redisplay. I think. Ah. So if somebody sets isearch-lazy-highlighting-intial-delay to 0.00001 seconds, it will trigger before redisplay has happened. Yes. Here's another idea. In place of that "(sit-for 0)", I add another condition (redisplay-would-scroll-window-p) , with the following in (probably) window.el: (defun redisplay-would-scroll-window-p (&optional pos window) "Would redisplay scroll WINDOW vertically on an immediate redisplay? WINDOW defaults to the current window. POS, the position of point which is to be tested defaults to the value of point in WINDOW. The buffer displayed by WINDOW is assumed to be the current buffer. Return t if a vertical scroll would be triggered by redisplay, otherwise nil." (or window (setq window (selected-window))) (or pos (setq pos (window-point window))) (with-selected-window window (with-current-buffer (window-buffer) (not (and (pos-visible-in-window-p pos) (or (<= scroll-margin 0) (let* ((this-scroll-margin (min scroll-margin (/ (window-body-height) 4))) (top-limit (save-excursion (move-to-window-line this-scroll-margin) (point))) (bottom-limit (save-excursion (move-to-window-line (- this-scroll-margin)) (point)))) (and (>= pos top-limit) (< pos bottom-limit))))))))) . -- Alan Mackenzie (Nuremberg, Germany).