unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: martin rudalics <rudalics@gmx.at>
To: pranshu sharma <pranshusharma366@gmail.com>
Cc: Juri Linkov <juri@linkov.net>, Eli Zaretskii <eliz@gnu.org>,
	emacs-devel@gnu.org
Subject: Re: Add function to rotate/transpose all windows
Date: Sat, 19 Oct 2024 10:33:05 +0200	[thread overview]
Message-ID: <e4857e44-ae44-4b5e-bbbd-0bdf4efe69b4@gmx.at> (raw)
In-Reply-To: <87bjzgg929.fsf@gmail.com>

 >> If you optionally can supply REFER as a cons where the car is the
 >> previous (currently deleted) parent and the cdr the previous (currently
 >> deleted) leaf window (you have to keep pointers to all of them just in
 >> case the collector runs in between), we can easily fix that.  Just that
 >> 'window-tree-pixel-sizes' would have to report the old parent window too
 >> (in front of the flag telling whether it constitutes a horizontal or
 >> vertical split, probably).  It's easy to do, believe me.
 >>
 >
 > I don't understand

Suppose I had defined 'window-tree-pixel-sizes' as

(defun window-tree-pixel-sizes (window &optional next)
   "Return pixel sizes of all windows rooted at WINDOW.
The return value is a list where each internal window is represented by
a list of four elements: The window object, an indicator that is t if
the window is a horizontal combination and nil otherwise, the size of
the window as a cons of its pixel height and pixel width and a recursive
list of the window's child windows using the same list structure.  A
live window is represented by a cons consisting of the window object and
a cons of its pixel height and pixel width."
   (let (list child)
     (while window
       (setq list
	    (cons
	     (if (window-live-p window)
		 (cons window (cons (window-pixel-height window)
				    (window-pixel-width window)))
	       (list window
		     (not (window-top-child window))
		     (cons (window-pixel-height window)
			   (window-pixel-width window))
		     (window-tree-pixel-sizes
		      (or (window-top-child window)
			  (window-left-child window))
		      t)))
	     list))
       (setq window (when next (window-next-sibling window))))
     (nreverse list)))

Then

(pp (window-tree-pixel-sizes (frame-root-window)))

gets me here with a three live windows frame instead of your

((nil (979 . 1680) (#<window 15 on window-transpose.el> (979 . 840))
       (t (979 . 840) (#<window 89 on *Messages*> (490 . 840))
	 (#<window 95 on *scratch*> (489 . 840)))))

something like

((#<window 56> t (979 . 1680)
	   ((#<window 15 on window-transpose.el> 979 . 840)
	    (#<window 60> nil (979 . 840)
		      ((#<window 57 on *Messages*> 490 . 840)
		       (#<window 61 on *scratch*> 489 . 840))))))

The first element for each window would be its object: So #<window 56>
is a horizontal combination with the live #<window 15> as left and the
internal window #<window 60> as its right child.  Now when you want to
recreate #<window #15> you would have to pass 'split-window' a cons cell
referencing #<window 56> and #<window #15> and 'split-window-internal'
would resurrect the first as the parent and the second as its child.

martin



  parent reply	other threads:[~2024-10-19  8:33 UTC|newest]

Thread overview: 79+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-24 13:45 Add function to rotate/transpose all windows pranshu sharma
2024-09-24 13:53 ` Eli Zaretskii
2024-09-25  8:05   ` martin rudalics
2024-09-25  8:34     ` pranshu sharma
2024-09-25  9:31       ` martin rudalics
2024-09-25 10:50         ` pranshu sharma
2024-09-25 13:53           ` martin rudalics
2024-09-25 15:31             ` pranshu sharma
2024-09-26 14:10       ` martin rudalics
2024-09-26 14:22         ` Eli Zaretskii
2024-09-27 17:29           ` martin rudalics
2024-09-28  7:52             ` pranshu sharma
2024-09-28  9:26               ` martin rudalics
2024-09-28 10:53                 ` pranshu sharma
2024-09-28 14:48                   ` martin rudalics
2024-09-29  7:36                     ` pranshu sharma
2024-09-29  8:40                       ` martin rudalics
2024-09-29  9:23                         ` pranshu sharma
2024-09-29 14:48                           ` martin rudalics
2024-09-30  6:29                             ` pranshu sharma
2024-09-30  8:57                               ` martin rudalics
2024-10-01  9:17                                 ` pranshu sharma
2024-10-02  9:04                                   ` martin rudalics
2024-10-03  7:06                                     ` pranshu sharma
2024-10-03  8:17                                       ` martin rudalics
2024-10-03 10:09                                         ` pranshu sharma
2024-10-03 14:18                                           ` martin rudalics
2024-10-04  5:50                                             ` pranshu sharma
2024-10-04  8:08                                               ` martin rudalics
2024-10-04 15:10                                                 ` pranshu sharma
2024-10-05 14:43                                                   ` martin rudalics
2024-10-06  2:54                                                     ` pranshu sharma
2024-10-06 15:02                                                       ` martin rudalics
2024-10-06 15:52                                                         ` pranshu sharma
2024-10-07  8:33                                                           ` martin rudalics
2024-10-07  9:42                                                             ` pranshu sharma
2024-10-03 15:12                                           ` Eli Zaretskii
2024-10-08 18:35                                       ` Juri Linkov
2024-10-09  6:59                                         ` pranshu sharma
2024-10-09 16:21                                           ` Juri Linkov
2024-10-10 11:49                                             ` pranshu sharma
2024-10-10 16:57                                               ` Juri Linkov
2024-10-13  5:43                                                 ` pranshu sharma
2024-10-13  8:17                                                   ` martin rudalics
2024-10-14 17:36                                                     ` Juri Linkov
2024-10-15  8:34                                                     ` pranshu sharma
2024-10-15 16:16                                                       ` Juri Linkov
2024-10-18 14:52                                                     ` pranshu sharma
2024-10-18 17:48                                                       ` martin rudalics
2024-10-18 18:37                                                         ` Eli Zaretskii
2024-10-19  1:45                                                         ` pranshu sharma
2024-10-19  6:45                                                           ` Eli Zaretskii
2024-10-19 18:19                                                             ` Juri Linkov
2024-10-19  8:33                                                           ` martin rudalics [this message]
2024-10-20  8:19                                                       ` martin rudalics
2024-10-20 14:11                                                         ` Pranshu Sharma
2024-10-20 17:37                                                           ` martin rudalics
2024-10-21  5:54                                                             ` Pranshu Sharma
2024-10-21  8:14                                                               ` martin rudalics
2024-10-21  9:23                                                               ` martin rudalics
2024-10-21 13:37                                                             ` Pranshu Sharma
2024-10-22 18:12                                                               ` martin rudalics
2024-10-14 17:32                                                   ` Juri Linkov
2024-09-28  7:58             ` pranshu sharma
2024-09-28  8:18             ` Eli Zaretskii
2024-09-28  9:40               ` martin rudalics
2024-09-28 11:35                 ` Eli Zaretskii
2024-09-28 14:58                   ` martin rudalics
2024-09-28 15:28                     ` Eli Zaretskii
2024-10-07  8:33                       ` martin rudalics
2024-09-28 13:22                 ` pranshu sharma
2024-09-28 14:21                   ` Eli Zaretskii
2024-09-28 14:49                   ` martin rudalics
2024-09-27 10:06         ` pranshu sharma
2024-09-27 17:29           ` martin rudalics
2024-09-24 17:40 ` Petteri Hintsanen
2024-09-24 19:34 ` Charles Choi
2024-09-25  2:00   ` Emanuel Berg
2024-09-25  7:00   ` pranshu sharma

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=e4857e44-ae44-4b5e-bbbd-0bdf4efe69b4@gmx.at \
    --to=rudalics@gmx.at \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=juri@linkov.net \
    --cc=pranshusharma366@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).