From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: "Drew Adams" Newsgroups: gmane.emacs.devel Subject: wanted: someone to integrate frame-resizing code Date: Fri, 28 May 2004 14:10:50 -0700 Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1085779918 7633 80.91.224.253 (28 May 2004 21:31:58 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 28 May 2004 21:31:58 +0000 (UTC) Original-X-From: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Fri May 28 23:31:48 2004 Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1BToxA-0008LH-00 for ; Fri, 28 May 2004 23:31:48 +0200 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.35 #1 (Debian)) id 1BToxA-0001yW-00 for ; Fri, 28 May 2004 23:31:48 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.34) id 1BToea-00086n-BU for emacs-devel@quimby.gnus.org; Fri, 28 May 2004 17:12:36 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.34) id 1BToda-00086N-1L for emacs-devel@gnu.org; Fri, 28 May 2004 17:11:34 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.34) id 1BTod2-00081K-UB for emacs-devel@gnu.org; Fri, 28 May 2004 17:11:32 -0400 Original-Received: from [148.87.2.201] (helo=inet-mail1.oracle.com) by monty-python.gnu.org with esmtp (TLSv1:DES-CBC3-SHA:168) (Exim 4.34) id 1BTod2-00080H-3Q for emacs-devel@gnu.org; Fri, 28 May 2004 17:11:00 -0400 Original-Received: from rgmgw3.us.oracle.com (rgmgw3.us.oracle.com [138.1.191.12]) by inet-mail1.oracle.com (Switch-3.1.4/Switch-3.1.0) with ESMTP id i4SLCABY023740 for ; Fri, 28 May 2004 14:12:10 -0700 (PDT) Original-Received: from rgmgw3.us.oracle.com (localhost [127.0.0.1]) by rgmgw3.us.oracle.com (Switch-3.1.4/Switch-3.1.0) with ESMTP id i4SLAsJq013109 for ; Fri, 28 May 2004 15:10:54 -0600 Original-Received: from dradamslap (dhcp-amer-vpn-gw2-east-141-144-83-64.vpn.oracle.com [141.144.83.64]) by rgmgw3.us.oracle.com (Switch-3.1.4/Switch-3.1.0) with SMTP id i4SLArGo013096 for ; Fri, 28 May 2004 15:10:53 -0600 Original-To: X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.6604 (9.0.2911.0) X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 Importance: Normal X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.4 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:24098 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:24098 RMS suggested I provide emacs-devel a summary of our conclusions regarding some code I wrote to resize frames, and ask if there is anyone who would be willing to integrate it (I do not have the resources to do that). I've tested the code in Emacs 20 and 21.3.50 on Windows. The code is especially useful when pop-up-frames is non-nil; that is, when you use frames instead of Emacs windows by default. The code is here: - http://www.emacswiki.org/elisp/shrink-fit.el - a command, shrink-frame-to-fit, that fits a frame to its selected window (should probably be renamed resize-frame) - http://www.emacswiki.org/elisp/shrink-fit-all.el - provides automatic frame resizing when appropriate There are user variables to turn resizing on & off. Automatic resizing applies only to one-window frames (the selected window is one-window-p). Requirements - * Frames should be automatically resized: - When you create a new frame for a buffer. - When you read a different buffer into a frame. - When you display a buffer whose contents have changed since last display. For instance, when a *Help* frame is raised, you want it to be the right size each time. * Frames should *not* be automatically resized: - When the frame's buffer and its contents have not changed since last display. This is the case, for instance, for *Occur* when the source buffer doesn't change and you just redisplay it to access a different source line. - When a buffer is displayed before it has been filled. This is the case, for instance, for output buffers like *grep*. Ideally, the code logic would follow these requirements exactly. My code is not so sophisticated. If someone integrates the code it would be good to consider a smarter implementation. I simply added frame resizing to each of the basic display functions (display-buffer, pop-to-buffer, switch-to-buffer). Without other changes elsewhere this doesn't take into account the two requirements of *not* resizing when inappropriate. For instance, occur-* commands call pop-to-buffer, and if the user already manually sized the source-code buffer (and wants it to stay put), resizing it automatically would be annoying. Similarly, in compile, you want to resize the frame explicitly after the buffer is full, not prematurely when display-buffer is called on an empty output buffer. The way I dealt with this was essentially a hack: In those places where resizing would be inappropriate, I set a variable that inhibited resizing in the basic display functions like pop-to-buffer. This is equivalent to having two versions of each display function like pop-to-buffer, one that resizes and one that doesn't, and calling the right one (analogy: find-file-no-select vs find-file). In practice, I only found two places where I needed to inhibit automatic resizing: compile-internal and occur. However, I did not test exhaustively with Emacs 21; there are perhaps other places where resizing should not be done. I've used this with Emacs 20 for years with no inconvenience, but I don't use all of Emacs. For a more sophisticated solution, perhaps it would be possible to detect (in resize-frame) whether or not the buffer had changed (either a different buffer or changed content) since the last resizing of that frame (no matter how it was resized: by the user or by program). If someone decides to take this up, feel free to contact me with questions. If no one has the time or interest to take up the automatic resizing, consider at least adding command resize-frame to Emacs (http://www.emacswiki.org/elisp/shrink-fit.el). Thanks Drew P.S. For more info: http://www.emacswiki.org/cgi-bin/wiki/Shrink-Wrapping_Frames