From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Pranshu Sharma Newsgroups: gmane.emacs.devel Subject: Re: Add function to rotate/transpose all windows Date: Fri, 25 Oct 2024 00:38:02 +1000 Message-ID: <87r085r2gl.fsf@gmail.com> References: <87setpdv21.fsf@gmail.com> <87r09224pe.fsf@gmail.com> <87ikudk62k.fsf@gmail.com> <0d879e95-c37e-416d-b439-daa6384c4f30@gmx.at> <878qv8kws2.fsf@gmail.com> <87ed4xvf60.fsf@gmail.com> <861q0qfnhr.fsf@mail.linkov.net> <878quxdant.fsf@gmail.com> <86zfndi6wh.fsf@mail.linkov.net> <87zfncuqhu.fsf@gmail.com> <86v7y00w68.fsf@mail.linkov.net> <87y12smubh.fsf@gmail.com> <96ea5140-9043-4c1b-97f3-4c534296355e@gmx.at> <87frotqx90.fsf@gmail.com> <87y12iyidd.fsf@gmail.com> <87iktld1bd.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="31100"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: Juri Linkov , Eli Zaretskii , emacs-devel@gnu.org To: martin rudalics Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Thu Oct 24 16:56:12 2024 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1t3zG0-0007wg-4Z for ged-emacs-devel@m.gmane-mx.org; Thu, 24 Oct 2024 16:56:12 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t3zFZ-0008Mp-Ow; Thu, 24 Oct 2024 10:55:46 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t3yyW-0004N0-8h for emacs-devel@gnu.org; Thu, 24 Oct 2024 10:38:09 -0400 Original-Received: from mail-pg1-x532.google.com ([2607:f8b0:4864:20::532]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t3yyU-0000sD-Jm; Thu, 24 Oct 2024 10:38:08 -0400 Original-Received: by mail-pg1-x532.google.com with SMTP id 41be03b00d2f7-7ea6a4f287bso600704a12.3; Thu, 24 Oct 2024 07:38:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729780684; x=1730385484; darn=gnu.org; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=TOj0jk0f/80D6vKUnk4FUT2G954RYKEiHBT2eEu/u4A=; b=iyDDXgabComoFhKcv6u3yxE34HVF00nqZN1kWHaDPNE6MzmYudCymNWn8hlwNymWyF 07RYVXn8XtDPJVq0VqXcNzyOO9nnlIDQ2IlxGgdH+PiWvd0cDX06F+5WSm+WclEtHrDd n2TBKVnrhXxsFyWd1aqcgTUJG5a5QoisH0BuyFY6qP2QUwiIrO64Y7c2gCx1qxxN7BDI B+55+gsNNGqZlaDhGgRjXTCXPqTX/N/sOs7no/3gH5J8qhAqOhJZcagzm4aQSc1fo0s7 DNoE2LpxXCEFBLhB14XhZCCLINYH+NBIXZ0wWz+U5ESQ+b4niHcu/9jaNrq4ODvbVdA0 Wq4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729780684; x=1730385484; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=TOj0jk0f/80D6vKUnk4FUT2G954RYKEiHBT2eEu/u4A=; b=gABnUHJTWs6W6uMBrFvVgHSLV2LqwFSBji1V4zUDbk23M6BowHGrsDuZhnnsgto+4f AkICYIRNpD87XxI5+SH9UAyWaqz3m6Sbh7ptzLIEB2bTXsBrYNfsvH27z20VhMoklEoN 14P2xGr43M6zMVCXyilzmf8u4bywTkZ8Qkes/DgJZfSaz+GPP+74lMnjng86MMcImIfg aqxICgZy2VJ1XklHV/3PQ0suEENTzop+BL1bipIjK4hM6O97Cqvwc8lBVI5VaW9hkDO6 5wXaxsd/Lao0O4pfaQ1KVgFq2mKcLoMIIfgqSYdkI9iPaLHTajTRgfkNeXUMOkOyCi7/ GqtA== X-Forwarded-Encrypted: i=1; AJvYcCU5B0Tb8o8xeJSRJuvcmF3g0nZuo/79ra+/6LtLi75WilzztX0W4de6Xl6bXz/5gM1+o8nz@gnu.org, AJvYcCUFr1tu0MVGtApBdyfjepdwSB9bitaG2qbmyTuhdU2EundDT/Zv9dZXzW2rsEpqiysNU9cio5gzHJDxlsU=@gnu.org X-Gm-Message-State: AOJu0YyxiI7q7Xtk4jC7Jf1Ro24RxDLLmF4p1HKlOR0CFRMs0qD3D/dw 7A2wdOMUexWJY11JijrH0Xwl21nkzGZ9QI6HOqJHX0XKLOlCCIk0mbrBYbl9 X-Google-Smtp-Source: AGHT+IHgDx1xsBlU2hlZo7AzOJ53CFDdhfa1Sm20W6rqzR4AjmcYzrRxQ8vdun0zWhh7WTguFky0rw== X-Received: by 2002:a05:6a21:a24c:b0:1d9:4837:ad95 with SMTP id adf61e73a8af0-1d978b986bamr7471185637.37.1729780684129; Thu, 24 Oct 2024 07:38:04 -0700 (PDT) Original-Received: from pranshu-ThinkPad-E560 ([2001:8003:7816:8300:f3bd:43c2:172b:74f0]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7eaebd061c1sm7308295a12.19.2024.10.24.07.38.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Oct 2024 07:38:03 -0700 (PDT) In-Reply-To: (martin rudalics's message of "Tue, 22 Oct 2024 20:12:18 +0200") Received-SPF: pass client-ip=2607:f8b0:4864:20::532; envelope-from=pranshusharma366@gmail.com; helo=mail-pg1-x532.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Thu, 24 Oct 2024 10:55:38 -0400 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:324821 Archived-At: --=-=-= Content-Type: text/plain martin rudalics writes: > OK. I looked into this again and maybe I can help you. Attached find a > new version of 'split-window' that accepts also a (WINDOW . PARENT) > cons as REFER where WINDOW is the buffer window to use and PARENT its > parent before WINDOW was deleted. How to use that is documented in the > version of window-transpose.el I also attach. It's full of debugging > code so you have to figure out yourself how to make use of it. > > The three crucial aspects are: > > (1) It has a function 'window-alist' that establishes before transposing > anything an association list of all live windows with their parents and > stores it in the variable 'window-alist'. > > (2) It deletes windows via 'delete-other-windows-internal'. > > (3) When it calls 'split-window' then in the (listp win) case I set the > cdr of the cons to the old parent of the _window to split_ (found via > 'window-alist'). In the win is a window case, I set the cdr of the cons > to the old parent of the _window to make_ (again found via > 'window-alist'). > > This survives quite a number of 'rotate-windows-clockwise' on the three > windows structure I create on the bottom of window-transpose.el. > > Try it and then maybe try it with your remaining functions in an > analogous manner. The tricky part is certainly (3) which might just > work with my simple rotation scenario. Sorry for late reply, been caught up with rl shit. I had a skim look at this, will have a proper one tommorow or saturday, and I think the problem of using flatten-list still exists. I've made a new protoptype (buggy) of window--transpose-1 that does not call flatten. Right now, it works with this kind of split: (let ((win (split-window (split-window nil nil t)))) (dotimes (_ 4) (setq win (split-window win 10 t)) )) and: (let ((win (split-window (split-window nil nil t)))) (dotimes (_ 4) (setq win (split-window win 10 t)) )) However, not on the one achived by: C-x 3 C-x o C-x 2 C-x 3 I did make some progress on this, but the problem was there was no way I know to achive this, which makes it a bit harder: |-------------| |-------------| | A | | A | |-------------| |-------------| | B | -> | B | | |-------------| |------| D | | C | | C | | |-------------| |-------------| I'm sure there is way to make it work without this, I'll probably come up with way in shower. --=-=-= Content-Type: application/emacs-lisp Content-Disposition: inline; filename=isolate.el Content-Transfer-Encoding: quoted-printable (defun window--transpose-1 (subtree cwin conf do-not-convert-size &optional= sizeee) "Subroutine of `window--transpose'. SUBTREE must be in the format of the result of `window-tree-pixel-sizes'. CWIN is the current window through which the window splits are made. The CONF and DO-NOT-CONVERT-SIZE arguments are the same as the ones in `window--transpose'." ;; `ilen' is the max size a window could be of given the split type. ;; `flen' is max size the window could be converted to the opposite ;; of the given split type. (pcase-let ((`(,ilen . ,flen) (if (car subtree) (cons (float (car (cadr subtree))) (float (window-pixel-width cwin))) (cons (float (cdr (cadr subtree))) (float (window-pixel-height cwin))))) (split-type (funcall (if (car subtree) 'car 'cdr) conf))) ;; (caaddr subtree) is the first window. ;; (unless (windowp (caaddr subtree)) ;; (window--transpose-1 (caddr subtree) cwin conf do-not-convert-size)) (seq-reduce (pcase-lambda (mwin `(,win . ,size)) (if (and (eq fwin win)) mwin (let ((split-size (and size (if do-not-convert-size size (round (* flen (/ size ilen))))))) (if (listp win) (if (and (not size) sizeee) (window--transpose-1 (cons (car win) (cdr win)) mwin conf do-not-convert-size sizeee ) (window--transpose-1 win mwin conf do-not-convert-size split-size)) (if (and (not size) sizeee) (split-window mwin sizeee (not (car subtree)) t win) (split-window mwin split-size (car subtree) t win)))))) (let ((ls (mapcar (lambda (e) (let ((window? (if (windowp (car e)) (car e) e))) (cons window? ;; The respective size of the window. (if (car subtree) (car (cadr e)) (cdr (cadr e)))))) ;; By using cdddr, we ignore first window (irelevnt unless tree) (cddr subtree)))) ;; (if sizeee ls ) ;; (seq-mapn 'cons (mapcar 'car ls) (cons sizeee (mapcar 'cdr ls))) (seq-mapn 'cons (mapcar 'car ls) (cons nil (mapcar 'cdr ls))) ) cwin) (window-parent cwin) )) --=-=-=--