branch: elpa/golden-ratio
commit e0f783dfa7776b0aa6951f55b408e37752e5b6dd
Author: Roman Gonzalez <[email protected]>
Commit: Roman Gonzalez <[email protected]>

    First commit of golden-ratio.el
---
 .gitignore          |   1 +
 LICENSE             |  20 ++++++++++++++++++++
 README.md           |  37 +++++++++++++++++++++++++++++++++++++
 golden-ratio.el     |  40 ++++++++++++++++++++++++++++++++++++++++
 golden_ratio_el.gif | Bin 0 -> 1208151 bytes
 5 files changed, 98 insertions(+)

diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000000..016d3b1692
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+*.elc
\ No newline at end of file
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000000..de6968fe2c
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,20 @@
+Copyright (c) 2012 Roman Gonzalez
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\ No newline at end of file
diff --git a/README.md b/README.md
new file mode 100644
index 0000000000..197385932d
--- /dev/null
+++ b/README.md
@@ -0,0 +1,37 @@
+# golden-ratio.el
+
+When working with many windows at the same time, each window has a size
+that is not convenient for editing.
+
+golden-ratio helps on this issue by resizing automatically the windows you are
+working on to the size specified in the "Golden Ratio". The window that has the
+main focus will have the perfect size for editing, while the ones that are
+not being actively edited will be re-sized to a smaller size that doesn't get
+in the way, but at the same time will be readable enough to know it's content.
+
+![Golden 
Ratio](https://raw.github.com/roman/golden-ratio.el/master/golden_ratio_el.gif)
+
+For more info about the golden ratio check out
+
+http://en.wikipedia.org/wiki/Golden_ratio
+
+## Install
+
+Use [el-get](https://github.com/dimitri/el-get) to install.
+
+## Usage
+
+To enable automatic resizing, put on your .emacs.d/init.el
+
+```elisp
+(require 'golden-ratio)
+
+(golden-ratio-enable)
+```
+
+***
+
+If you want to disable automatic resizing done by golden-ratio, just invoke
+`(golden-ratio-disable)`
+
+To call golden ratio manually just `M-x golden-ratio`
diff --git a/golden-ratio.el b/golden-ratio.el
new file mode 100644
index 0000000000..b13bb4a7b5
--- /dev/null
+++ b/golden-ratio.el
@@ -0,0 +1,40 @@
+(defun -golden-ratio-dimensions ()
+  (let* ((main-rows     (floor (/ (frame-height) 1.618)))
+         (main-columns  (floor (/ (frame-width)  1.618))))
+    (list main-rows
+          main-columns)))
+
+(defun -golden-ratio-resize-window (dimensions window)
+  (let* ((edges           (window-absolute-pixel-edges window))
+         (nrow            (floor
+                           (- (first dimensions)
+                              (window-height window))))
+         (ncol            (floor
+                           (- (second dimensions)
+                              (window-width window)))))
+    (progn
+      (enlarge-window nrow nil)
+      (enlarge-window ncol t))))
+
+
+(defun golden-ratio ()
+  (interactive)
+  (if (not (window-minibuffer-p))
+      (progn
+        (balance-windows)
+        (-golden-ratio-resize-window (-golden-ratio-dimensions)
+                                     (selected-window)))))
+
+(defadvice select-window
+  (after golden-ratio-resize-window)
+  (golden-ratio))
+
+(defun golden-ratio-enable ()
+  (interactive)
+  (ad-activate 'select-window))
+
+(defun golden-ratio-disable ()
+  (interactive)
+  (ad-deactivate 'select-window))
+
+(provide 'golden-ratio)
diff --git a/golden_ratio_el.gif b/golden_ratio_el.gif
new file mode 100644
index 0000000000..4cb0215627
Binary files /dev/null and b/golden_ratio_el.gif differ

Reply via email to