From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: "Paul W. Rankin" Newsgroups: gmane.emacs.devel Subject: Re: Adding olivetti to GNU ELPA Date: Wed, 15 May 2019 18:26:55 +1000 Message-ID: References: <83tvemzcn2.fsf@gnu.org> <9bb5fc63-61ae-44dc-a8d5-b67803eab1e5@www.fastmail.com> <83h8amz24g.fsf@gnu.org> <24cca761-36ea-4c16-bce1-e3651aad52c8@www.fastmail.com> <83ftq6yx5o.fsf@gnu.org> <83ftppii16.fsf@gnu.org> <875d1b0c-7f44-ba5d-4660-84637533b8f3@gmx.at> Mime-Version: 1.0 Content-Type: text/plain; format=flowed Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="92439"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: mu4e 1.2.0; emacs 26.2 Cc: martin rudalics , Eli Zaretskii , emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed May 15 10:27:52 2019 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hQpGQ-000NtT-DI for ged-emacs-devel@m.gmane.org; Wed, 15 May 2019 10:27:50 +0200 Original-Received: from localhost ([127.0.0.1]:33358 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hQpGP-000580-9w for ged-emacs-devel@m.gmane.org; Wed, 15 May 2019 04:27:49 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:39145) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hQpFm-00057v-OK for emacs-devel@gnu.org; Wed, 15 May 2019 04:27:11 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hQpFl-0007wW-J3 for emacs-devel@gnu.org; Wed, 15 May 2019 04:27:10 -0400 Original-Received: from wout4-smtp.messagingengine.com ([64.147.123.20]:33047) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hQpFj-0007pM-Bk; Wed, 15 May 2019 04:27:07 -0400 Original-Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.west.internal (Postfix) with ESMTP id CE559579; Wed, 15 May 2019 04:27:04 -0400 (EDT) Original-Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Wed, 15 May 2019 04:27:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paulwrankin.com; h=references:from:to:cc:subject:in-reply-to:date:message-id :mime-version:content-type; s=fm3; bh=4o3MEPwngypHNU9Q8ZkzH5Xyt9 f0NBIkF8KNILqXtDE=; b=i4xfb5cyKSsapyAW7dG6FQi1xW90Y1arneDhAzf+/6 eQ6J6VwUTg2qpvsIfJ+fTvdksdMUcHJFE+BA5j/hfClWzTrMOcD08zRJh1t/lccS gWgmvG0OraM4o1GLpk66gzf8vxPCOVUyuvolPF6kpN+1oiazottrwS5+M5JmGhEO K4A36ccbzC1eS/puAyyf/MgfN9/XIFweZfLQZTCPZeoF/xnvssPtjB31Gh/70F9e TI84ucuWjtv1FC2l72gHtUA6Mm8OU0YTC29GZxkdC64vZ0Z/z/Wc1jY/aFswRGSW 1U+at8PVtWi3Zit82RtDIcIQbNo2gfbBFBwnG7b+KptQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=4o3MEP wngypHNU9Q8ZkzH5Xyt9f0NBIkF8KNILqXtDE=; b=oBQ/DxUBtqI91/RPV0eK4Q QFR0Sxq/CubdBqfbV01VFiQKh+pwI2y1leXfReEEmJHcZ9qO/sZuGT6PEE3HoQSI n4N+MqbGL6S6o4OVaqqRKMCM0jnxVyB1xl4DeHdccO1EDt0dQWaG7e+C8uEPzzRx Mw459PMNj1SndPmTDJqwE/bwsqF00/H5j2/yg69Ei747rLXBLRxRV+oxRz0aKOdM bzQl6CPXGKMLNXxEs1NDsKMU6FqOIpDTiDOb08evSSA8VjoZb7rb9novAFjP5RVH X4LGkEdg5KVwwFLFJRKVWrMsWOOR6pzGx09vORjjX8eH/eYwHR9bRa7bz6PxyzDg == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduuddrleekgddthecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpehffgfhvffujgffkfggtgesthdtredttdertdenucfhrhhomhepfdfrrghulhcu hgdrucftrghnkhhinhdfuceohhgvlhhlohesphgruhhlfihrrghnkhhinhdrtghomheqne cuffhomhgrihhnpehprghulhifrhgrnhhkihhnrdgtohhmnecukfhppeduvddtrddvvddr vddtfedrvddtjeenucfrrghrrghmpehmrghilhhfrhhomhephhgvlhhlohesphgruhhlfi hrrghnkhhinhdrtghomhenucevlhhushhtvghrufhiiigvpedt X-ME-Proxy: Original-Received: from localhost (unknown [120.22.203.207]) by mail.messagingengine.com (Postfix) with ESMTPA id 30C06103D0; Wed, 15 May 2019 04:27:01 -0400 (EDT) In-reply-to: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 64.147.123.20 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 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" Xref: news.gmane.org gmane.emacs.devel:236535 Archived-At: I think the patch below should cover all the bases, from 24 -> 27, using window-configuration-change-hook and window-size-change-functions: - for Emacs 24, we just use window-configuration-change-hook - for Emacs 25 & 26 we use the combination architected by Stefan - for Emacs 27, just window-size-change-functions This doesn't cover for window size changes in Emacs 26 (25?) when display-line-numbers-mode scrolls from 99 to 100, but I spent hours trying to get that working a while back to no avail... *shrug* diff --git a/olivetti.el b/olivetti.el index a64607e..6e140ce 100644 --- a/olivetti.el +++ b/olivetti.el @@ -259,7 +259,7 @@ fraction of the window width." (read-number "Set text body width (integer or float): " olivetti-body-width)))) (setq olivetti-body-width n) - (olivetti-set-margins) + (olivetti-set-all-margins) (message "Text body width set to %s" olivetti-body-width)) (defun olivetti-expand (&optional arg) @@ -273,7 +273,7 @@ If prefixed with ARG, incrementally decrease." ((floatp olivetti-body-width) (+ olivetti-body-width (* 0.01 p)))))) (setq olivetti-body-width (olivetti-safe-width n (selected-window)))) - (olivetti-set-margins) + (olivetti-set-all-margins) (message "Text body width set to %s" olivetti-body-width) (set-transient-map (let ((map (make-sparse-keymap))) @@ -312,10 +312,17 @@ body width set with `olivetti-body-width'." :lighter olivetti-lighter (if olivetti-mode (progn - (add-hook 'window-size-change-functions - #'olivetti-set-margins t t) - (add-hook 'window-configuration-change-hook - 'olivetti-set-all-margins t t) + (cond ((<= emacs-major-version 24) + (add-hook 'window-configuration-change-hook + #'olivetti-set-all-margins t t)) + ((<= emacs-major-version 26) + (add-hook 'window-configuration-change-hook + #'olivetti-set-all-margins t t) + (add-hook 'window-size-change-functions + #'olivetti-set-margins t t)) + ((<= 27 emacs-major-version) + (add-hook 'window-size-change-functions + #'olivetti-set-margins t t))) (add-hook 'change-major-mode-hook #'olivetti-reset-all-windows nil t) (setq-local split-window-preferred-function -- https://www.paulwrankin.com