all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@linkov.net>
To: martin rudalics <rudalics@gmx.at>
Cc: 32850@debbugs.gnu.org
Subject: bug#32850: 27.0.50; window-swap-states doesn't swap window prev/next-buffers
Date: Sat, 27 Oct 2018 23:09:53 +0300	[thread overview]
Message-ID: <87r2gbb85y.fsf@mail.linkov.net> (raw)
In-Reply-To: <5BD2C4AD.3060402@gmx.at> (martin rudalics's message of "Fri, 26 Oct 2018 09:39:25 +0200")

>> But unfortunately set-window-configuration doesn't restore
>> the old values of prev/next-buffers.
>
> That's disputable anyway.  When, in a window excursion, you show some
> buffer in a window, don't you want to record that buffer in that
> window's list of previous buffers after exiting from the excursion?

Thanks for the hint, I see now that the problem is not in
set-window-configuration, but in window-state-put.

In case of set-window-configuration, `(set-window-next-buffers nil nil)'
correctly changes the value of window-next-buffers in the same
window that was stored in window-configuration and that is
currently selected, i.e. this produces the right result
when prev/next-buffers are modified in a new window
(so not in the window shared in window configurations):

(progn (set-buffers)
       ;; Remember window-configuration with prev/next-buffers
       (let ((window-configuration (current-window-configuration)))
         ;; Create a new window
         (delete-other-windows) (split-window) (delete-window)
         ;; Reset prev/next-buffers
         (set-window-prev-buffers nil nil)
         (set-window-next-buffers nil nil)
         ;; This correctly restores remembered prev/next-buffers
         ;; because window-next-buffers are modified in another window
         (set-window-configuration window-configuration)
         ;; window-prev-buffers and window-next-buffers are correct
	 (list (window-prev-buffers) (window-next-buffers))))

But window-state-put has such deficiency with its undocumented
prerequisite that a new unique window should be created manually
before calling window-state-put to put the state into a new
window (to not share it with other window configurations).
This means a need in such ugly hack:

;; Create a new window
(delete-other-windows) (split-window) (delete-window)
;; Put a previous state into the new window
;; to not share it with other window configurations
(window-state-put previously-saved-window-state nil 'safe)
;; Get its window configuration
(current-window-configuration)

Please confirm is `(delete-other-windows) (split-window) (delete-window)'
is the right idiom to create a new window to put the window state into,
or there is a special function to create a window, that I can't find.

> Anyway.  It would be tedious but probably not impossible to provide a
> function that transforms a configuration into a state.  Doing the
> opposite is conceptually questionable, at the very least.

The code above does the opposite, but it requires an ugly workaround
for window-state-put.

> A basic invariant of the windows code is that a valid window cannot
> appear twice on the same or a different frame.  It may, however,
> appear an arbitrary number of times in stored window configurations.

Like the earlier code snippet demonstrates it causes problems when
the same window appears an arbitrary number of times in stored window
configurations.  Thus the need to create a new window to put the state into
(currently window-state-put itself doesn't create a new unique window).





  parent reply	other threads:[~2018-10-27 20:09 UTC|newest]

Thread overview: 78+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-26 23:39 bug#32850: 27.0.50; window-swap-states doesn't swap window prev/next-buffers Juri Linkov
2018-09-27 18:45 ` martin rudalics
2018-09-27 22:52   ` Juri Linkov
2018-09-30  8:00     ` martin rudalics
2018-09-30 20:00       ` Juri Linkov
2018-10-01  8:35         ` martin rudalics
2018-10-08 22:41           ` Juri Linkov
2018-10-09  7:44             ` martin rudalics
2018-10-15 20:48               ` Juri Linkov
2018-10-16  8:45                 ` martin rudalics
2018-10-16 22:37                   ` Juri Linkov
2018-10-17  7:31                     ` martin rudalics
2018-10-17 21:58                       ` Juri Linkov
2018-10-18  8:05                         ` martin rudalics
2018-10-18 22:37                           ` Juri Linkov
2018-10-19  7:40                             ` martin rudalics
2018-10-20 21:40                               ` Juri Linkov
2018-10-21  8:22                                 ` martin rudalics
2018-10-21 18:14                                   ` Juri Linkov
2018-10-22  9:07                                     ` martin rudalics
2018-10-23 20:45                                       ` Juri Linkov
2018-10-24  9:45                                         ` martin rudalics
2018-10-24 23:39                                           ` Juri Linkov
2018-10-25  6:04                                             ` martin rudalics
2018-10-25 19:19                                               ` Juri Linkov
2018-10-26  7:39                                                 ` martin rudalics
2018-10-26  7:59                                                   ` Eli Zaretskii
2018-10-27 20:09                                                   ` Juri Linkov [this message]
2018-10-28  9:00                                                     ` martin rudalics
2018-10-28 19:29                                                       ` Juri Linkov
2018-10-29  8:44                                                         ` martin rudalics
2018-10-29 22:45                                                           ` Juri Linkov
2018-10-30  9:00                                                             ` martin rudalics
2018-10-30 21:23                                                               ` Juri Linkov
2018-10-31  8:11                                                                 ` martin rudalics
2018-10-31 21:25                                                                   ` Juri Linkov
2018-11-01  9:03                                                                     ` martin rudalics
2018-11-01 22:30                                                                       ` Juri Linkov
2018-11-02  8:43                                                                         ` martin rudalics
2018-11-05 21:38                                                                           ` Juri Linkov
2018-11-06  3:26                                                                             ` Eli Zaretskii
2018-11-06 22:35                                                                               ` Juri Linkov
2018-11-06  8:46                                                                             ` martin rudalics
2018-11-10 21:56                                                   ` Juri Linkov
2018-11-11  8:53                                                     ` martin rudalics
2018-11-11 20:23                                                       ` Juri Linkov
2018-11-12  8:53                                                         ` martin rudalics
2018-11-12 23:47                                                           ` Juri Linkov
2018-11-13  9:09                                                             ` martin rudalics
2018-11-13 23:43                                                               ` Juri Linkov
2018-11-14  8:34                                                                 ` martin rudalics
2018-11-15  0:02                                                                   ` Juri Linkov
2018-11-15  9:12                                                                     ` martin rudalics
2018-11-15 21:30                                                                       ` Juri Linkov
2018-11-16  8:52                                                                         ` martin rudalics
2018-11-17 22:04                                                                           ` Juri Linkov
2018-11-18  9:23                                                                             ` martin rudalics
2018-11-17 17:01                                                                         ` Charles A. Roelli
2018-11-17 22:01                                                                           ` Juri Linkov
2018-11-18  9:23                                                                             ` martin rudalics
2018-11-18 22:47                                                                               ` Juri Linkov
2018-11-19  9:42                                                                                 ` martin rudalics
2018-11-19 22:28                                                                                   ` Juri Linkov
2018-11-20  9:27                                                                                     ` martin rudalics
2018-11-21  0:08                                                                                       ` Juri Linkov
2018-11-21  8:20                                                                                         ` martin rudalics
2018-11-21 23:44                                                                                           ` Juri Linkov
2018-11-22  7:41                                                                                             ` martin rudalics
2018-11-15  9:23                                                                     ` martin rudalics
2018-10-18 23:18                   ` Juri Linkov
2018-10-19  7:40                     ` martin rudalics
2018-10-25 19:31                       ` Juri Linkov
2018-10-26  7:41                         ` martin rudalics
2018-10-27 21:11                           ` Juri Linkov
2018-10-27 21:39                           ` Juri Linkov
2018-10-28  9:01                             ` martin rudalics
2018-10-28 19:09                               ` Juri Linkov
2018-10-29  8:43                                 ` 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

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

  git send-email \
    --in-reply-to=87r2gbb85y.fsf@mail.linkov.net \
    --to=juri@linkov.net \
    --cc=32850@debbugs.gnu.org \
    --cc=rudalics@gmx.at \
    /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 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.