Subject: Re: bug#35860: Delayed window positioning after buffer display

From: Juri Linkov <[email-masked]>
Date: Sun, 16 Jun 2019 22:32:08 +0300

> Currently 'temp-buffer-window-show' has
>
>       (goto-char (point-min))
>
> and 'internal-temp-output-buffer-show' has
>
> 	  (set-window-start window (point-min) t)
> 	  ;; This should not be necessary.
> 	  (set-window-point window (point-min))

BTW, there is a strange comment before the first line:

	  ;; Don't try this with NOFORCE non-nil!
	  (set-window-start window (point-min) t)

but its NOFORCE is non-nil here.  Is this a FIXME-like reminder?

> Then 'help-window-point-marker' may be set by the BODY of
> 'with-help-window' and 'help-window-setup' will pick that up guarded
> as
>
>       (when (eq (marker-buffer help-window-point-marker) help-buffer)
> 	(set-window-point window help-window-point-marker)
> 	;; Reset `help-window-point-marker'.
> 	(set-marker help-window-point-marker nil))
>
> thus (1) checking whether the marker buffer matches and (2)
> immediately resetting that marker to nil.
>
> Can you provide equivalent security guards when generalizing that
> variable?

In my previous patch there is no need to check for the buffer,
because a new general variable is declared as buffer-local.

> What happens with these markers when 'display-buffer-no-window' gets
> called?  Or some user provided routine provokes an unhandled error?
> You don't even check the marker buffer of these variables so some old,
> completely unrelated marker could get reused here.

There is no global effect because this feature is localized
to a single buffer by its buffer-local scope.

> So we'd carefully have to examine first how the mechanism you propose
> could be abused, how to handle any errors in using and failing to
> reset these markers and last but not least tell why we don't provide
> 'window-point' and 'window-start' action alist entries instead of such
> global variables.

We could support an action alist too in addition to buffer-local variables,
but we should leave an ability to set buffer-local variables, because
neither view-lossage nor vc-git-print-log (two primary cases to test
this feature) have no access to the 'action' arg of display-buffer.