emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/olivetti d0d2bc0 067/134: Attempt to patch known Emacs


From: Stefan Monnier
Subject: [elpa] externals/olivetti d0d2bc0 067/134: Attempt to patch known Emacs bugs.
Date: Thu, 25 Apr 2019 09:57:30 -0400 (EDT)

branch: externals/olivetti
commit d0d2bc0c12549e7cba5e3a5027591a32c8568c15
Author: Paul Rankin <address@hidden>
Commit: Paul Rankin <address@hidden>

    Attempt to patch known Emacs bugs.
    
    Adds advice to split-window-right to workaround changes in
    window-min-size that return erronously large minimum window width when
    using large margins.
---
 olivetti.el | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)

diff --git a/olivetti.el b/olivetti.el
index 62cd8a3..b0901c0 100644
--- a/olivetti.el
+++ b/olivetti.el
@@ -278,6 +278,37 @@ 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 split.
+
+If optional argument SIZE is ommitted or nil, split window
+exactly in half.
+
+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)
+              (< (string-to-number emacs-version) 25))
+      (advice-add 'split-window-right :filter-args
+                  'split-window-right-force)))
+
+
 ;;; Mode Definition
 
 ;;;###autoload
@@ -318,6 +349,8 @@ hidden."
           (visual-line-mode 1))
         (if olivetti-hide-mode-line
             (olivetti-set-mode-line))
+        (if olivetti-patch-emacs-bugs
+            (olivetti-patch-emacs-bugs))
         (olivetti-set-environment))
     (remove-hook 'window-configuration-change-hook
                  #'olivetti-set-environment t)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]