[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/goldenratio 0d7e18325d 33/95: Merge pull request #1 from
From: 
ELPA Syncer 
Subject: 
[nongnu] elpa/goldenratio 0d7e18325d 33/95: Merge pull request #1 from thierryvolpiatto/exp 
Date: 
Thu, 7 Sep 2023 22:02:11 0400 (EDT) 
branch: elpa/goldenratio
commit 0d7e18325d0f2019adb81fad9132b47ce2870a06
Merge: 2d1553431c 550fb22580
Author: Thierry Volpiatto <thierry.volpiatto@gmail.com>
Commit: Thierry Volpiatto <thierry.volpiatto@gmail.com>
Merge pull request #1 from thierryvolpiatto/exp
Fix crashes and make it working with helm

goldenratio.el  140 ++++++++++++++++++++++++++
1 file changed, 64 insertions(+), 76 deletions()
diff git a/goldenratio.el b/goldenratio.el
index 31334cd897..f75e630d51 100644
 a/goldenratio.el
+++ b/goldenratio.el
@@ 17,16 +17,16 @@
;;; Code:
(evalwhencompile (require 'cl))
(defconst goldenratiovalue 1.618
+(defconst goldenratiovalue 1.618
"The golden ratio value itself.")
;; 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,93 +34,81 @@ 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)
(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."
+ "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 'hook)
(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)))))

+(defun goldenratiodimensions ()
+ (list (floor (/ (frameheight) goldenratiovalue))
+ (floor (/ (framewidth) goldenratiovalue))))
+
+(defun goldenratioresizewindow (dimensions &optional window)
+ (withselectedwindow (or window (selectedwindow))
+ (let ((nrow (floor ( (first dimensions) (windowheightafterbalance))))
+ (ncol (floor ( (second dimensions) (windowwidthafterbalance)))))
+ (when (windowresizablep (selectedwindow) nrow)
+ (enlargewindow nrow nil))
+ (when (windowresizablep (selectedwindow) ncol t)
+ (enlargewindow ncol t)))))
+
+(defun windowwidthafterbalance ()
+ (let* ((sizels (loop for i in (windowlist)
+ unless (windowfullwidthp i)
+ collect (windowwidth i)))
+ (len (length sizels))
+ (width (and sizels (floor (/ (apply #'+ sizels) len)))))
+ (if width (min (windowwidth) width) (windowwidth))))
+
+(defun windowheightafterbalance ()
+ (let* ((sizels (loop for i in (windowlist)
+ unless (or (windowfullheightp i)
+ (not (windowfullwidthp i)))
+ collect (windowheight i)))
+ (len (length sizels))
+ (height (and sizels (floor (/ (apply #'+ sizels) len)))))
+ (if height (min (windowheight) height) (windowheight))))
;;;###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))
 (not (runhookwithargsuntilsuccess
 'goldenratioinhibitfunctions)))
 (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
+ always (funcall fun))))
+ (let ((dims (goldenratiodimensions)))
+ (goldenratioresizewindow dims)
+ (scrollleft))))
+
+;; Should return nil
(defadvice otherwindow
(after goldenratioresizewindow)
 (goldenratio))

(defadvice splitwindow
 (after goldenratioresizewindow)
 (goldenratio))

(defadvice deletewindow
 (after goldenratioresizewindow)
 (goldenratio))
+ (goldenratio) nil)
;;;###autoload
(defun goldenratioenable ()
 "Enables goldenratio's automatic window resizing"
 (interactive)
 (adactivate 'selectwindow)
 (adactivate 'otherwindow)
 (adactivate 'splitwindow)
 (adactivate 'deletewindow))


;;;###autoload
(defun goldenratiodisable ()
 "Disables goldenratio's automatic window resizing"
 (interactive)
 (addeactivate 'selectwindow)
 (addeactivate 'otherwindow)
 (addeactivate 'splitwindow)
 (addeactivate 'deletewindow))
+(defineminormode goldenratiomode
+ "Enable automatic window resizing with golden ratio."
+ :lighter " Golden"
+ (if goldenratiomode
+ (progn
+ (addhook 'windowconfigurationchangehook 'goldenratio)
+ (adactivate 'otherwindow))
+ (removehook 'windowconfigurationchangehook 'goldenratio)
+ (addeactivate 'otherwindow)))
(provide 'goldenratio)
 [nongnu] elpa/goldenratio 6af760274b 16/95: Fixing several bugs at once, (continued)
 [nongnu] elpa/goldenratio 6af760274b 16/95: Fixing several bugs at once, ELPA Syncer, 2023/09/07
 [nongnu] elpa/goldenratio ff8ade7d35 19/95: Merge branch 'release/withexemptionsupport', ELPA Syncer, 2023/09/07
 [nongnu] elpa/goldenratio 7504957a7a 23/95: Merge pull request #19 from deftsp/inhabitfunc, ELPA Syncer, 2023/09/07
 [nongnu] elpa/goldenratio 2d1553431c 25/95: Merge pull request #22 from Fuco1/master, ELPA Syncer, 2023/09/07
 [nongnu] elpa/goldenratio c028a68645 26/95: Initial cleanup., ELPA Syncer, 2023/09/07
 [nongnu] elpa/goldenratio d7c433c655 27/95: (goldenratioresizewindow): Fix, it is not a cond but when twice., ELPA Syncer, 2023/09/07
 [nongnu] elpa/goldenratio b2eb54a74c 28/95: Remove unuseful advices and create new minor mode., ELPA Syncer, 2023/09/07
 [nongnu] elpa/goldenratio 239eb4d9cb 29/95: (goldenratio): scroll left., ELPA Syncer, 2023/09/07
 [nongnu] elpa/goldenratio d877ceec2c 30/95: Remove commented line., ELPA Syncer, 2023/09/07
 [nongnu] elpa/goldenratio f547dee6ad 31/95: (goldenratiomode): fix lighter., ELPA Syncer, 2023/09/07
 [nongnu] elpa/goldenratio 0d7e18325d 33/95: Merge pull request #1 from thierryvolpiatto/exp,
ELPA Syncer <=
 [nongnu] elpa/goldenratio 7646627bbf 34/95: * goldenratio.el: Add group., ELPA Syncer, 2023/09/07
 [nongnu] elpa/goldenratio 07fc7d7f7b 35/95: Merge branch 'master' of github.com:thierryvolpiatto/goldenratio.el, ELPA Syncer, 2023/09/07
 [nongnu] elpa/goldenratio 4871294c94 36/95: * goldenratio.el (poptobuffer): Advice also poptobuffer., ELPA Syncer, 2023/09/07
 [nongnu] elpa/goldenratio 6e58cc5871 37/95: Merge branch 'originexp', ELPA Syncer, 2023/09/07
 [nongnu] elpa/goldenratio a19b9b0a3b 39/95: * goldenratio.el: Fix windowresizablep compatibility with 24.2., ELPA Syncer, 2023/09/07
 [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