@@ 1,21 @@
+Copyright (c) 2012 Roman Gonzalez
+Copyright (c) 2020 Walter Lewis
+
+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
@@ 1,21 @@
+# golden
+
+Automatic sizing of Emacs windows according to the golden ratio.
+
+This is an updated and greatly simplified derivative of [golden-ratio.el](https://github.com/roman/golden-ratio.el) for Emacs 27. Version 27 included a complete overhaul of the window change interface, obviating the need for the original code's complexity. The UX was also simplified in the process and a number of outstanding issues fixed.
+
+# Usage
+
+Toggle one of the following minor modes:
+
+- `golden-mode`: Enable or disable automatic resizing when switching to windows containing this buffer
+
+- `global-golden-mode`: Enable or disable automatic resizing for all windows
+
+The command `global-golden-resize` can also be used to manually resize the selected window.
+
+# Inhibiting resizing
+
+The `golden-ratio.el` customization options dedicated to inhibiting the resizing of particular buffers, major modes, etc. have been replaced by a single list of predicate functions:
+
+- `golden-inhibit-predicates`: List of functions to be called with no arguments the first time `global-golden-mode` might be enabled in a buffer; if any returns a non-nil value, automatic resizing is inhibited when switching to windows containing that buffer
@@ 1,75 @@
+;;; golden.el --- Automatic sizing of windows according to the golden ratio -*- lexical-binding: t -*-
+
+;; Copyright (C) 2012 Roman Gonzalez
+;; Copyright (C) 2020 Walter Lewis
+
+;; Author: Roman Gonzalez <romanandreg@gmail.com>
+;; Walter Lewis <wklew@mailbox.org>
+;; Created: 23 Dec 2020
+;; Keywords: frames
+;; URL: https://git.sr.ht/~wklew/golden
+
+;; This file is not part of GNU Emacs
+
+;; This file is free software (MIT License)
+
+;;; Code:
+
+(defgroup golden nil
+ "Automatically resize windows according to the golden ratio."
+ :group 'windows)
+
+(defcustom golden-inhibit-predicates nil
+ "Functions checking whether to inhibit resizing for a buffer.
+Each function is called with no arguments in every new buffer in
+which `global-golden-mode' might be enabled. Don't enable
+automatic resizing if any function returns nil."
+ :group 'golden
+ :type 'hook)
+
+;;;###autoload
+(define-minor-mode golden-mode
+ "Automatic window resizing according to the golden ratio."
+ :lighter " Golden"
+ (if golden-mode (golden--init) (golden--quit)))
+
+;;;###autoload
+(define-globalized-minor-mode global-golden-mode golden-mode golden--maybe-init
+ :group 'golden
+ (unless global-golden-mode
+ (golden--quit)))
+
+;;;###autoload
+(defun golden-resize (&optional window)
+ "Resizes WINDOW as long as it's the current window."
+ (interactive (list (selected-window)))
+ (when (eq window (selected-window))
+ (when (and (not (one-window-p))
+ (not (window-minibuffer-p)))
+ (balance-windows)
+ (enlarge-window (- (golden--scale (frame-height))
+ (window-height)))
+ (enlarge-window (- (golden--scale (frame-width))
+ (window-width))
+ t))))
+
+(defun golden--init ()
+ (add-hook 'window-selection-change-functions #'golden-resize nil t)
+ (golden-resize))
+
+(defun golden--quit ()
+ (remove-hook 'window-selection-change-functions #'golden-resize t))
+
+(defun golden--maybe-init ()
+ (unless (or (minibufferp)
+ (seq-reduce (lambda (p pred) (or p (funcall pred)))
+ golden-inhibit-predicates
+ nil))
+ (golden--init)))
+
+(defun golden--scale (x)
+ (floor (/ x 1.618)))
+
+(provide 'golden)
+
+;;; golden.el ends here