all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Re: [Emacs-diffs] master 51f0ccc: Put follow-mode's engine on pre-redisplay-hook instead of post-command-hook
       [not found] ` <20181003105359.AA7EC204E8@vcs0.savannah.gnu.org>
@ 2018-10-03 12:20   ` Stefan Monnier
  2018-10-03 13:14     ` Alan Mackenzie
  0 siblings, 1 reply; 3+ messages in thread
From: Stefan Monnier @ 2018-10-03 12:20 UTC (permalink / raw)
  To: Alan Mackenzie; +Cc: emacs-devel

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`.

> +;; 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.


        Stefan



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Emacs-diffs] master 51f0ccc: Put follow-mode's engine on pre-redisplay-hook instead of post-command-hook
  2018-10-03 12:20   ` [Emacs-diffs] master 51f0ccc: Put follow-mode's engine on pre-redisplay-hook instead of post-command-hook Stefan Monnier
@ 2018-10-03 13:14     ` Alan Mackenzie
  2018-10-03 13:52       ` Stefan Monnier
  0 siblings, 1 reply; 3+ messages in thread
From: Alan Mackenzie @ 2018-10-03 13:14 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

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).



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Emacs-diffs] master 51f0ccc: Put follow-mode's engine on pre-redisplay-hook instead of post-command-hook
  2018-10-03 13:14     ` Alan Mackenzie
@ 2018-10-03 13:52       ` Stefan Monnier
  0 siblings, 0 replies; 3+ messages in thread
From: Stefan Monnier @ 2018-10-03 13:52 UTC (permalink / raw)
  To: emacs-devel

>> > +;; 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.

Thanks.  A comment explaining why these hooks are still used would be very
welcome (apparently, we don't know the deep reason why, but you can
mention the known test cases where it was found to be needed (e.g. what
you just wrote)).


        Stefan




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-10-03 13:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20181003105358.19923.64797@vcs0.savannah.gnu.org>
     [not found] ` <20181003105359.AA7EC204E8@vcs0.savannah.gnu.org>
2018-10-03 12:20   ` [Emacs-diffs] master 51f0ccc: Put follow-mode's engine on pre-redisplay-hook instead of post-command-hook Stefan Monnier
2018-10-03 13:14     ` Alan Mackenzie
2018-10-03 13:52       ` Stefan Monnier

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.