[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/goldenratio 73e9bd7f94 57/95: Merge remotetracking branc
From: 
ELPA Syncer 
Subject: 
[nongnu] elpa/goldenratio 73e9bd7f94 57/95: Merge remotetracking branch 'upstream/master' 
Date: 
Thu, 7 Sep 2023 22:02:13 0400 (EDT) 
branch: elpa/goldenratio
commit 73e9bd7f944aec4dcdcc20d5ec6c08a7cb392beb
Merge: feddcbe68b 33aa083b66
Author: Stuart Hickinbottom <stuart@hickinbottom.com>
Commit: Stuart Hickinbottom <stuart@hickinbottom.com>
Merge remotetracking branch 'upstream/master'

README.md  4 +
goldenratio.el  157 ++++++++++++++++++++++++++++++++
2 files changed, 92 insertions(+), 69 deletions()
diff git a/README.md b/README.md
index 30f47b6db2..65eb80020f 100644
 a/README.md
+++ b/README.md
@@ 26,13 +26,13 @@ To enable automatic resizing, put on your .emacs.d/init.el
```elisp
(require 'goldenratio)
(goldenratioenable)
+(goldenratiomode 1)
```
***
If you want to disable automatic resizing done by goldenratio, just invoke
`(goldenratiodisable)`
+`Mx goldenratiomode`
To call golden ratio manually just `Mx goldenratio`
diff git a/goldenratio.el b/goldenratio.el
index afcffaab8d..c28b3d4f28 100644
 a/goldenratio.el
+++ b/goldenratio.el
@@ 17,16 +17,20 @@
;;; Code:
(evalwhencompile (require 'cl))
(defconst goldenratiovalue 1.618
+(defconst goldenratiovalue 1.618
"The golden ratio value itself.")
+(defgroup goldenratio nil
+ "Resize windows to golden ratio."
+ :group 'windows)
+
;; Major modes that are exempt from being resized. An example of this
;; for users of Orgmode might be:
;; ("calendarmode")
(defcustom goldenratioexcludemodes nil
 "An array of strings naming major modes. Switching to a buffer
whose major mode is a member of this list will not cause the
window to be resized to the golden ratio."
+ "An array of strings naming major modes.
+Switching to a buffer whose major mode is a member of this list
+will not cause the window to be resized to the golden ratio."
:type '(repeat string)
:group 'goldenratio)
@@ 34,79 +38,98 @@ window to be resized to the golden ratio."
;; for users of Orgmode might be (note the leading spaces):
;; (" *Org tags*" " *Org todo*")
(defcustom goldenratioexcludebuffernames nil
 "An array of strings containing buffer names. Switching to a
buffer whose name is a member of this list will not cause the
window to be resized to the golden ratio."
+ "An array of strings containing buffer names.
+Switching to a buffer whose name is a member of this list
+will not cause the window to be resized to the golden ratio."
:type '(repeat string)
:group 'goldenratio)
(defun goldenratiodimensions ()
 (let* ((mainrows (floor (/ (frameheight) goldenratiovalue)))
 (maincolumns (floor (/ (framewidth) goldenratiovalue))))
 (list mainrows
 maincolumns)))


(defun goldenratioresizewindow (dimensions window)
 (let* ((edges (windowpixeledges window))
 (nrow (floor
 ( (first dimensions)
 (windowheight window))))
 (ncol (floor
 ( (second dimensions)
 (windowwidth window)))))
 (progn
 (if (not (windowfullheightp))
 (enlargewindow nrow nil))
 (if (not (windowfullwidthp))
 (enlargewindow ncol t)))))

+(defcustom goldenratioinhibitfunctions nil
+ "List of functions to call with no arguments.
+Switching to a buffer, if any of these functions returns nonnil
+will not cause the window to be resized to the golden ratio."
+ :group 'goldenratio
+ :type '(repeat symbol))
+
+(defcustom goldenratioextracommands
+ '(windmoveleft windmoveright windmovedown windmoveup)
+ "List of extra commands used to jump to other window."
+ :group 'goldenratio
+ :type '(repeat symbol))
+
+;;; Compatibility
+;;
+(unless (fboundp 'windowresizablep)
+ (defalias 'windowresizablep 'windowresizablep))
+
+(defun goldenratiodimensions ()
+ (list (floor (/ (frameheight) goldenratiovalue))
+ (floor (/ (framewidth) goldenratiovalue))))
+
+(defun goldenratioresizewindow (dimensions &optional window)
+ (withselectedwindow (or window (selectedwindow))
+ (let ((nrow (floor ( (first dimensions) (windowheight))))
+ (ncol (floor ( (second dimensions) (windowwidth)))))
+ (when (windowresizablep (selectedwindow) nrow)
+ (enlargewindow nrow))
+ (when (windowresizablep (selectedwindow) ncol t)
+ (enlargewindow ncol t)))))
;;;###autoload
(defun goldenratio ()
 "Resizes current window to the goldenratio's size specs"
+ "Resizes current window to the goldenratio's size specs."
(interactive)
 (if (and (not (windowminibufferp))
 (not (onewindowp))
 (not (member (symbolname majormode)
 goldenratioexcludemodes))
 (not (member (buffername)
 goldenratioexcludebuffernames)))
 (progn
 (balancewindows)
 (goldenratioresizewindow (goldenratiodimensions)
 (selectedwindow)))))


(defadvice selectwindow
 (after goldenratioresizewindow)
 (goldenratio))

+ (unless (or (windowminibufferp)
+ (onewindowp)
+ (member (symbolname majormode)
+ goldenratioexcludemodes)
+ (member (buffername)
+ goldenratioexcludebuffernames)
+ (and goldenratioinhibitfunctions
+ (loop for fun in goldenratioinhibitfunctions
+ thereis (funcall fun))))
+ (let ((dims (goldenratiodimensions))
+ (goldenp (if goldenratiomode 1 1)))
+ ;; Always disable `goldenratiomode' to avoid
+ ;; infinite loop in `balancewindows'.
+ (goldenratiomode 1)
+ (balancewindows)
+ (goldenratioresizewindow dims)
+ (goldenratiomode goldenp))))
+
+;; Should return nil
(defadvice otherwindow
 (after goldenratioresizewindow)
 (goldenratio))

(defadvice splitwindow
 (after goldenratioresizewindow)
 (goldenratio))


;;;###autoload
(defun goldenratioenable ()
 "Enables goldenratio's automatic window resizing"
 (interactive)
 (adactivate 'selectwindow)
 (adactivate 'otherwindow)
 (adactivate 'splitwindow))

+ (after goldenratioresizewindow)
+ (goldenratio) nil)
+
+;; Should return the buffer
+(defadvice poptobuffer
+ (around goldenratioresizewindow)
+ (prog1 addoit (goldenratio)))
+
+(defun goldenratiopostcommandhook ()
+ (when (or (memq thiscommand goldenratioextracommands)
+ (and (consp thiscommand) ; A lambda form.
+ (loop for com in goldenratioextracommands
+ thereis (or (memq com thiscommand)
+ (memq (carsafe com) thiscommand)))))
+ (goldenratio)))
;;;###autoload
(defun goldenratiodisable ()
 "Disables goldenratio's automatic window resizing"
 (interactive)
 (addeactivate 'selectwindow)
 (addeactivate 'otherwindow)
 (addeactivate 'splitwindow))
+(defineminormode goldenratiomode
+ "Enable automatic window resizing with golden ratio."
+ :lighter " Golden"
+ :global t
+ (if goldenratiomode
+ (progn
+ (addhook 'windowconfigurationchangehook 'goldenratio)
+ (addhook 'postcommandhook 'goldenratiopostcommandhook)
+ (adactivate 'otherwindow)
+ (adactivate 'poptobuffer))
+ (removehook 'windowconfigurationchangehook 'goldenratio)
+ (removehook 'postcommandhook 'goldenratiopostcommandhook)
+ (addeactivate 'otherwindow)
+ (addeactivate 'poptobuffer)))
(provide 'goldenratio)
 [nongnu] elpa/goldenratio 19bacbeaee 40/95: * goldenratio.el (goldenratioresizewindow): Remove unuseful nil arg., (continued)
 [nongnu] elpa/goldenratio 19bacbeaee 40/95: * goldenratio.el (goldenratioresizewindow): Remove unuseful nil arg., ELPA Syncer, 2023/09/07
 [nongnu] elpa/goldenratio e66acd10ae 41/95: * goldenratio.el (windowheightafterbalance, windowwidthafterbalance): Prefix with goldenratio., ELPA Syncer, 2023/09/07
 [nongnu] elpa/goldenratio 134156bbff 42/95: * goldenratio.el: Allow running goldenratio when switching with other commands than otherwindow., ELPA Syncer, 2023/09/07
 [nongnu] elpa/goldenratio 5411fb2798 45/95: Merge pull request #23 from thierryvolpiatto/master, ELPA Syncer, 2023/09/07
 [nongnu] elpa/goldenratio 38948457fd 48/95: Merge remotetracking branch 'refs/remotes/upstream/master', ELPA Syncer, 2023/09/07
 [nongnu] elpa/goldenratio 25e95f7833 49/95: Merge pull request #27 from thierryvolpiatto/master, ELPA Syncer, 2023/09/07
 [nongnu] elpa/goldenratio 1df894012e 51/95: Merge pull request #28 from thierryvolpiatto/master, ELPA Syncer, 2023/09/07
 [nongnu] elpa/goldenratio 12b57a3904 53/95: * goldenratio.el: Fix Issue #29, a typo., ELPA Syncer, 2023/09/07
 [nongnu] elpa/goldenratio 86ffa26952 54/95: Merge pull request #31 from thierryvolpiatto/master, ELPA Syncer, 2023/09/07
 [nongnu] elpa/goldenratio 0b90ffbf02 59/95: Delay window reconfig to fix autofollow, ELPA Syncer, 2023/09/07
 [nongnu] elpa/goldenratio 73e9bd7f94 57/95: Merge remotetracking branch 'upstream/master',
ELPA Syncer <=
 [nongnu] elpa/goldenratio 7da7dd7d53 60/95: * goldenratio.el (goldenratiorecenter): New user var, allow recentering, ELPA Syncer, 2023/09/07
 [nongnu] elpa/goldenratio 892e668685 55/95: * goldenratio.el (goldenratio): Fix Issue #32 don't recenter and scrollright., ELPA Syncer, 2023/09/07
 [nongnu] elpa/goldenratio cb9ccd04bb 58/95: Also resize windows when using mouse, ELPA Syncer, 2023/09/07
 [nongnu] elpa/goldenratio 79ead1cba6 61/95: Merge pull request #35 from thierryvolpiatto/master, ELPA Syncer, 2023/09/07
 [nongnu] elpa/goldenratio d4a2dd0aeb 63/95: * goldenratio.el (goldenratiomode): Issue #34 remove mouseleavebufferhook when mode is off., ELPA Syncer, 2023/09/07
 [nongnu] elpa/goldenratio 6851a5f720 67/95: Added goldenratiotogglewidescreen function, ELPA Syncer, 2023/09/07
 [nongnu] elpa/goldenratio 26f616f658 70/95: set autoscale to nil by default., ELPA Syncer, 2023/09/07
 [nongnu] elpa/goldenratio e2cbe68277 71/95: Use a common way to avoid recursion, ELPA Syncer, 2023/09/07
 [nongnu] elpa/goldenratio 79b1743fc1 73/95: Merge pull request #45 from vkazanov/master, ELPA Syncer, 2023/09/07
 [nongnu] elpa/goldenratio b78f921f56 74/95: Allow using symbols in goldenratioexcludemodes., ELPA Syncer, 2023/09/07