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: Sat, 28 Sep 2024 17:52:29 +1000 Message-ID: <878qvcgqpu.fsf@gmail.com> References: <87setpdv21.fsf@gmail.com> <86zfnxcg57.fsf@gnu.org> <877cb09ln4.fsf@gmail.com> <9005cccc-7545-4257-b2c0-885a13d3bde2@gmx.at> <86o74aa41b.fsf@gnu.org> <3d4546ac-70d9-4865-b42d-0dc50cb0f3a7@gmx.at> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="34962"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: Eli Zaretskii , emacs-devel@gnu.org To: martin rudalics Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat Sep 28 10:23:09 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 1suSjN-0008xO-GP for ged-emacs-devel@m.gmane-mx.org; Sat, 28 Sep 2024 10:23:09 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1suSiq-0001ro-MN; Sat, 28 Sep 2024 04:22:36 -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 1suSFp-0007KR-QW for emacs-devel@gnu.org; Sat, 28 Sep 2024 03:52:37 -0400 Original-Received: from mail-pl1-x62f.google.com ([2607:f8b0:4864:20::62f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1suSFo-0001iY-9j; Sat, 28 Sep 2024 03:52:37 -0400 Original-Received: by mail-pl1-x62f.google.com with SMTP id d9443c01a7336-20551eeba95so28505875ad.2; Sat, 28 Sep 2024 00:52:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727509954; x=1728114754; 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=nG9m7qj7LsaHFQHvq/T4ZY0MCAkVRH4vk6cMNNbCToc=; b=Q3JzNnYLmVRPU480uZuUGO9iy/tkSMmt6Wffdo4tJrEaUNar33dljsyaiQGnEgNRHb gkx5y0tGg9bZH37eOisbz6pvpbrdDKraxsEQqwejpNIsw7v30FPxbE3dyWkSZOSXj50G Tc0Ahj7I57tUKIvTVgp72IfIwj7AiS6vfBLp6cVkmvGAY/o1oM9Cq5qNnKdtkmJIzNSj 2z67rUP761tGr7pz7vuV3Holnpf5t9yYjhLTmlZ44qHFNcG1Nloo0odmk61H4v5ie7JW /+YMadgNxonRfxSt78nm9+8F9lUWRJ+wR7JwaQNkN6WVaydBvDSZCt9gv4gGVG8iJ5NZ wvsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727509954; x=1728114754; 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=nG9m7qj7LsaHFQHvq/T4ZY0MCAkVRH4vk6cMNNbCToc=; b=qqCD+FyXY5QpnSDSPh+CZjdVwQTwrzCA1V8UhQZEtcRKbMzAuecvCmtUl+623GsRYD T/CYDlrOKI4qE7KQeox3EE9m5PDV9fJX7uDWqPPXkXlmT6dCfQ0vMmd2KYbd815uHCn/ tLlmXVV23u/xUs+0tAWr6OHi0QBLL/9qPyF0SeXrfJaRFEOM7plkxWMbsf8CxzNJBrO0 AP9yqXFQHaSw7Rg0ILsTCzGXD4JpxShLjOKrQpvtnPHe+QPH+5oIutoLnw22+KDV+UJy tuyXNqJMrcfbPgutU5Mcek5Y6Iy2IJkOSEgLgb9BaM1WMERMlt5N2pDyIphz17aa6BfK OHxQ== X-Forwarded-Encrypted: i=1; AJvYcCXPuoqxfARSqhEsk6BWW4c8yLfZXgUCUuvfDEGGxQKiUuUw9QeVcGaifebc6tumqBB2yj6pyzYqwe7hzw==@gnu.org X-Gm-Message-State: AOJu0YxdTnYmxi1ot8nUNDlGIwrLwiITtYGzls5Q84m+vjuq8a2svnZs wrSVP51dBgHW/ZRKk4/xrNUCQHDXAc2GjjZ4mzsV/vJmFrGF9C+/1EA4ag== X-Google-Smtp-Source: AGHT+IFclNYPdAfm4ihSbEdk4i9ZE3/4rncOHmBPlPxYhh7RY6RyYaz/ag12lNM7bfOKsjCFz5veEg== X-Received: by 2002:a17:902:e848:b0:202:ac8:991f with SMTP id d9443c01a7336-20b36ad984amr104349095ad.26.1727509954225; Sat, 28 Sep 2024 00:52:34 -0700 (PDT) Original-Received: from pebl ([2001:8003:7816:8300:be62:5525:b7f7:4de4]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20b37d6734asm22931555ad.62.2024.09.28.00.52.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Sep 2024 00:52:33 -0700 (PDT) In-Reply-To: <3d4546ac-70d9-4865-b42d-0dc50cb0f3a7@gmx.at> (martin rudalics's message of "Fri, 27 Sep 2024 19:29:21 +0200") Received-SPF: pass client-ip=2607:f8b0:4864:20::62f; envelope-from=pranshusharma366@gmail.com; helo=mail-pl1-x62f.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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Sat, 28 Sep 2024 04:22:35 -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:324155 Archived-At: martin rudalics writes: > Sure. I'll wait until the OP approves the concept and was able to make > use of it. Hello Martin, I managed to make remake the transpose frame function without using reseruct window, and instead used swap-window-states. I still have to do some cleaning up and error handling tho, eg is still returns error when you only have one window. However one thing I'm stuck with it getting it to work with root C-x 2 C-x 3 kinda splits (basiclly where (listp (caddar (window-tree))) is true). However if you start with no windows, split window once, go to split window, they you can go crazy with splitting in any direction (even the C-x 2 C-x 3) and it will work when you call transpose-frame. This also different from the transpose-windows.el in that it does not start on a blank slate(transpose-windows.el calls delete-other-windows in the transpose-frame-set-arrangement), so transposing partial window trees much easier but I haven't implimented it yet. --------------------------- ;; is there already another inbuilt funcion like this? (defun deepmap(func ls) (if (null ls) () (cons (if (listp (car ls)) (deepmap func (car ls)) (funcall func (car ls))) (deepmap func (cdr ls))))) (defun transpose-frame () (interactive) (let ((fwin (car (window-tree)))) (toggle-window-split ;; We gotta get sizes now, cuz if not then window split mess em ;; up (deepmap (lambda (e) (if (windowp e) (cons e (window-edges e)) e)) (car (window-tree))) fwin t) )) (defun toggle-window-split (subtree cwin &optional nokill) (pcase-let* ((`(,eee . ,flen) (if (car subtree) (cons 1 (window-width cwin)) (cons 0 (window-height cwin)))) (ilen (float (- (nth (+ 2 eee) (cadr subtree)) (nth (+ eee 0) (cadr subtree)))))) (mapcar (pcase-lambda (`(,win . ,size)) (if (listp win) (progn (toggle-window-split win (split-window cwin (- (round (* flen (/ size ilen)))) (car subtree)))) (progn (let ((newwin (split-window cwin (- (round (* flen (/ size ilen)))) (car subtree)))) (window-swap-states newwin win nil) (delete-window win))))) (mapcar (lambda (e) (pcase-let ((`(,edges ,window?) (if (windowp (car e)) (list (cdr e) (car e)) (list (cadr e) e)))) (cons window? (- (nth (+ 2 eee) edges) (nth eee edges))))) (nreverse (cdddr subtree)))) (unless nokill (if (windowp (caaddr subtree)) (delete-window (caaddr subtree)) (toggle-window-split (caddr subtree) cwin))))) ---------------------------