unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: martin rudalics <rudalics@gmx.at>
To: Juri Linkov <juri@linkov.net>
Cc: 35860@debbugs.gnu.org
Subject: bug#35860: Delayed window positioning after buffer display
Date: Sun, 16 Jun 2019 10:16:20 +0200	[thread overview]
Message-ID: <d699d924-dbf6-3587-3f12-0d8bcd767933@gmx.at> (raw)
In-Reply-To: <87imt6jva7.fsf@mail.linkov.net>

 > Generalized version does exactly what 'help-window-point-marker'
 > used to do, i.e.:
 >
 >    ;; `help-window-point-marker' is a marker you can move to a valid
 >    ;; position of the buffer shown in the help window in order to override
 >    ;; the standard positioning mechanism (`point-min') chosen by
 >    ;; `with-output-to-temp-buffer' and `with-temp-buffer-window'.
 >    ;; `with-help-window' has this point nowhere before exiting.  Currently
 >    ;; used by `view-lossage' to assert that the last keystrokes are always
 >    ;; visible.
 >    (defvar help-window-point-marker (make-marker)
 >      "Marker to override default `window-point' in help windows.")
 >
 > but for all windows instead of only help windows, i.e.:
 >
 >      "Marker to override default `window-point' in all windows."
 >
 > So do you think about just removing the prefix `help-' from the name:
 > `window-point-marker'?

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

For help windows (windows showing *Help*) 'help-window-point-marker'
allows to override these assignments by a suitable assignment for that
variable.  It's hackish but still done in a pretty restricitve fashion
as follows.

First 'help-window-point-marker' is reset in 'with-help-window' via

      ;; Make `help-window-point-marker' point nowhere.  The only place
      ;; where this should be set to a buffer position is within BODY.
      (set-marker help-window-point-marker nil)

- a security guard, because that marker should be nil at that time
anyway.

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?  For example, you proposed

  (defun window--display-buffer (buffer window type &optional alist)
    "Display BUFFER in WINDOW.
[...]
+
+      (when window-start
+        (set-window-start window window-start)
+        (setq window-start nil))
+
+      (when window-point
+        (set-window-point window window-point)
+        (setq window-point nil))

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.

The *Help* buffer is special because it's used in a centralized way
for any help Emacs provides (that's also why it has a browsable
history).  Buffers displayed by 'display-buffer' OTOH don't obey any
such restricitions.  They don't even have a BODY as the only place
where markers as the ones you propose can be set.

Also 'temp-buffer-window-show' and 'internal-temp-output-buffer-show'
are special because they explicitly wants to set window point to BOB.
So there's some predefined mechanism we (1) are aware of and (2) want
to override deliberately.

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.

martin





  reply	other threads:[~2019-06-16  8:16 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-22 20:32 bug#35860: Delayed window positioning after buffer display Juri Linkov
2019-05-23  4:34 ` Eli Zaretskii
2019-05-23 20:56   ` Juri Linkov
2019-05-24  6:32     ` Eli Zaretskii
2019-05-24 18:34       ` Juri Linkov
2019-05-25  7:58         ` martin rudalics
2019-05-27 19:49           ` Juri Linkov
2019-06-11 20:53           ` Juri Linkov
2019-06-13  8:44             ` martin rudalics
2019-06-13 20:24               ` Juri Linkov
2019-06-14 19:14                 ` Juri Linkov
2019-06-15  8:17                   ` martin rudalics
2019-06-15 22:44                     ` Juri Linkov
2019-06-16  8:16                       ` martin rudalics [this message]
2019-06-16 19:32                         ` Juri Linkov
2019-06-17  8:23                           ` martin rudalics
2019-06-17 20:33                             ` Juri Linkov
2019-06-18  8:19                               ` martin rudalics
2019-06-18 21:02                                 ` Juri Linkov
2019-06-19  9:14                                   ` martin rudalics
2019-06-19 21:34                                 ` Juri Linkov
2019-06-20  7:41                                   ` martin rudalics
2019-06-15  8:17                 ` martin rudalics

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d699d924-dbf6-3587-3f12-0d8bcd767933@gmx.at \
    --to=rudalics@gmx.at \
    --cc=35860@debbugs.gnu.org \
    --cc=juri@linkov.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).