Skip to content

Commit

Permalink
Adding "emacs package standards" to golden-ratio.el
Browse files Browse the repository at this point in the history
  • Loading branch information
roman committed Oct 14, 2012
1 parent 8a1214c commit 0f42738
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions golden-ratio.el
Original file line number Diff line number Diff line change
@@ -1,9 +1,26 @@
;;; golden-ratio.el --- Automatic resizing of Emacs windows to the golden ratio

;; Copyright (C) 2012 Roman Gonzalez

;; Author: Roman Gonzalez <romanandreg@gmail.com>
;; Mantainer: Roman Gonzalez <romanandreg@gmail.com>
;; Created: 13 Oct 2012
;; Keywords: Window Resizing
;; Version: 0.0.2

;; This file is not part of GNU Emacs.

;; This file is free software (MIT License)

;;; Code:

(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
Expand All @@ -18,6 +35,7 @@


(defun golden-ratio ()
"Resizes current window to the golden-ratio's size specs"
(interactive)
(if (and (not (window-minibuffer-p))
(not (one-window-p)))
Expand All @@ -26,16 +44,24 @@
(-golden-ratio-resize-window (-golden-ratio-dimensions)
(selected-window)))))


(defadvice select-window
(after golden-ratio-resize-window)
(golden-ratio))


(defun golden-ratio-enable ()
"Enables golden-ratio's automatic window resizing"
(interactive)
(ad-activate 'select-window))


(defun golden-ratio-disable ()
"Disables golden-ratio's automatic window resizing"
(interactive)
(ad-deactivate 'select-window))


(provide 'golden-ratio)

;;; filename ends here

0 comments on commit 0f42738

Please sign in to comment.