branch: elpa/golden-ratio
commit 6851a5f720a01e2716d63574aa1b18a132e607cc
Author: EricGebhart <[email protected]>
Commit: EricGebhart <[email protected]>

    Added golden-ratio-toggle-widescreen function
---
 README.md       | 22 +++++++++++++++++++++-
 golden-ratio.el | 24 +++++++++++++++++++-----
 2 files changed, 40 insertions(+), 6 deletions(-)

diff --git a/README.md b/README.md
index 52799772e4..4d295fb648 100644
--- a/README.md
+++ b/README.md
@@ -36,12 +36,32 @@ If you want to disable automatic resizing done by 
golden-ratio, just invoke
 
 To call golden ratio manually just `M-x golden-ratio`
 
-If you use a large screen and have very wide frames, setting the 
golden-ratio-adjust-width
+***
+
+If you use a large screen and have very wide frames, setting the 
_golden-ratio-adjust-factor_
 variable to something less than 1 will cause the windows to be less wide.
 The golden-ratio-adjust function allows for experimentation with this value.
 
 `M-x golden-ratio-adjust` 
 
+It is also possible to toggle between widescreen and regular width window 
sizing
+with
+
+`M-x golden-ratio-toggle-widescreen`
+
+The variable _golden-ratio-wide-adjust-factor_ can be set to the adjustment 
value 
+you desire the widescreen toggle to use.
+
+The following code will set up golden-ratio to adjust for a moderately wide 
screen
+and also allow toggling between normal, with an adjustment factor of 1, and 
wide with
+an adjustment factor of .8. For a very wide screen/frame of ~3400 px, .4 works 
well giving
+screens with a width ~100 columns wide.
+
+```elisp
+(setq golden-ratio-adjust-factor .8
+      golden-ratio-wide-adjust-factor .8)
+```
+
 ## Credits
 
 Code inspired by ideas from [Tatsuhiro Ujihisa](http://twitter.com/ujm)
diff --git a/golden-ratio.el b/golden-ratio.el
index 1b9f6438f1..6cd24c2f9d 100644
--- a/golden-ratio.el
+++ b/golden-ratio.el
@@ -62,28 +62,42 @@ will not cause the window to be resized to the golden 
ratio."
   :group 'golden-ratio
   :type 'boolean)
 
-(defcustom golden-ratio-adjust-width 1.0
+(defcustom golden-ratio-adjust-factor 1.0
   "Adjust the width sizing by some factor. 1 is no adjustment.
-   For very wide screens/frames .4 may work well."
+   For very wide screens/frames, ie. 3400px, .4 may work well."
   :group 'golden-ratio
   :type 'integer)
 
+(defcustom golden-ratio-wide-adjust-factor 0.8
+  "Width adjustment factor for widescreens. Used when
+   toggling between widescreen and regular modes."
+  :group 'golden-ratio
+  :type 'float)
+
 ;;; Compatibility
 ;;
 (unless (fboundp 'window-resizable-p)
   (defalias 'window-resizable-p 'window--resizable-p))
 
+(defun golden-ratio-toggle-widescreen ()
+  (interactive)
+  (if (= golden-ratio-adjust-factor 1)
+      (setq golden-ratio-adjust-factor golden-ratio-wide-adjust-factor)
+    (setq golden-ratio-adjust-factor 1))
+  (golden-ratio))
+
 (defun golden-ratio-adjust (a)
   "set the adjustment of window widths."
   (interactive
    (list
-    (read-number "Adjust: " golden-ratio-adjust-width)))
-  (setq golden-ratio-adjust-width a))
+    (read-number "Screeen width adjustment factor: " 
golden-ratio-adjust-factor)))
+  (setq golden-ratio-adjust-factor a)
+  (golden-ratio))
 
 (defun golden-ratio--dimensions ()
   (list (floor (/ (frame-height) golden-ratio--value))
         (floor  (* (/ (frame-width)  golden-ratio--value)
-                   golden-ratio-adjust-width))))
+                   golden-ratio-adjust-factor))))
 
 (defun golden-ratio--resize-window (dimensions &optional window)
   (with-selected-window (or window (selected-window))

Reply via email to