Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

layers/+spacemacs/spacemacs-purpose: move to define-advice #16360

Merged
merged 1 commit into from
May 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 8 additions & 11 deletions layers/+spacemacs/spacemacs-purpose/funcs.el
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,11 @@ Enable or disable advices to popwin, according to the state of `purpose-mode'."
(require 'window-purpose)
(if purpose-mode
(progn
(ad-enable-advice 'popwin:create-popup-window
'before 'window-purpose/save-dedicated-windows)
(ad-enable-advice 'popwin:create-popup-window
'after 'window-purpose/restore-dedicated-windows)
(ad-update 'popwin:create-popup-window)
(ad-activate 'popwin:create-popup-window))
(ad-disable-advice 'popwin:create-popup-window
'before 'window-purpose/save-dedicated-windows)
(ad-disable-advice 'popwin:create-popup-window
'after 'window-purpose/restore-dedicated-windows)
(ad-update 'popwin:create-popup-window)))
(advice-add #'popwin:create-popup-window
:before #'window-purpose/save-dedicated-windows)
(advice-add #'popwin:create-popup-window
:after #'window-purpose/restore-dedicated-windows))
(advice-remove #'popwin:create-popup-window
#'window-purpose/save-dedicated-windows)
(advice-remove #'popwin:create-popup-window
#'window-purpose/restore-dedicated-windows)))
Original file line number Diff line number Diff line change
Expand Up @@ -211,15 +211,15 @@ Popwin's settings are taken from `popwin:special-display-config'."
(remove-hook 'purpose-display-buffer-functions #'pupo/after-display)
(remove-hook 'purpose-display-buffer-functions #'pupo/auto-delete-windows)))

(defadvice popwin:create-popup-window (before pupo/before-popwin-create)
(define-advice popwin:create-popup-window (:before pupo/before-popwin-create)
"Save current popup windows for later restoration.
The windows are restored in `pupo/after-popwin-create'.
Note that the windows themselves aren't saved, but some internal
variables are updated instead."
(setq pupo--saved-buffers (mapcar #'window-buffer pupo--windows))
(setq pupo--saved-auto-buffers (mapcar #'window-buffer pupo--auto-windows)))

(defadvice popwin:create-popup-window (after pupo/after-popwin-create)
(define-advice popwin:create-popup-window (:after pupo/after-popwin-create)
"Restore popup windows.
The windows were saved in `pupo/before-popwin-create'.
Note that the windows themselves aren't restored, but some internal
Expand All @@ -238,13 +238,10 @@ variables are updated instead."
(defun pupo/sync-advices ()
(if pupo-mode
(progn
(ad-enable-advice 'popwin:create-popup-window 'before 'pupo/before-popwin-create)
(ad-enable-advice 'popwin:create-popup-window 'after 'pupo/after-popwin-create)
(ad-update 'popwin:create-popup-window)
(ad-activate 'popwin:create-popup-window))
(ad-disable-advice 'popwin:create-popup-window 'before 'pupo/before-popwin-create)
(ad-disable-advice 'popwin:create-popup-window 'after 'pupo/after-popwin-create)
(ad-update 'popwin:create-popup-window)))
(advice-add #'popwin:create-popup-window :before #'pupo/before-popwin-create)
(advice-add #'popwin:create-popup-window :after #'pupo/after-popwin-create))
(advice-remove #'popwin:create-popup-window #'pupo/before-popwin-create)
(advice-remove #'popwin:create-popup-window #'pupo/after-popwin-create)))
(add-hook 'pupo-mode-hook #'pupo/sync-advices)

(provide 'spacemacs-purpose-popwin)
Expand Down
8 changes: 4 additions & 4 deletions layers/+spacemacs/spacemacs-purpose/packages.el
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,14 @@
:post-config
(progn
(defvar window-purpose--dedicated-windows nil)
(defadvice popwin:create-popup-window
(before window-purpose/save-dedicated-windows)
(define-advice popwin:create-popup-window
(:before window-purpose/save-dedicated-windows)
(setq window-purpose--dedicated-windows
(cl-loop for window in (window-list)
if (purpose-window-purpose-dedicated-p window)
collect (window-buffer window))))
(defadvice popwin:create-popup-window
(after window-purpose/restore-dedicated-windows)
(define-advice popwin:create-popup-window
(:after window-purpose/restore-dedicated-windows)
(cl-loop for buffer in window-purpose--dedicated-windows
do (cl-loop for window in (get-buffer-window-list buffer)
do (purpose-set-window-purpose-dedicated-p
Expand Down