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: Wed, 2 Oct 2024 11:04:28 +0200 Message-ID: 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> 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="24592"; 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 Wed Oct 02 11:05:24 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 1svvIS-0006Dz-3b for ged-emacs-devel@m.gmane-mx.org; Wed, 02 Oct 2024 11:05:24 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1svvHi-0004Ew-Rj; Wed, 02 Oct 2024 05:04:38 -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 1svvHg-0004El-IS for emacs-devel@gnu.org; Wed, 02 Oct 2024 05:04:36 -0400 Original-Received: from mout.gmx.net ([212.227.15.19]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1svvHd-0008Vt-SD; Wed, 02 Oct 2024 05:04:36 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.at; s=s31663417; t=1727859869; x=1728464669; i=rudalics@gmx.at; bh=C33uoqaxPb4gniJGvkcJXgS9sKGBKJESAYzsnX1lE/w=; 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=FYHZR32JS931AbJQE+N1pFEX1DtuqCd94UjoIn5hUH9W9VLMpIs7UyPy6ViL23KK +36UgAkAvz2IQZk/UIlPQRgNNwr1ZTAuyLJYwObCtLkLeg7K5M1DthKCiPAZ0Gj42 QyafXy0WTqovOs4F4To2nDLeKYsy91J/MnXZCZ7TuYvV8PMQb/hh9+gpsVLGAnrSS +L4DftPlPbhgtNyT/lE/LJaCAgJCKg/03yD7OBp24TgUIwbQrHZ5FTZv6lTw9XdqK C0E6Q2jNpxJSq3e9Y3ElQh6qIO+0XkGW23HwfUNOOdY2NDYZFP9O51zT2HGTTbEpO 7V1ovgESFXz87ZOIrQ== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Original-Received: from [192.168.31.113] ([213.142.97.14]) by mail.gmx.net (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MAfYw-1skwvk3qpM-00G5lA; Wed, 02 Oct 2024 11:04:29 +0200 Content-Language: en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vDKzZKHin6iwsrkWgyOItJuP3mWuRw+KQ3nOdZ3ZZiCnDdHBQnYtJi0mS+5v Received-SPF: pass client-ip=212.227.15.19; envelope-from=rudalics@gmx.at; helo=mout.gmx.net X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.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_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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:324244 Archived-At: >> Alternatively, we could give 'window-tree' an optional PIXELWISE >> argument so it returns the pixel edges of windows. > > You decide Better not - the fact that 'window-tree' does not report the edges of live windows constitutes bad design. Let's not support it. Rather let's make it a normal function called 'window-tree-pixel-sizes'. I would write its doc string 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 window is represented either by a triple whose first element is either t for an internal window that is a horizontal combination, nil for an internal window that is a vertical combination, or the window itself for a live window. The second element is a cons of the pixel height and pixel width of the window. The third element is specified for internal windows only and recursively lists that window's child windows using the same triple structure." but you would have to check whether it really does what I wrote. > (defun rotate-windows-anticlockwise (&optional frame-or-window) > "Rotate windows of FRAME-OR-WINDOW 90 degrees anticlockwise. > See `rotate-windows-clockwise' for more." I think it's better to write out the full doc-string here first and in a final sentence say See `rotate-windows-clockwise' for how to rotate windows in the opposite direction. > (defun rotate-windows-clockwise (&optional frame-or-window) > "Rotate windows of FRAME-OR-WINDOW 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 from the root > window of the frame, otherwise rotate from FRAME-OR-WINDOW." Please add two spaces after the end of each sentence like selected frame. If FRAME-OR-WINDOW is a frame, ... Also I would omit the "from" in "rotate from". And I would add a cross reference to 'rotate-windows-anticlockwise' at the end. > (defun flip-windows-horizontally (&optional frame-or-window) > "Horizontally flip windows of FRAME-OR-WINDOW. > 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 the root > window of the frame, otherwise flip from FRAME-OR-WINDOW." Here you should probably first say what "flip" means. It's obvious when you have a frame with two side-by-side live windows. It's already less obvious with three side-by-side windows and even less so with more complex layouts. > (defun transpose-windows (&optional frame-or-window) > "Transpose windows of FRAME-OR-WINDOW. > Windows are rearanged such that where an horizontal split was used, an > vertical one is instead, and vice versa. FRAME-OR-WINDOW must be a live > frame or window and defaults to the selected frame. If FRAME-OR-WINDOW > is a frame, transpose from the root window of the frame, otherwise > transpose from FRAME-OR-WINDOW." Please us active voice like Rearrange windows such that where a horizontal split was used a vertical one is used instead, and vice versa. and again remove the "from" in "transpose from". > (defun transpose-windows--rearrange (frame-or-window conf norm-size) I'd call this just 'window--transpose'. > "Rearrange windows of FRAME-OR-WINDOW recursively. > CONF should be a cons cell: (HORIZONTAL-SPLIT . VERTICAL-SPLIT) where > horizontal split is called when splitting a window that was previously > horizontally split, and VERTICAL-SPLIT for a window that was previously > vertically split. 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. > When is NORM-SIZE non-nil, the size argument of the I think it's just the pixel size and not the normal size, right? Also you should write it as "When NORM-SIZE is non-nil ..." > (frame-root-window frame-root-window) This doesn't look right. > (message "Not enough windows") Better is "No windows to transpose". > (let* ((fwin (frame-first-window rwin)) Note that 'frame-first-window' returns the first live window on its frame. What if you want to flip some child windows only? > (select-window selwin))))) should become (set-frame-selected-window selwin) for the case that you rotate windows on a non-selected frame. > (defun transpose-windows--rearrange-1 (subtree cwin conf norm-size) And this I'd call 'window--transpose-1' > "Subroutine of `transpose-windows--rearrange'." Again please describe all arguments in the doc-string. And please handle the case where a frame contains side windows. Just replace 'frame-root-window' with 'window--main-window' everywhere and talk about "main window" instead of "root window". Thanks, martin