[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/olivetti 4f9210b 074/134: Don't use min-margins - there
From: |
Stefan Monnier |
Subject: |
[elpa] externals/olivetti 4f9210b 074/134: Don't use min-margins - there is a better way |
Date: |
Thu, 25 Apr 2019 09:57:32 -0400 (EDT) |
branch: externals/olivetti
commit 4f9210bda4b6340a5e8a459f240785b57e0cbd87
Author: Paul Rankin <address@hidden>
Commit: Paul Rankin <address@hidden>
Don't use min-margins - there is a better way
---
olivetti.el | 34 ++++++++++++++++++++++++++--------
1 file changed, 26 insertions(+), 8 deletions(-)
diff --git a/olivetti.el b/olivetti.el
index 69839a3..7eaa40d 100644
--- a/olivetti.el
+++ b/olivetti.el
@@ -225,10 +225,7 @@ If ARG is 'exit set window margins to nil.
If ARG is nil, first find the `olivetti-safe-width' to which to
set `olivetti-body-width', then find the appropriate margin size
relative to each window. Finally set the window margins, taking
-care that the maximum size is 0.
-
-Also set the window parameter 'min-margins to half of the margin
-current width."
+care that the maximum size is 0."
(dolist (window (get-buffer-window-list (current-buffer) nil t))
(if (eq arg 'exit)
(set-window-margins window nil nil)
@@ -242,10 +239,7 @@ current width."
(margin (max (round (/ (- (window-total-width window)
width)
2))
- 0))
- (min-margin (floor (/ (float margin)
- 2))))
- (set-window-parameter window 'min-margins (cons min-margin min-margin))
+ 0)))
(set-window-margins window margin margin)))))
(defun olivetti-toggle-hide-mode-line ()
@@ -283,6 +277,28 @@ If prefixed with ARG, incrementally increase."
(olivetti-expand p)))
+;;; 25.1 Workaround
+
+(defun split-window-right-force (&optional size)
+ "Filter arguments to `split-window-right' to force splitting window.
+
+If optional argument SIZE is ommitted or nil, both windows get
+the same width."
+ (if (car size) size (list (/ (window-total-width) 2))))
+
+(defun olivetti-patch-split-window (&optional remove)
+ "Adds advice to `split-window-right' to workaround `window-min-size'.
+
+If REMOVE is non-nil, remove this advice."
+ (if remove
+ (advice-remove 'split-window-right 'split-window-right-force)
+ (unless (or (advice-member-p 'split-window-right-force 'split-window-right)
+ (version< emacs-version "25"))
+ (advice-add 'split-window-right :filter-args
+ 'split-window-right-force)
+ (message "olivetti: Function `split-window-right' has been patched"))))
+
+
;;; Mode Definition
;;;###autoload
@@ -323,11 +339,13 @@ hidden."
(visual-line-mode 1))
(if olivetti-hide-mode-line
(olivetti-set-mode-line))
+ (olivetti-patch-split-window)
(olivetti-set-environment))
(dolist (hook '(window-configuration-change-hook
after-setting-font-hook
text-scale-mode-hook))
(remove-hook hook 'olivetti-set-environment t))
+ (olivetti-patch-split-window 'remove)
(olivetti-set-mode-line 'exit)
(olivetti-set-environment 'exit)
(if (and olivetti-recall-visual-line-mode-entry-state
- [elpa] externals/olivetti bb7b2ce 007/134: Doc cleanup, (continued)
- [elpa] externals/olivetti bb7b2ce 007/134: Doc cleanup, Stefan Monnier, 2019/04/25
- [elpa] externals/olivetti 751b90f 028/134: Fixes #3, Stefan Monnier, 2019/04/25
- [elpa] externals/olivetti c2b1100 025/134: Updated README and Commentary, Stefan Monnier, 2019/04/25
- [elpa] externals/olivetti 1553934 079/134: Move hide-mode-line into set-environment, Stefan Monnier, 2019/04/25
- [elpa] externals/olivetti 39271d0 082/134: Only reset split-window param if olivetti-split-window, Stefan Monnier, 2019/04/25
- [elpa] externals/olivetti 4c8b62f 094/134: Updating README/Commentary, Stefan Monnier, 2019/04/25
- [elpa] externals/olivetti 35d275d 104/134: deleted: TODO.md, Stefan Monnier, 2019/04/25
- [elpa] externals/olivetti 38b2eb4 110/134: Limit window-width to 2* largest fringe, Stefan Monnier, 2019/04/25
- [elpa] externals/olivetti 8558589 111/134: Rewrite olivetti-set-environment, Stefan Monnier, 2019/04/25
- [elpa] externals/olivetti ef3d85e 051/134: Updated copyright, Stefan Monnier, 2019/04/25
- [elpa] externals/olivetti 4f9210b 074/134: Don't use min-margins - there is a better way,
Stefan Monnier <=
- [elpa] externals/olivetti 3f237b0 075/134: Use split-window window-parameter, Stefan Monnier, 2019/04/25
- [elpa] externals/olivetti e515385 083/134: Docstring update, Stefan Monnier, 2019/04/25
- [elpa] externals/olivetti de2716c 081/134: Only reset all windows on exit, Stefan Monnier, 2019/04/25
- [elpa] externals/olivetti fd5d85b 097/134: Enhance short description, Stefan Monnier, 2019/04/25
- [elpa] externals/olivetti 85ecdfc 099/134: Revert "Enhance short description", Stefan Monnier, 2019/04/25
- [elpa] externals/olivetti 7bf367c 105/134: Updated README/Commentary, Stefan Monnier, 2019/04/25
- [elpa] externals/olivetti 7eadbe7 108/134: Rewrite olivetti-safe-width for fringes, Stefan Monnier, 2019/04/25
- [elpa] externals/olivetti fc3b045 116/134: Readded window-configuration-change-hook, Stefan Monnier, 2019/04/25
- [elpa] externals/olivetti ff2b0a0 123/134: Change default body width to 70 (matches fill-column standard-value), Stefan Monnier, 2019/04/25
- [elpa] externals/olivetti cb22f8a 127/134: Merge pull request #25 from Nielius/fix-scale-width, Stefan Monnier, 2019/04/25