unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: martin rudalics <rudalics@gmx.at>
To: Eli Zaretskii <eliz@gnu.org>, Tom Gillespie <tgbugs@gmail.com>
Cc: emacs-devel@gnu.org, larsi@gnus.org
Subject: Re: [PATCH] Fix display-buffer-use-some-window to honor reusable-frames
Date: Sat, 28 Jan 2023 11:46:30 +0100	[thread overview]
Message-ID: <a37e3600-c40b-e9c6-7893-b3a9a580dfb1@gmx.at> (raw)
In-Reply-To: <834jsccepb.fsf@gnu.org>

 > Martin, any comments?

Sorry but I had no idea what 'display-buffer-use-least-recent-window' is
and what it is supposed to accomplish.  This part of its doc-string "but
will cycle through windows when displaying buffers repeatedly" seems to
describe what 'display-buffer-use-some-window' does.  The "if there's
only a single window, it will split the window" does not fit at all - it
would rely on some extraneous mechanism like a base action to do that
(and IIUC Tom's patch tries to address that issue).  OTOH, the fact that
'display-buffer-use-least-recent-window' bumps a window's use time is
nowhere mentioned AFAICT.

IIUC the idea of bumping the use time is to make sure that a subsequent
'display-buffer' does not reuse the window that's used here because we
pretend that that window was selected recently and so 'get-lru-window'
will avoid it.  The doc-string should have said that.

IMO the present approach has three defects which break things and
ultimately make it useless for 'display-buffer'.


(1) 'display-buffer-use-least-recent-window' claims to be a buffer
display action function but IIUC it does not return the window used.
For example, with emacs -Q do C-x 2, C-x o and evaluate

(display-buffer
  (get-buffer-create "*foo*")
  '((display-buffer-use-least-recent-window display-buffer-at-bottom)))

You get two windows showing *foo*.  This one is easy to fix.


(2) The current version of 'window-bump-use-time' changes the semantics
of "least recently used window" without even mentioning that anywhere.
For example, this code in sql.el

     (let ((one-win (eq (selected-window)
                        (get-lru-window))))

will conclude that there is only one window even if another window
recently created by 'display-buffer-use-least-recent-window' exists.  I
have no idea how 'get-mru-window' could be affected.

This is a grave bug.  'window-bump-use-time' could try

   struct window *sw = XWINDOW (selected_window);

   if (w != sw)
     {
       w->use_time = ++window_select_count;
       sw->use_time = ++window_select_count;
     }

to make sure that the selected window invariably stays the most recently
used one but this would require some testing.


(3) The idea of having one action function bump use times works iff
'display-buffer-use-least-recent-window' is the _only_ action function
called by both user and application.  It breaks as soon as another
action function kicks in - either because the other action function does
not call 'get-lru-window' or because that other action function does not
bump the use time of the window used.  This is impossible to fix with
the current approach.

One thing we could do is to add a new action alist entry say
'bump-use-time'.  People could use this to indicate that they want to
display several buffers in a row.  'window--display-buffer' would then
bump the use time of the window it uses when ALIST contains that entry.
I have no idea how this would work in practice.


A few words about Tom's patch: 'display-buffer-use-some-window' must not
pop up a new window.  It's doc-string clearly says to "Display BUFFER in
an existing window."  Please don't ever try to change that.  Also, it
should not care about 'reusable-frames'.  The latter is about reusing a
window that already shows BUFFER and other action functions might be
affected badly if 'display-buffer-use-some-window' tried to handle this
too.  Finally, 'display-buffer-no-window' has no place in another action
function.  It is strictly reserved to callers and users.

martin



  reply	other threads:[~2023-01-28 10:46 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-27  5:17 [PATCH] Fix display-buffer-use-some-window to honor reusable-frames Tom Gillespie
2023-01-27  5:25 ` Tom Gillespie
2023-01-27  6:19   ` Tom Gillespie
2023-01-27 13:03     ` Eli Zaretskii
2023-01-28 10:46       ` martin rudalics [this message]
2023-01-28 11:12         ` Eli Zaretskii
2023-01-28 15:35           ` martin rudalics
2023-01-28 16:02             ` Eli Zaretskii
2023-01-29 17:39               ` martin rudalics
2023-01-29 18:41                 ` Eli Zaretskii
2023-01-29 18:50                   ` Tom Gillespie
2023-01-30 16:43                   ` martin rudalics
2023-01-30 17:38                     ` Eli Zaretskii
2023-01-30 17:57                       ` martin rudalics
2023-01-30 18:04                         ` Eli Zaretskii
2023-01-31  8:45                           ` martin rudalics
2023-01-31 14:01                             ` Eli Zaretskii
2023-02-01 10:45                               ` martin rudalics
2023-02-01 17:38                                 ` Eli Zaretskii
2023-02-01 18:33                                   ` martin rudalics
2023-01-28 19:04         ` Tom Gillespie
2023-01-28 20:01           ` Tom Gillespie
2023-01-29 17:39             ` martin rudalics
2023-01-29 19:02               ` Tom Gillespie
2023-01-30 16:44                 ` martin rudalics
2023-01-30 17:43                   ` Tom Gillespie
2023-01-30 17:58                     ` martin rudalics
2023-01-30 19:40                       ` Tom Gillespie
2023-01-30 22:45                         ` Tom Gillespie
2023-01-31  8:46                           ` martin rudalics
2023-01-31 18:38                             ` Tom Gillespie
2023-02-01  9:08                               ` martin rudalics
2023-02-01 17:19                                 ` Tom Gillespie
2023-02-01 18:32                                   ` martin rudalics
2023-02-02 16:39                                     ` martin rudalics
2023-02-02 19:57                                       ` Tom Gillespie
2023-02-03  9:09                                         ` martin rudalics
2023-02-11 15:44                                           ` Eli Zaretskii
2023-02-11 18:15                                           ` Tom Gillespie
2023-02-12  9:33                                             ` martin rudalics
2023-02-18 17:46                                               ` Eli Zaretskii
2023-02-20  9:03                                                 ` martin rudalics
2023-02-20 11:55                                                   ` Eli Zaretskii
2023-02-20 18:14                                                     ` martin rudalics
2023-02-21 12:02                                                       ` Eli Zaretskii
2023-01-31  8:46                         ` martin rudalics
2023-01-29 17:48         ` Juri Linkov
2023-01-29 18:48           ` Eli Zaretskii
2023-02-06 10:01         ` 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=a37e3600-c40b-e9c6-7893-b3a9a580dfb1@gmx.at \
    --to=rudalics@gmx.at \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=larsi@gnus.org \
    --cc=tgbugs@gmail.com \
    /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).