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: 33871@debbugs.gnu.org, Lars Ingebrigtsen <larsi@gnus.org>
Subject: bug#33871: 27.0.50; Revert Dired window saved in window configuration
Date: Wed, 23 Feb 2022 10:31:41 +0100	[thread overview]
Message-ID: <dfec786c-3037-60ea-bed2-715f7c40e898@gmx.at> (raw)
In-Reply-To: <86fsoaq4lo.fsf@mail.linkov.net>

 > Like in bug#54038 (about having access to windows in window configurations),
 > the problem is that there is no way to update and even peek inside
 > a window configuration.  In bug#54038 the cleanup function can't tell
 > if a window is still live in a window configuration.

We might be able to provide such a function but can you tell me why you
would need it and how you would use it?

 > And here 'dired-revert' can't update windows saved in a window configuration.

Updating window configurations can be hairy.  We have no function for
testing the validity of a configuration - we simply rely on the fact
that it is a 1-to-1 copy of original sizes and parent-child
relationships.  For example: When we resize a window we check the new
sizes of all windows on that frame before storing them.  When we restore
a window configuration, we simply store back the old sizes and then
maybe try to resize the windows if the frame size changed in between.

 > 'dired-save-positions' goes to great lengths to employ get-buffer-window-list,
 > and walk-windows with window-prev-buffers to update the Dired buffer
 > even in window-prev-buffers.  And 'dired-restore-positions' with the
 > same number of lines tries to restore all prev-buffers.
 >
 > But still 'dired-revert' fails to update the Dired buffer in
 > window configurations saved in tabs, or in winner.el, or
 > in 'C-x r w' (window-configuration-to-register), etc.

As a first step we could try to do that for window states.

 > A possible solution would be to add two hooks:
 >
 > 1. hook before finishing 'current-window-configuration' that will add all
 > windows to some variable that the cleanup function could check in bug#54038.
 > This is like 'dired-save-positions'.

We can easily add such a hook - an abnormal, buffer local one probably
that would be set by dired whenever it shows a directory in a window and
could get as argument the frame and/or the window(s) and probably the
return value of 'current-window-configuration' so dired can match it
with later invocations of 'set-window-configuration'.

 > 2. hook after calling 'set-window-configuration' that will restore
 > previous positions.  This is like 'dired-restore-positions' that
 > uses 'dired-goto-file'.

We can do that in a similar fashion.  But: Updating your "variable" when
dired does something (like copying, deleting or renaming files) would
still have to be synchronized with the position of, for example,
'window-point' in that window when the window is still live at the time
'set-window-configuration' is called.  So we might need yet another hook
called at the beginning of 'set-window-configuration' that allows dired
to check whether the window stored in your variable is live, take the
position of point from there if it is and keep it in the second hook.

(Note in this context: We traditionally say in the Elisp manual that "As
a special exception, the window configuration does not record the value
of point in the selected window for the current buffer." which is not
precise IIUC.  It does record the value but 'set-window-configuration'
does not or not necessarily restore it.)

martin





  reply	other threads:[~2022-02-23  9:31 UTC|newest]

Thread overview: 60+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-25 21:39 bug#33871: 27.0.50; Revert Dired window saved in window configuration Juri Linkov
2018-12-26  9:43 ` martin rudalics
2018-12-27  0:01   ` Juri Linkov
2018-12-27  9:37     ` martin rudalics
2018-12-27 21:34       ` Juri Linkov
2018-12-28  8:34         ` martin rudalics
2018-12-29 11:19           ` Markus Triska
2018-12-29 18:18             ` martin rudalics
2018-12-29 23:21           ` Juri Linkov
2018-12-30  9:52             ` martin rudalics
2018-12-30 14:57               ` martin rudalics
2018-12-30 21:29               ` Juri Linkov
2022-02-12  8:45 ` Lars Ingebrigtsen
2022-02-13 18:40   ` Juri Linkov
2022-02-14  9:13     ` martin rudalics
2022-02-14 18:10       ` Juri Linkov
2022-02-14 18:36         ` martin rudalics
2022-02-15 19:30           ` Juri Linkov
2022-02-16  8:50             ` martin rudalics
2022-02-16 18:34               ` Juri Linkov
2022-02-17 10:05                 ` martin rudalics
2022-02-17 17:28                   ` Juri Linkov
2022-02-19  9:37                     ` martin rudalics
2022-02-19 17:08                       ` Juri Linkov
2022-02-19 17:22                         ` martin rudalics
2022-02-20 18:40                           ` Juri Linkov
2022-02-21  9:07                             ` martin rudalics
2022-02-22 17:14                               ` Juri Linkov
2022-02-23  9:31                                 ` martin rudalics [this message]
2022-02-23 17:53                                   ` Juri Linkov
2022-02-24  9:19                                     ` martin rudalics
2024-02-16  7:37                                       ` Juri Linkov
2024-02-16  9:41                                         ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-02-18  7:39                                           ` Juri Linkov
2024-02-19  9:42                                             ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-02-20  7:45                                               ` Juri Linkov
2024-02-21  9:05                                                 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-02-21 17:18                                                   ` Juri Linkov
2024-03-20 17:27                                                   ` Juri Linkov
2024-03-21  9:20                                                     ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-03-21 17:54                                                       ` Juri Linkov
2024-03-22  9:26                                                         ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-03-22 16:15                                                           ` Juri Linkov
2024-03-23  9:14                                                             ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-03-23 18:31                                                               ` Juri Linkov
2024-03-24  9:54                                                                 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-03-24 17:12                                                                   ` Juri Linkov
2024-03-25  9:41                                                                     ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-03-25 17:10                                                                       ` Juri Linkov
2024-03-26  9:55                                                                         ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-03-28  7:40                                                                           ` Juri Linkov
2024-03-28  9:18                                                                             ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-03-28 17:54                                                                               ` Juri Linkov
2024-03-29  8:45                                                                                 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-03-29 16:25                                                                                   ` Juri Linkov
2024-03-30  9:36                                                                                     ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-03-30 18:19                                                                                       ` Juri Linkov
2024-04-02 17:19                                                                                         ` Juri Linkov
2024-04-09  6:44                                           ` Juri Linkov
2024-04-09  9:05                                             ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors

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=dfec786c-3037-60ea-bed2-715f7c40e898@gmx.at \
    --to=rudalics@gmx.at \
    --cc=33871@debbugs.gnu.org \
    --cc=juri@linkov.net \
    --cc=larsi@gnus.org \
    /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).