From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: joaotavora@gmail.com (=?utf-8?B?Sm/Do28gVMOhdm9yYQ==?=) Newsgroups: gmane.emacs.devel Subject: Re: PATCH: make linum.el play nicely with other margin-setting extensions Date: Fri, 13 Nov 2015 08:32:57 +0000 Message-ID: References: <83vb97i3ta.fsf@gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1447403600 15937 80.91.229.3 (13 Nov 2015 08:33:20 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 13 Nov 2015 08:33:20 +0000 (UTC) Cc: markus.triska@gmx.at, emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Nov 13 09:33:15 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 1Zx9nH-0005s9-42 for ged-emacs-devel@m.gmane.org; Fri, 13 Nov 2015 09:33:15 +0100 Original-Received: from localhost ([::1]:51620 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zx9nG-0006pF-2K for ged-emacs-devel@m.gmane.org; Fri, 13 Nov 2015 03:33:14 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:35536) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zx9n3-0006pA-VZ for emacs-devel@gnu.org; Fri, 13 Nov 2015 03:33:02 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zx9n0-0008Se-Pd for emacs-devel@gnu.org; Fri, 13 Nov 2015 03:33:01 -0500 Original-Received: from mail-wm0-x231.google.com ([2a00:1450:400c:c09::231]:35088) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zx9n0-0008SY-JG; Fri, 13 Nov 2015 03:32:58 -0500 Original-Received: by wmdw130 with SMTP id w130so19056209wmd.0; Fri, 13 Nov 2015 00:32:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-type:content-transfer-encoding; bh=cyJW5+Ge8cO/ZGVQutGOwG0teJkXCiNZRjabM8Uns2A=; b=0DYwJ2u1W82kFupD2SAZSfKBjt+QqbadXe8pMg7ye5AswNi2EfD4qfz1ApC+aZ8B2j z0V7fISk6JFcHOqTbLNhCtKGbK9FDgIbTS5i+bbaz3RPJgwRe5lE8gxLJ6N/K2vW5AAX dZlvIVIVeaqnM3iwGFPfiDjsNWJFt3byWVW49o5W6n5LwbFU9znbejD245xdCjujHbx4 N0xteoCuWksG9Pz3W1VzUE3HDSEfIKxEJMJh7DaB8yfXJpAc4Spgb8DzJ9govF3yy5TV Gx3ajzHo+i3aF2UI08i/DIav+HAggWIbs3W/5BOTvcY3dajOloFsQLVjCuhzDRljPLB2 WyQg== X-Received: by 10.28.141.17 with SMTP id p17mr1184072wmd.35.1447403578007; Fri, 13 Nov 2015 00:32:58 -0800 (PST) Original-Received: from king.yourcompany.com (31.57.37.188.rev.vodafone.pt. [188.37.57.31]) by smtp.gmail.com with ESMTPSA id i18sm2813377wmf.6.2015.11.13.00.32.56 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 13 Nov 2015 00:32:57 -0800 (PST) In-Reply-To: <83vb97i3ta.fsf@gnu.org> (Eli Zaretskii's message of "Thu, 12 Nov 2015 18:24:17 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (darwin) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:400c:c09::231 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:194331 Archived-At: Eli Zaretskii writes: >> From: joaotavora@gmail.com (Jo=C3=A3o T=C3=A1vora) >> Date: Thu, 12 Nov 2015 12:23:02 +0000 >>=20 >> The problem popped up in darkroom.el which is in ELPA. The margins >> aren't correctly in any situation intermingling calls to M-x linum-mode >> and M-x darkroom-mode. >>=20 >> This patch to linum.el appears to work nicely, and probably fixes stuff >> for other margin-setting extensions, but I'd like a review from the >> maintainer or someone else more knowledgeable: > > Thanks. > > I'm not familiar with darkroom-mode. Can you tell in more detail what > problem your patch attempts to solve? Sure, darkroom-mode (and many other "writeroom" clones) hide visual distractions to simulate an 1980's text-processing experience. :-) In Emacs that means adjusting the left and right margins to center the text on a narrower section of the window. So, if you `M-x linum-mode` after `M-x darkroom-mode` you almost immediately lose the left margin that darkroom-mode set: it now now only shows the linum line numbers numbers. Similarly, if you `M-x darkroom-mode` after `M-x linum-mode`, `darkroom-mode` can't set the margin. Other problems happen when exiting those modes. Read on for some explanation regarding the workings of the patch, or read the patch itself. linum.el uses the left margin to make just enough to show numbered indicators. The gist of this patch is: if there is enough space there already, linum.el won't set the left margin width. But if it does, it records that fact in a window parameter, to check later, when turning off linum-mode, if resetting the margin is needed. In this situation, resetting the margin is only needed if linum-mode was the only extension to touch it, otherwise one considers that some other extension or interactive "set-margins" call touched the margins. The way I implemented "some other extension ... touched the margins" is an equal test of current margins vs remembered set margins. It seems robust enough for now, but ideally linum-mode would know that "his" margins have been overriden interactively or by some other extension, and decide in accordance. In fact, this pattern of multiple extensions/commands competing for a Emacs setting is relatively common, I wonder we could abstract some more generic solution...=20 --=20 Jo=C3=A3o T=C3=A1vora