Permalink
Browse files

First commit of golden-ratio.el

  • Loading branch information...
0 parents commit e0f783dfa7776b0aa6951f55b408e37752e5b6dd @roman committed Oct 13, 2012
Showing with 98 additions and 0 deletions.
  1. +1 −0 .gitignore
  2. +20 −0 LICENSE
  3. +37 −0 README.md
  4. +40 −0 golden-ratio.el
  5. BIN golden_ratio_el.gif
@@ -0,0 +1 @@
+*.elc
20 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.
@@ -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`
@@ -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)
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit e0f783d

Please sign in to comment.