From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.bugs Subject: bug#32874: Unwanted scrolling in edebug `f' command when follow-mode is active Date: Sun, 30 Sep 2018 14:45:29 +0000 Message-ID: <20180930144529.GE6305@ACM> References: <20180929140957.GB5008@ACM> <83lg7k5q2o.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: blaine.gmane.org 1538319014 27138 195.159.176.226 (30 Sep 2018 14:50:14 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 30 Sep 2018 14:50:14 +0000 (UTC) User-Agent: Mutt/1.10.1 (2018-07-13) Cc: 32874@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Sep 30 16:50:09 2018 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1g6d2u-0006w1-Dt for geb-bug-gnu-emacs@m.gmane.org; Sun, 30 Sep 2018 16:50:08 +0200 Original-Received: from localhost ([::1]:55726 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g6d51-0006RA-4G for geb-bug-gnu-emacs@m.gmane.org; Sun, 30 Sep 2018 10:52:19 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:51513) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g6d4n-0006Qt-LX for bug-gnu-emacs@gnu.org; Sun, 30 Sep 2018 10:52:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g6d4k-00024q-C9 for bug-gnu-emacs@gnu.org; Sun, 30 Sep 2018 10:52:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:55847) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1g6d4k-00024m-7Z for bug-gnu-emacs@gnu.org; Sun, 30 Sep 2018 10:52:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1g6d4k-0004m4-2A for bug-gnu-emacs@gnu.org; Sun, 30 Sep 2018 10:52:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Alan Mackenzie Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 30 Sep 2018 14:52:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 32874 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 32874-submit@debbugs.gnu.org id=B32874.153831907218293 (code B ref 32874); Sun, 30 Sep 2018 14:52:02 +0000 Original-Received: (at 32874) by debbugs.gnu.org; 30 Sep 2018 14:51:12 +0000 Original-Received: from localhost ([127.0.0.1]:60105 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1g6d3v-0004kz-W3 for submit@debbugs.gnu.org; Sun, 30 Sep 2018 10:51:12 -0400 Original-Received: from colin.muc.de ([193.149.48.1]:58506 helo=mail.muc.de) by debbugs.gnu.org with smtp (Exim 4.84_2) (envelope-from ) id 1g6d3u-0004kr-4M for 32874@debbugs.gnu.org; Sun, 30 Sep 2018 10:51:10 -0400 Original-Received: (qmail 58806 invoked by uid 3782); 30 Sep 2018 14:51:09 -0000 Original-Received: from acm.muc.de (p5B14620D.dip0.t-ipconnect.de [91.20.98.13]) by colin.muc.de (tmda-ofmipd) with ESMTP; Sun, 30 Sep 2018 16:51:08 +0200 Original-Received: (qmail 8466 invoked by uid 1000); 30 Sep 2018 14:45:29 -0000 Content-Disposition: inline In-Reply-To: <83lg7k5q2o.fsf@gnu.org> 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.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] 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" Xref: news.gmane.org gmane.emacs.bugs:150819 Archived-At: Hello, yet again, Eli. On Sat, Sep 29, 2018 at 17:35:43 +0300, Eli Zaretskii wrote: > > Date: Sat, 29 Sep 2018 14:09:57 +0000 > > From: Alan Mackenzie [ .... ] > > The best available hooks which might serve seem to be > > pre-redisplay-function or pre-redisplay-functions. Unfortunately, > > these are called too late, after redisplay has already determined > > which windows to operate on. > That's not true: pre-redisplay-function is called _before_ the display > engine determines what window(s) might need to be redrawn. Indeed, pre-redisplay-function appears to work well. The following patch, which moves follow-mode's embedding in Emacs from post-command-hook to pre-redisplay-function appears to solve the original bug (Unwanted scrolling after `f' in edebug) completely. Any objection from anybody to me committing this change to master? diff --git a/lisp/follow.el b/lisp/follow.el index 7aa7b51473..54ece9cd4f 100644 --- a/lisp/follow.el +++ b/lisp/follow.el @@ -187,8 +187,8 @@ ;; Implementation: ;; ;; The main method by which Follow mode aligns windows is via the -;; function `follow-post-command-hook', which is run after each -;; command. This "fixes up" the alignment of other windows which are +;; function `follow-pre-redisplay-function', which is run before each +;; redisplay. This "fixes up" the alignment of other windows which are ;; showing the same Follow mode buffer, on the same frame as the ;; selected window. It does not try to deal with buffers other than ;; the buffer of the selected frame, or windows on other frames. @@ -418,7 +418,8 @@ follow-mode (if follow-mode (progn (add-hook 'compilation-filter-hook 'follow-align-compilation-windows t t) - (add-hook 'post-command-hook 'follow-post-command-hook t) + ;; (add-hook 'post-command-hook 'follow-post-command-hook t) + (add-function :before pre-redisplay-function 'follow-pre-redisplay-function) (add-hook 'window-size-change-functions 'follow-window-size-change t) (add-hook 'after-change-functions 'follow-after-change nil t) (add-hook 'isearch-update-post-hook 'follow-post-command-hook nil t) @@ -445,7 +446,7 @@ follow-mode (setq following (buffer-local-value 'follow-mode (car buffers)) buffers (cdr buffers))) (unless following - (remove-hook 'post-command-hook 'follow-post-command-hook) + ;; (remove-hook 'post-command-hook 'follow-post-command-hook) (remove-hook 'window-size-change-functions 'follow-window-size-change))) (kill-local-variable 'move-to-window-group-line-function) @@ -1260,10 +1261,27 @@ follow-avoid-tail-recenter (not (eq win top)))) ;; Loop while this is true. (set-buffer orig-buffer)))) -;;; Post Command Hook +;;; Pre Display Function + +;; This function is added to `pre-display-function' and is thus called +;; before each redisplay operation. It supersedes (2018-09) the +;; former use of the post command hook, and now does the right thing +;; when a program calls `redisplay' or `sit-for'. + +(defun follow-pre-redisplay-function (wins) + (if (or (eq wins t) + (null wins) + (and (listp wins) + (memq (selected-window) wins))) + (follow-post-command-hook))) -;; The magic little box. This function is called after every command. +;;; Post Command Hook +;; 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. +;; ;; This is not as complicated as it seems. It is simply a list of common ;; display situations and the actions to take, plus commands for redrawing ;; the screen if it should be unaligned. @@ -1284,6 +1302,12 @@ follow-post-command-hook (setq follow-windows-start-end-cache nil)) (follow-adjust-window win))))) +;; NOTE: to debug follow-mode with edebug, it is helpful to add +;; `follow-post-command-hook' to `post-command-hook' temporarily. Do +;; this locally to the target buffer with, say,: +;; M-: (add-hook 'post-command-hook 'follow-post-command-hook t t) +;; . + (defun follow-adjust-window (win) ;; Adjust the window WIN and its followers. (cl-assert (eq (window-buffer win) (current-buffer))) -- Alan Mackenzie (Nuremberg, Germany).