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: Sun, 29 Sep 2024 19:23:57 +1000 Message-ID: <87r09224pe.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> <878qvcgqpu.fsf@gmail.com> <0138d382-8e63-4b53-8c2c-fece826a7d0a@gmx.at> <87plooaw1w.fsf@gmail.com> <87v7yeykr0.fsf@gmail.com> <19ca7821-e034-4ae5-9ff6-570243329d74@gmx.at> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="29499"; 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 Sun Sep 29 11:37:37 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 1suqMy-0007XS-N4 for ged-emacs-devel@m.gmane-mx.org; Sun, 29 Sep 2024 11:37:36 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1suqM6-00020o-1I; Sun, 29 Sep 2024 05:36:42 -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 1suq9u-0008Uw-Ho for emacs-devel@gnu.org; Sun, 29 Sep 2024 05:24:06 -0400 Original-Received: from mail-pj1-x1033.google.com ([2607:f8b0:4864:20::1033]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1suq9s-00030M-HD; Sun, 29 Sep 2024 05:24:05 -0400 Original-Received: by mail-pj1-x1033.google.com with SMTP id 98e67ed59e1d1-2e07ad50a03so2596332a91.3; Sun, 29 Sep 2024 02:24:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727601842; x=1728206642; darn=gnu.org; h=content-transfer-encoding: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=4+ihxyjQezpNeEJqwIj0WjbwKeY55+JsB6kZ/ZmsI94=; b=PjKu83heoZ1PLmZUgzG8s0t7Ne5FrvFcQtVdzHcT3cbz7t6M8iRVWtVnjSqYXexdc5 N2pCiHL1N6aB84nVMHqcTKeXeQ+79qzD3etutqubKWeCYnfuIV/5ICNYjNnnYC8a8HSo qWeulP+U2lgkrUQcmvQbaP3elt5ESTONwm1mVebuUZZD0kpZ+ukL3Tdae6+xhc1SpxiX jzeVg9GLKLnWQwIlvhMhERpqSCaP9gItuAj+PpW/DI6AP76CuFJsC5YE+LAbcqR+iFA/ mMWRG3kNOgnlAn/3gLU6vDGPw+ZMZxuTxQEWBAAv/1SPW1nOq3xnlmaszp8Ft8maLBrw gNrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727601842; x=1728206642; h=content-transfer-encoding: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=4+ihxyjQezpNeEJqwIj0WjbwKeY55+JsB6kZ/ZmsI94=; b=vrqwEa2TgyzPDjVhtnb8iDRxBR1cc2krxfaVsdKUyi0OC9uPlA+V6ijnRABJ4WSmcV 91oycBODWQI2p+UEOD7vVusJwpCMRMe7ePynjheo8yUMv/WnC1CMZbWCqwJ4SrxC4srt yuXU5l3w6qRZfmBRlb7qkVbHpvq9fFUCl6TFPGgTBesqOsMErwGD9rzoQhArQnyVTcXn FyzIQEGTc4Y3IOFpRpF841bpj+H+1GmClgyRxHBJZO6rl8MefdrZNfziKvyYrFIvBcgH lRENe26NeH6oAO9DXZ/uNZKCWz9X85uYm1hFGuEzsQMOQkPO+Cz/JCHND7JfnCAz+NMY GjyA== X-Forwarded-Encrypted: i=1; AJvYcCXblF0eUICEJHhw1xQCnmvOV0WSKxsVS6MhQRDjgc2zO52KmdP6atIORoj83NjVuXpy7ZV4sOz5EJHqYw==@gnu.org X-Gm-Message-State: AOJu0YzQlVvdv5qOeDo3KB+3rpfZlRO+lEvFUu8m3PRHMotW4usFxq9j t0CEW5Pg6+q9hVL71mLCacHwcnx1KSD623WwTF9Ht8UpInKKh3mo3hbvjA== X-Google-Smtp-Source: AGHT+IF7ewlKNrmxcybPlDyUj9pXTQVbw2tssWXpJyil3c0DX9KPCiTHwbKWtJDcrguJfuIzvcu9ZA== X-Received: by 2002:a17:90b:118c:b0:2e0:a77e:8305 with SMTP id 98e67ed59e1d1-2e0b8ec75d7mr9075856a91.39.1727601842189; Sun, 29 Sep 2024 02:24:02 -0700 (PDT) Original-Received: from pebl ([2001:8003:7816:8300:bbce:8c3e:8e68:23c]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e0b6e13cdbsm5405955a91.43.2024.09.29.02.23.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Sep 2024 02:24:01 -0700 (PDT) In-Reply-To: <19ca7821-e034-4ae5-9ff6-570243329d74@gmx.at> (martin rudalics's message of "Sun, 29 Sep 2024 10:40:42 +0200") Received-SPF: pass client-ip=2607:f8b0:4864:20::1033; envelope-from=pranshusharma366@gmail.com; helo=mail-pj1-x1033.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: Sun, 29 Sep 2024 05:36:39 -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:324188 Archived-At: martin rudalics writes: >> The following code implements transpose-frame and which works fine, I >> tested with some random window layouts and it worked for all. It uses >> the split-window refer argument. > > Thank you. > >> (defun transpose-frame (arg) >> "Transpose frame, or if arg is non-nil, selected window." > > ARG (upper case please) should be renamed to make it more descriptive > and you should explain what transposing the selected window means. Ok, will do > >> (res (deepmap (lambda (e) (if (windowp e) >> (prog1 (cons e (window-edges e)) >> (unless (equal fwin e) >> (push e delist))) > > IIUC here you "flatten" the return value of 'window-tree'. Why do you > do that? Can't 'transpose-frame' work directly on the return value of a > (possibly modified) 'window-tree'? This is definetly a big hack. The reason why this is needed is because the parent window might not actually be a window, it might also be another split, so it would have to recursivly descent find the first window. The only real alternative I can see is that if toggle-window-split returns a list of spltis to do, and then they are mapped over and done by toggle-window-split one level higher. I'll look into how transpose-frame.el deals with this. >> (prog1 (cons e (window-edges e)) > > On my maximized frame calling 'transpose-frame' repeatedly shrinks the > right/bottom windows until they cannot be shrunk any more. Hmm, show your window-tree (or the sequence of splits you did), I tested with a lot of splits and didn't find this problem. > I wouldn't use 'window-edges' here. Make your own version of > 'window-tree' (or give that an optional argument) so it returns the > normal sizes of windows instead of the edges and use the normal sizes > as factor for the SIZE argument of =E2=80=98split-window=E2=80=99 and mak= e the > PIXELWISE argument non-nil. I see, this should definetly make the function better. > Rounding window sizes can be awfully tricky and we should try to avoid > its effects as good as we can. When transposing windows on a GUI you > will always have to take into account that the width of a window > includes things like fringes and scroll bars (where the size of the > latter is toolkit dependent) which often make the width not an integral > multiple of the frame's character width. A similar argument goes for > window heights, for example, if a mode or tab line is displayed with a > different font or some sort of box around it. > > Also I expected your functions to run on subwindows of a frame's windows > and permit to rotate configurations clockwise or counter clockwise as > the version from 2011 did? Do you intend to provide those? They should be very easy(just changing up the arguments of split-window to correct combo of above, below, right, left), I'm just trying to first get the other aspects streamlined, but yes, I do intend on adding them. I'll also add flip if you want. > > martin