Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Fetching contributors…
Cannot retrieve contributors at this time
76 lines (54 sloc) 2.01 KB
;;; golden-ratio.el --- Automatic resizing of Emacs windows to the golden ratio
;; Copyright (C) 2012 Roman Gonzalez
;; Author: Roman Gonzalez <>
;; Mantainer: Roman Gonzalez <>
;; Created: 13 Oct 2012
;; Keywords: Window Resizing
;; Version: 0.0.3
;; Code inspired by ideas from Tatsuhiro Ujihisa
;; This file is not part of GNU Emacs.
;; This file is free software (MIT License)
;;; Code:
(eval-when-compile (require 'cl))
(defconst -golden-ratio-value 1.618
"The golden ratio value itself.")
(defun -golden-ratio-dimensions ()
(let* ((main-rows (floor (/ (frame-height) -golden-ratio-value)))
(main-columns (floor (/ (frame-width) -golden-ratio-value))))
(list main-rows
(defun -golden-ratio-resize-window (dimensions window)
(let* ((edges (window-pixel-edges window))
(nrow (floor
(- (first dimensions)
(window-height window))))
(ncol (floor
(- (second dimensions)
(window-width window)))))
(if (not (window-full-height-p))
(enlarge-window nrow nil))
(if (not (window-full-width-p))
(enlarge-window ncol t)))))
(defun golden-ratio ()
"Resizes current window to the golden-ratio's size specs"
(if (and (not (window-minibuffer-p))
(not (one-window-p)))
(-golden-ratio-resize-window (-golden-ratio-dimensions)
(defadvice select-window
(after golden-ratio-resize-window)
(defun golden-ratio-enable ()
"Enables golden-ratio's automatic window resizing"
(ad-activate 'select-window))
(defun golden-ratio-disable ()
"Disables golden-ratio's automatic window resizing"
(ad-deactivate 'select-window))
(provide 'golden-ratio)
;;; filename ends here
Jump to Line
Something went wrong with that request. Please try again.