[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/olivetti 18a9a8e 071/134: Use min-margins instead of sp
From: |
Stefan Monnier |
Subject: |
[elpa] externals/olivetti 18a9a8e 071/134: Use min-margins instead of split-window-right-force |
Date: |
Thu, 25 Apr 2019 09:57:31 -0400 (EDT) |
branch: externals/olivetti
commit 18a9a8ec531dea0eaec0563d736695b3aabb3f70
Author: Paul Rankin <address@hidden>
Commit: Paul Rankin <address@hidden>
Use min-margins instead of split-window-right-force
Set window parameter 'min-margins to half of current margins for
olivetti-set-environment
Always specify the window for olivetti-safe-width
---
README.md | 8 --------
olivetti.el | 63 +++++++++++++++----------------------------------------------
2 files changed, 15 insertions(+), 56 deletions(-)
diff --git a/README.md b/README.md
index 8cd10e2..9d0c246 100644
--- a/README.md
+++ b/README.md
@@ -57,14 +57,6 @@ Known Bugs
- `linum-mode` currently has a bug that overwrites margin settings,
making it incompatible with Olivetti. More information here:
<http://debbugs.gnu.org/20674>.
-- Emacs 25.1 introduced changes to `window-min-width` that return
- erroneously large minimum window widths when using large window
- margins, causing `split-window-right` to fail with a misleading
- error message. This necessitates Olivetti patching `split-window-right`
- to always split the window in half (in line with its documentation
- string). This is designed as a temporary workaround until the Emacs
- maintainers fix the problems with `window-min-width`.
- See <http://debbugs.gnu.org/24193>.
Please report bugs on GitHub [Issues][] page.
diff --git a/olivetti.el b/olivetti.el
index 6395e4c..1cea3c5 100644
--- a/olivetti.el
+++ b/olivetti.el
@@ -67,14 +67,6 @@
;; - `linum-mode` currently has a bug that overwrites margin settings,
;; making it incompatible with Olivetti. More information here:
;; <http://debbugs.gnu.org/20674>.
-;; - Emacs 25.1 introduced changes to `window-min-width` that return
-;; erroneously large minimum window widths when using large window
-;; margins, causing `split-window-right` to fail with a misleading
-;; error message. This necessitates Olivetti patching `split-window-right`
-;; to always split the window in half (in line with its documentation
-;; string). This is designed as a temporary workaround until the Emacs
-;; maintainers fix the problems with `window-min-width`.
-;; See <http://debbugs.gnu.org/24193>.
;; Please report bugs on GitHub [Issues][] page.
@@ -190,10 +182,10 @@ face, scale N by that factor, otherwise scale by 1."
1)))
(round (* n face-height))))
-(defun olivetti-safe-width (n)
- "Parse N to a safe value for `olivetti-body-width'."
- (let ((window-width (- (window-total-width)
- (% (window-total-width) 2)))
+(defun olivetti-safe-width (n window)
+ "Parse N to a safe value for `olivetti-body-width' for WINDOW."
+ (let ((window-width (- (window-total-width window)
+ (% (window-total-width window) 2)))
(min-width (+ olivetti-minimum-body-width
(% olivetti-minimum-body-width 2))))
(cond ((integerp n)
@@ -235,19 +227,26 @@ 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."
+care that the maximum size is 0.
+
+Also set the window parameter 'min-margins to half of the margin
+current width."
(dolist (window (get-buffer-window-list (current-buffer) nil t))
(if (equal arg 'exit)
(set-window-margins window nil nil)
(let* ((n (olivetti-safe-width (if (integerp olivetti-body-width)
(olivetti-scale-width
olivetti-body-width)
- olivetti-body-width)))
+ olivetti-body-width)
+ window))
(width (cond ((integerp n) n)
((floatp n) (* (window-total-width window)
n))))
(margin (max (round (/ (- (window-total-width window) width)
2))
- 0)))
+ 0))
+ (min-margin (floor (/ (float margin)
+ 2))))
+ (set-window-parameter window 'min-margins (cons min-margin min-margin))
(set-window-margins window margin margin)))))
(defun olivetti-toggle-hide-mode-line ()
@@ -268,7 +267,7 @@ If prefixed with ARG, incrementally decrease."
(+ olivetti-body-width (* 2 p)))
((floatp olivetti-body-width)
(+ olivetti-body-width (* 0.01 p))))))
- (setq olivetti-body-width (olivetti-safe-width n)))
+ (setq olivetti-body-width (olivetti-safe-width n (selected-window))))
(olivetti-set-environment)
(message "Text body width set to %s" olivetti-body-width)
(set-transient-map
@@ -285,38 +284,6 @@ If prefixed with ARG, incrementally increase."
(olivetti-expand p)))
-;;; Patch Emacs Bugs
-
-(defcustom olivetti-patch-emacs-bugs
- t
- "Attempt to patch known bugs in Emacs."
- :type 'boolean
- :group 'olivetti)
-
-(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.
-
-Workaround for known Emacs bug in `window-min-size'.
-See <http://debbugs.gnu.org/24193>."
- (if (car size) size (list (/ (window-total-width) 2))))
-
-(defun olivetti-patch-emacs-bugs ()
- "Attempt to patch known bugs in Emacs.
-
-Adds advice to `split-window-right' to workaround changes in
-`window-min-size' that return erronously large minimum window
-width when using large margins.
-See <http://debbugs.gnu.org/24193>."
- (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
- [elpa] externals/olivetti 2e92258 103/134: Consider fringe width in current window when setting environment, (continued)
- [elpa] externals/olivetti 2e92258 103/134: Consider fringe width in current window when setting environment, Stefan Monnier, 2019/04/25
- [elpa] externals/olivetti cd2fdca 101/134: Added alt recommendation for writeroom-mode, Stefan Monnier, 2019/04/25
- [elpa] externals/olivetti 4344261 109/134: Don't round olivetti-scale-width, Stefan Monnier, 2019/04/25
- [elpa] externals/olivetti 6893bef 107/134: Added Ethereum and Bitcoin Cash addresses, Stefan Monnier, 2019/04/25
- [elpa] externals/olivetti b1759ab 117/134: Remove crypto addresses, Stefan Monnier, 2019/04/25
- [elpa] externals/olivetti f5c4565 119/134: Deleted repeated word in README.md, Stefan Monnier, 2019/04/25
- [elpa] externals/olivetti c516083 120/134: Merge pull request #21 from smythp/master, Stefan Monnier, 2019/04/25
- [elpa] externals/olivetti 0227265 125/134: Update package version number, and text keyword, Stefan Monnier, 2019/04/25
- [elpa] externals/olivetti 46fdcfe 134/134: Assign copyright to Free Software Foundation, Stefan Monnier, 2019/04/25
- [elpa] externals/olivetti a7f6477 118/134: Add LICENSE.txt, remove README license badge, Stefan Monnier, 2019/04/25
- [elpa] externals/olivetti 18a9a8e 071/134: Use min-margins instead of split-window-right-force,
Stefan Monnier <=
- [elpa] externals/olivetti 050815f 113/134: Use internal rounding for olivetti-safe-width, Stefan Monnier, 2019/04/25
- [elpa] externals/olivetti da7955a 088/134: Added TODO.md, Stefan Monnier, 2019/04/25
- [elpa] externals/olivetti 914af43 096/134: Update copyright year to add 2017, Stefan Monnier, 2019/04/25
- [elpa] externals/olivetti e824a21 106/134: Remove disparaging remarks about display-line-numbers-mode, Stefan Monnier, 2019/04/25
- [elpa] externals/olivetti da1ef8e 114/134: Improving olivetti-safe-width, Stefan Monnier, 2019/04/25
- [elpa] externals/olivetti d40a054 126/134: Fixed olivetti-scale-width for integer heights, Stefan Monnier, 2019/04/25
- [elpa] externals/olivetti 2ae21fa 128/134: Remove redundant turn-on-olivetti-mode function, Stefan Monnier, 2019/04/25
- [elpa] externals/olivetti 7c4410f 133/134: Rename olivetti-set-environment -> olivetti-set-margins, Stefan Monnier, 2019/04/25
- [elpa] externals/olivetti 40c64f9 131/134: Remove window-configuration-change-hook, Stefan Monnier, 2019/04/25
- [elpa] externals/olivetti 26f3db0 050/134: Updated README/Commentary, Stefan Monnier, 2019/04/25