emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/golden-ratio b2eb54a74c 28/95: Remove unuseful advices and


From: ELPA Syncer
Subject: [nongnu] elpa/golden-ratio b2eb54a74c 28/95: Remove unuseful advices and create new minor mode.
Date: Thu, 7 Sep 2023 22:02:11 -0400 (EDT)

branch: elpa/golden-ratio
commit b2eb54a74c1f835b808db2a78af8d41e0ff34d80
Author: Thierry Volpiatto <thierry.volpiatto@gmail.com>
Commit: Thierry Volpiatto <thierry.volpiatto@gmail.com>

    Remove unuseful advices and create new minor mode.
---
 golden-ratio.el | 43 ++++++++++---------------------------------
 1 file changed, 10 insertions(+), 33 deletions(-)

diff --git a/golden-ratio.el b/golden-ratio.el
index 0506309103..43ab2d5759 100644
--- a/golden-ratio.el
+++ b/golden-ratio.el
@@ -77,44 +77,21 @@ will not cause the window to be resized to the golden 
ratio."
       ;(balance-windows-area)
       (golden-ratio--resize-window dims))))
 
-;(add-hook 'window-configuration-change-hook 'golden-ratio)
-;; Should return window
-(defadvice select-window
-  (around golden-ratio-resize-window)
-  (prog1 ad-do-it (golden-ratio)))
-
 ;; Should return nil
 (defadvice other-window
   (after golden-ratio-resize-window)
-  (golden-ratio))
-
-;; Should return window
-(defadvice split-window
-  (around golden-ratio-resize-window)
-  (prog1 ad-do-it (golden-ratio)))
-
-;; Should return nil
-(defadvice delete-window
-  (after golden-ratio-resize-window)
-  (golden-ratio))
+  (golden-ratio) nil)
 
 ;;;###autoload
-(defun golden-ratio-enable ()
-  "Enables golden-ratio's automatic window resizing"
-  (interactive)
-  (ad-activate 'select-window)
-  (ad-activate 'other-window)
-  (ad-activate 'split-window)
-  (ad-activate 'delete-window))
-
-;;;###autoload
-(defun golden-ratio-disable ()
-  "Disables golden-ratio's automatic window resizing"
-  (interactive)
-  (ad-deactivate 'select-window)
-  (ad-deactivate 'other-window)
-  (ad-deactivate 'split-window)
-  (ad-deactivate 'delete-window))
+(define-minor-mode golden-ratio-mode
+    "Enable automatic window resizing with golden ratio."
+  :lighter "Golden"
+  (if golden-ratio-mode
+      (progn
+        (add-hook 'window-configuration-change-hook 'golden-ratio)
+        (ad-activate 'other-window))
+      (remove-hook 'window-configuration-change-hook 'golden-ratio)
+      (ad-deactivate 'other-window)))
 
 
 (provide 'golden-ratio)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]