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

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

[nongnu] elpa/golden-ratio f5807212d3 88/95: Merge pull request #81 from


From: ELPA Syncer
Subject: [nongnu] elpa/golden-ratio f5807212d3 88/95: Merge pull request #81 from wictory/pr_20190406
Date: Thu, 7 Sep 2023 22:02:16 -0400 (EDT)

branch: elpa/golden-ratio
commit f5807212d3349c1065cfeebf3e895aebba862bbf
Merge: 9059e1d139 c5e916d238
Author: Roman Gonzalez <roman@users.noreply.github.com>
Commit: GitHub <noreply@github.com>

    Merge pull request #81 from wictory/pr_20190406
    
    Add fixed width feature
---
 README.md       | 15 +++++++++++++++
 golden-ratio.el | 12 ++++++++++--
 2 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/README.md b/README.md
index 9a7b913bfb..1276fdba87 100644
--- a/README.md
+++ b/README.md
@@ -72,6 +72,21 @@ screens with a width ~100 columns wide.
       golden-ratio-wide-adjust-factor .8)
 ```
 
+## Fixed width
+
+When working with files that are required to have a maximum line width or when 
writing text it's
+sometimes good to have a fixed width on the window you are typing in. For 
example when editing this
+files it's nice to set:
+```elisp
+(setq golden-ratio-max-width 100)
+```
+
+When I write I like to have two empty buffers on the side and set
+```elisp
+(setq golden-ratio-max-width 72)
+```
+to get a distraction free experience.
+
 ## Credits
 
 Code inspired by ideas from [Tatsuhiro Ujihisa](http://twitter.com/ujm)
diff --git a/golden-ratio.el b/golden-ratio.el
index 728f480b35..0b6103e62b 100644
--- a/golden-ratio.el
+++ b/golden-ratio.el
@@ -80,6 +80,11 @@ will not cause the window to be resized to the golden ratio."
   :group 'golden-ratio
   :type 'boolean)
 
+(defcustom golden-ratio-max-width nil
+  "Set a maximum column width on the active window."
+  :group 'golden-ratio
+  :type 'integer)
+
 (defcustom golden-ratio-exclude-buffer-regexp nil
   "A list of regexp's used to match buffer names.
 Switching to a buffer whose name matches one of these regexps
@@ -114,8 +119,11 @@ will prevent the window to be resized to the golden ratio."
 
 (defun golden-ratio--dimensions ()
   (list (floor (/ (frame-height) golden-ratio--value))
-        (floor  (* (/ (frame-width)  golden-ratio--value)
-                   (golden-ratio--scale-factor)))))
+        (let ((width (floor  (* (/ (frame-width)  golden-ratio--value)
+                                (golden-ratio--scale-factor)))))
+          (if golden-ratio-max-width
+              (min golden-ratio-max-width width)
+            width))))
 
 (defun golden-ratio--resize-window (dimensions &optional window)
   (with-selected-window (or window (selected-window))



reply via email to

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