From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: martin rudalics Newsgroups: gmane.emacs.devel Subject: Re: Add function to rotate/transpose all windows Date: Thu, 3 Oct 2024 10:17:31 +0200 Message-ID: <32650808-7cf9-4288-91b5-c7d78663de8f@gmx.at> 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> <87r09224pe.fsf@gmail.com> <87ikudk62k.fsf@gmail.com> <0d879e95-c37e-416d-b439-daa6384c4f30@gmx.at> <878qv8kws2.fsf@gmail.com> <87ed4xvf60.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="20011"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla Thunderbird Cc: Eli Zaretskii , emacs-devel@gnu.org To: pranshu sharma Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Thu Oct 03 12:24:47 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 1swJ0p-00056O-DM for ged-emacs-devel@m.gmane-mx.org; Thu, 03 Oct 2024 12:24:47 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1swI1X-0006GC-WC; Thu, 03 Oct 2024 05:21:39 -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 1swI1M-0006EQ-RE for emacs-devel@gnu.org; Thu, 03 Oct 2024 05:21:17 -0400 Original-Received: from mout.gmx.net ([212.227.15.18]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1swI08-00075P-HH; Thu, 03 Oct 2024 05:20:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.at; s=s31663417; t=1727947077; x=1728551877; i=rudalics@gmx.at; bh=GPj9eYxpvVAne7VsX04if1M7jSn61x/Oe4zvL2ejJaA=; h=X-UI-Sender-Class:Message-ID:Date:MIME-Version:Subject:To:Cc: References:From:In-Reply-To:Content-Type: Content-Transfer-Encoding:cc:content-transfer-encoding: content-type:date:from:message-id:mime-version:reply-to:subject: to; b=DAbuhBy9mesNtaapBJBTDGRpGmWwYRWBNf4cHvCF0ZFuh5e8gc4EPIqJFZel6wQT 6l/KNgqHPulQe7AHUxqqpUAVLAjgjAi/mTt0/kVFnL0lCwFxGZr3Msu6zZZw/U1uy v9TJgCDTV+hZ54ky9D9P5WhiWgupD5Mk3T4GUIr/GcoQWZr5ccfd088C0EzmvEvkg tdVR/LUPq3+O+A3RQzK2E0P4aaHEwj6dT233abALByFsBtX3gR/Yie+eJ1ngP2Tpz rd1MT0v72V92yJI5ErS5vvHjs15nM7QN6D+pSSsPE1kxfr2ZY3W7uqy9BWeD08Pt1 kPUjLp8Pi0DuckF6/g== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Original-Received: from [192.168.31.113] ([212.95.8.143]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1ML9uK-1se3Q60cdu-00LDaf; Thu, 03 Oct 2024 10:17:32 +0200 Content-Language: en-US In-Reply-To: <87ed4xvf60.fsf@gmail.com> X-Provags-ID: V03:K1:mIufRmvSgO4v2Y2oPCirfwX8j3KT/x5FspG6hqiCJTZiLihPGoj +wuHKwcFWgBwGnqfVcrX+IK1DA7wIwTpx0hz6VoAUlhsehgQQTA0S8enlThpUDEyibh3nWj AIkizHrqe8jebRNMfJQZ8QkEqtiSi4v7OO5ZGkeD9wkmdUa9U15Vl4fjlFjoR049Uql0B8s IAHRj2DiwiQwttQhgNCSg== UI-OutboundReport: notjunk:1;M01:P0:RxIELtgEZ1k=;HaaNOsH1ofvhM+Szy6jMy/g4s2A DKFDzP/9zSZ0ilkGzUxrv45wlO7QE85kDS2a+dsXAmsEBC0dPdiVXpV+Wt73Ct9EZ2uT2Ws+W EgFUDaw7sELl4T/+mb3sJKkS5SLA7ItQ7/FwQguSbHQZiXaF3ccZLqIkr23NVPcXUKwxJcTh7 ye88iB5xJz587wBQ/RQK2zFYMJeOjz/oTc5cHg5PYoVHHW8YDkIzSSuUYQ5tYq+0nsNfx46EW BeInqr5K7mZ2c1LvueXfO/pnNZ2VIciPf+xyPqyvexbQtz4fVAI5SwLf4MhS8irycn20VrN2C dE68RpdEDxJGOBwOQ1hTI9iOWbAe/5XpaX3MULs4QfYdmWREc6SDJqgnqj9Gk7dThxrNtSe+L UFZ8H2r7F5rL5ns4LEGdtVwJjp2aOdIIJNlWcm58SHEyfn71vY+k23x77fCfemauMxlrj/GLz GghthevQMR+SOOn94/EV1hzCpa0W5vGNeHUEmFN4j621VuLkezTpUH/SioRejCH0ZxeCHtHhB rfWT/2yoin+M7w/DxCCREfLkmzuD9TEtpuozBsky6dSC0loeMN2YU90j29bX1MgKJ2mJYChjP kFe59UDDYZhgE7rxIKLDuo2SU8+tqw7rbNmtAjuVyAek9/4miaBMNJpVxnJCf8WMmSABOPUuG uk6n67uI+g25yaf9P5SIuk7FJW6LtEXt+ZcI+77hsqEkH7wN+Q+E1YGRu3cEZz694YL5C1qZB nTW+bWeITYKDHkW/0ja905KeBG2Gq+Tp7157Q9VD9nPlUrgdzaqQfmeYej9rrTEhtDiwl0uM Received-SPF: pass client-ip=212.227.15.18; envelope-from=rudalics@gmx.at; helo=mout.gmx.net X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, FREEMAIL_FROM=0.001, SPF_HELO_NONE=0.001, T_SPF_TEMPERROR=0.01 autolearn=no autolearn_force=no X-Spam_action: no action 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:324276 Archived-At: >>> (defun transpose-windows--rearrange (frame-or-window conf norm-size) >> >> I'd call this just 'window--transpose'. > > done Not really IIUC. >> CONF is confusing. Why is it a cons cell in the first place? Wouldn't >> a simple boolean - t for horizontal and nil for vertical - suffice? If >> not, please explain why. > > You can also have below split and abvoe split, not just nil and t Aha... So the values are the possible values of the SIDE argument of 'split-window'. > I already explained the arguments in transpose-windows--rearrange. As > far as I can tell most other -1 postfix don't explain their arguments eg > window--resize-reset-1. Then please say "the arguments are the same as for `window--transpose'". > btw, what are the plans for the keybindings? imo they should be added > top level in C-x w map, as there are lots of spots avaiable, and there > are only 5 total new functions. Once we have installed it, we'll consult Juri Linkov. He knows more about keybindings in this area. BTW, you could have a look at the function 'window-swap-states'. IIUC it should then be rewritten in terms of the 'flip-windows-...' functions to get rid of window states and the overlay rigmarole. > (defun rotate-windows-anticlockwise (&optional frame-or-window) > "Rotate windows of FRAME-OR-WINDOW anti-clockwise by 90 degrees. > FRAME-OR-WINDOW must be a live frame or window and defaults to the > selected frame. If FRAME-OR-WINDOW is a frame, rotate the main window > of the frame, otherwise rotate FRAME-OR-WINDOW. See > `rotate-windows-clockwise' for how to rotate windows in the opposite > direction" > (interactive `(,(and current-prefix-arg (window-parent)))) Please test what happens if you have a keybinding for this and you hit that key in the minibuffer window, for example, after typing C-h f. > (defun flip-windows-horizontally (&optional frame-or-window) > "Horizontally flip windows of FRAME-OR-WINDOW. When the windows are > flipped horzontally, the window layout is made to it's reflection from > the side edge. FRAME-OR-WINDOW must be a live frame or window and > defaults to the selected frame. If FRAME-OR-WINDOW is a frame, flip from Still a space missing after the "." > (defun flip-windows-vertically (&optional frame-or-window) > "Horizontally flip windows of FRAME-OR-WINDOW. When the windows are Newline missing after ".". > flipped vertically, the window layout is made to it's reflection from > the top edge. FRAME-OR-WINDOW must be a live frame or window and > defaults to the selected frame. If FRAME-OR-WINDOW is a frame, flip from Space missing after ".". > (defun transpose-windows--rearrange (frame-or-window conf do-not-convert-size) Rename to 'window--transpose' as you claimed above. > "Rearrange windows of FRAME-OR-WINDOW recursively. > CONF should be a cons cell: (HORIZONTAL-SPLIT . VERTICAL-SPLIT) where > HORIZONTAL-SPLIT will be used as the third argument of `split-window' > when splitting a window that was previously horizontally split, and > VERTICAL-SPLIT as third argument `split-window' for a window that was ... third argument _of_ ... > previously vertically split. When is DO-NOT-CONVERT-SIZE non-nil, the Should become "If DO-NOT-CONVERT-SIZE is non-nil, ..." > size argument of the window-split is converted from vertical to > horizontal or vice versa, with the same proportion of the total split." > (pcase-let ((`(,rwin . ,frame) > (if (framep frame-or-window) > (cons (window-main-window frame-or-window) frame-or-window) > (cons frame-or-window (window-frame frame-or-window))))) > (if (or (not rwin) > (zerop (window-child-count rwin))) Actually (zerop (window-child-count rwin)) is equivalent to (window-live-p rwin) and the latter should be cheaper. > ;; The relevent size of the window. I think "respective size" is what you mean. > ;; By using cdddr, we ignore over window split type, sizes and Rather "ignore window split type" without the "over". > ;; the first window (it's implicitly created). > (nreverse (cdddr subtree)))) > ;; (caaddr subtree) is the first window. > (unless (windowp (caaddr subtree)) > (window--transpose-1 (caddr subtree) cwin conf do-not-convert-size)))) What I forgot to ask so far: Have you completed copyright assignment for Emacs? I can't look into this myself. martin