[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Adding olivetti to GNU ELPA
From: |
Paul W. Rankin |
Subject: |
Re: Adding olivetti to GNU ELPA |
Date: |
Wed, 15 May 2019 18:26:55 +1000 |
User-agent: |
mu4e 1.2.0; emacs 26.2 |
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
- Re: Adding olivetti to GNU ELPA, Paul W. Rankin, 2019/05/08
- Re: Adding olivetti to GNU ELPA, Eli Zaretskii, 2019/05/08
- Re: Adding olivetti to GNU ELPA, Joost Kremers, 2019/05/14
- Re: Adding olivetti to GNU ELPA, Stefan Monnier, 2019/05/14
- Re: Adding olivetti to GNU ELPA, Joost Kremers, 2019/05/14
- Re: Adding olivetti to GNU ELPA, Stefan Monnier, 2019/05/14
- Re: Adding olivetti to GNU ELPA, martin rudalics, 2019/05/20
- Re: Adding olivetti to GNU ELPA, Paul W. Rankin, 2019/05/20
- Re: Adding olivetti to GNU ELPA, martin rudalics, 2019/05/21
- Re: Adding olivetti to GNU ELPA, Paul W. Rankin, 2019/05/21
- Re: Adding olivetti to GNU ELPA, martin rudalics, 2019/05/21
- Re: Adding olivetti to GNU ELPA, Paul W. Rankin, 2019/05/21