branch: externals/olivetti commit 7f3fe83f43be32a02c790e3b209a9d4d08bdcee1 Author: Paul W. Rankin <he...@paulwrankin.com> Commit: Paul W. Rankin <he...@paulwrankin.com>
Conditionally add hooks for Emacs 24 -> 27 --- olivetti.el | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/olivetti.el b/olivetti.el index a15df1b..6e140ce 100644 --- a/olivetti.el +++ b/olivetti.el @@ -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