From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Joost Kremers Newsgroups: gmane.emacs.devel Subject: Re: Window splitting issues with margins Date: Thu, 12 Nov 2015 22:38:38 +0100 Message-ID: <8737wax5i9.fsf@fastmail.fm> References: <874mgrwerb.fsf@fastmail.fm> <5644A2AC.3080703@gmx.at> <83twori3n3.fsf@gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1447364347 20590 80.91.229.3 (12 Nov 2015 21:39:07 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 12 Nov 2015 21:39:07 +0000 (UTC) Cc: martin rudalics , emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Nov 12 22:38:54 2015 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Zwza0-0001ec-VW for ged-emacs-devel@m.gmane.org; Thu, 12 Nov 2015 22:38:53 +0100 Original-Received: from localhost ([::1]:49875 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZwzZz-00033T-Vf for ged-emacs-devel@m.gmane.org; Thu, 12 Nov 2015 16:38:51 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:39626) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZwzZt-0002ui-9i for emacs-devel@gnu.org; Thu, 12 Nov 2015 16:38:48 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZwzZp-0003nw-8B for emacs-devel@gnu.org; Thu, 12 Nov 2015 16:38:45 -0500 Original-Received: from out4-smtp.messagingengine.com ([66.111.4.28]:45852) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZwzZp-0003nk-3M for emacs-devel@gnu.org; Thu, 12 Nov 2015 16:38:41 -0500 Original-Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id ED45A2048C for ; Thu, 12 Nov 2015 16:38:40 -0500 (EST) Original-Received: from frontend2 ([10.202.2.161]) by compute6.internal (MEProxy); Thu, 12 Nov 2015 16:38:40 -0500 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=fastmail.fm; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-sasl-enc :x-sasl-enc; s=mesmtp; bh=uMCNEroonscUfgl5kZ7GTSEvqyo=; b=XUjfLE AM2GcrNzjxxNaBQD1OFNq/LV49H73+ddiFGNEwmhpPIBnWJ0XQ8LSX1RyoAMlsVM 0Teo7y/6WJV+qkoHTT1wfKB3nuwgd+re2QWfPxWY3EKqej8WAwuE4BkZp2JgUBLP RISq5kasw1tYV5DCVAPIQXrq8BeD3kD7qEnig= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-sasl-enc:x-sasl-enc; s=smtpout; bh=uMCNEroonscUfgl 5kZ7GTSEvqyo=; b=TZO9og6rcWZZ+OWLA35Zs+3wTkTUXvf0ApWbDwuA+0xg+03 +25yQxrcm5zRuvfgQ49Us2Mj0faqCGinuQ8qH7oPC+VWzW+KtaOuLG7nIbIG73Hk Lp4ltKU3JArJ/Of6wdttOg8cpW5BW2yo7vLzhoWOm0SEU88KQHGW9k8HRqO0= X-Sasl-enc: jVUCC/E61aVTXNDcOYd6APB8CHbfxQpXalRfBGmHVnsf 1447364320 Original-Received: from IdeaPad.messagingengine.com (x4d0af18f.dyn.telefonica.de [77.10.241.143]) by mail.messagingengine.com (Postfix) with ESMTPA id ECAC0680175; Thu, 12 Nov 2015 16:38:39 -0500 (EST) User-agent: mu4e 0.9.13; emacs 24.5.50.1 In-reply-to: <83twori3n3.fsf@gnu.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 66.111.4.28 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 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.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:194287 Archived-At: On Do, Nov 12 2015, Eli Zaretskii wrote: >> Date: Thu, 12 Nov 2015 15:31:08 +0100 >> From: martin rudalics >> >> Deciding when and how to auto-adjust margins is not trivial. > > I'm not sure margins should be auto-adjusted at all. Whatever > application sets up those margins, they most probably need all that > space, and Emacs should not second guess such applications. For > example, linum-mode sets the margin just wide enough to display the > longest line number; make the margin smaller, and the numbers will be > truncated. That's a bug in my book. Perhaps what is needed is for a mode that uses the margins to be able to specify a minimum size for them, so that a window-resize can take that into account. That would allow other modes to use the margin flexibly. In fact, IIUC this is sorta what the patch that João Távora posted earlier tries to do, but inside linum-mode. I have a package writeroom-mode that is similar to his darkroom-mode and I've received similar bug reports saying that writeroom-mode and linum-mode don't play nice together.[1] What writeroom-mode and darkroom-mode both do is use the margins to display the text of a buffer in the center of the window, to create a "distraction-free writing environment", as it's called. writeroom-mode lets you specify the width of the text and adjusts the margins to make that happen. (Actually, it uses visual-fill-column to do that.) With every window resize, the margins are readjusted. So there's no requirement that the margins have a minimum width, the width depends on whatever the window width happens to be. linum-mode seems to assume that no-one else is using the margins and simply sets the left margin to the width it needs for itself. It'd be great if linum-mode (or any other mode of course) would be able to specify that it needs the left margin to be at least n characters wide and if there were an easy way for other packages to respect this. If it would also be possible to specify a margin width without locking it, then this could help with the issue I posted about. If it's known that parts of the margins are reserved, while others are not, the window-splitting functions know what part of the margins they can safely assume will be adjusted. Perhaps an example to make things clearer: assume a window width of 200 characters. I want my text to be 80 chars wide and centered, so the left and right margins need to be (200-80)/2 = 60 each. Package X sets the margins to 60, but doesn't lock them. linum-mode says it needs a left margin of at least 4, so a width of 4 chars is locked. Now, the window is split and window-splittable-p must determine if the window can be split horizontally. Currently, it will base its judgement on the width of the text area, which is 80, the result being `nil' for 'no, the window cannot be split horizontally'. If a mode could "lock" part of the margin, it would know that it can assume a width of 200-4 = 196 and return `t' for 'yes, the window can be split horizontally'. The window is split and package X (through `window-configuration-change-hook') adjusts the margins. HTH Joost [1] E.g., here: https://github.com/joostkremers/writeroom-mode/issues/20 and here: https://github.com/joostkremers/writeroom-mode/issues/12 -- Joost Kremers Life has its moments