purpose: use use-package hook for popwin config
Also remove the check on purpose-mode. Using the purpose layer without purpose-mode does not make sense so I prefer to throw an error is such case happens.
This commit is contained in:
parent
be2061c7a0
commit
e41a17be4c
|
@ -52,7 +52,7 @@
|
||||||
(global-set-key [remap purpose-switch-buffer-with-some-purpose]
|
(global-set-key [remap purpose-switch-buffer-with-some-purpose]
|
||||||
#'ivy-purpose-switch-buffer-with-some-purpose))))
|
#'ivy-purpose-switch-buffer-with-some-purpose))))
|
||||||
|
|
||||||
(defun spacemacs-purpose/post-init-popwin ()
|
(defun spacemacs-purpose/pre-init-popwin ()
|
||||||
;; when popwin creates a popup window, it removes the `purpose-dedicated'
|
;; when popwin creates a popup window, it removes the `purpose-dedicated'
|
||||||
;; window parameter from all windows, so we must save and restore it
|
;; window parameter from all windows, so we must save and restore it
|
||||||
;; ourselves. this works well as long as no buffer is displayed in more than
|
;; ourselves. this works well as long as no buffer is displayed in more than
|
||||||
|
@ -62,22 +62,24 @@
|
||||||
;; there is no problem if the local spacemacs-purpose-popwin package is used,
|
;; there is no problem if the local spacemacs-purpose-popwin package is used,
|
||||||
;; as long as the user doesn't call `popwin:create-popup-window' directly
|
;; as long as the user doesn't call `popwin:create-popup-window' directly
|
||||||
;; (e.g. <f2> from `helm-mini')
|
;; (e.g. <f2> from `helm-mini')
|
||||||
(defvar window-purpose--dedicated-windows nil)
|
(spacemacs|use-package-add-hook popwin
|
||||||
(defadvice popwin:create-popup-window
|
:post-config
|
||||||
(before window-purpose/save-dedicated-windows)
|
(progn
|
||||||
(setq window-purpose--dedicated-windows
|
(defvar window-purpose--dedicated-windows nil)
|
||||||
(cl-loop for window in (window-list)
|
(defadvice popwin:create-popup-window
|
||||||
if (purpose-window-purpose-dedicated-p window)
|
(before window-purpose/save-dedicated-windows)
|
||||||
collect (window-buffer window))))
|
(setq window-purpose--dedicated-windows
|
||||||
(defadvice popwin:create-popup-window
|
(cl-loop for window in (window-list)
|
||||||
(after window-purpose/restore-dedicated-windows)
|
if (purpose-window-purpose-dedicated-p window)
|
||||||
(cl-loop for buffer in window-purpose--dedicated-windows
|
collect (window-buffer window))))
|
||||||
do (cl-loop for window in (get-buffer-window-list buffer)
|
(defadvice popwin:create-popup-window
|
||||||
do (purpose-set-window-purpose-dedicated-p window t))))
|
(after window-purpose/restore-dedicated-windows)
|
||||||
(add-hook 'purpose-mode-hook #'spacemacs/window-purpose-sync-popwin)
|
(cl-loop for buffer in window-purpose--dedicated-windows
|
||||||
(when (boundp 'purpose-mode)
|
do (cl-loop for window in (get-buffer-window-list buffer)
|
||||||
;; sync with popwin now if window-purpose was already loaded
|
do (purpose-set-window-purpose-dedicated-p
|
||||||
(spacemacs/window-purpose-sync-popwin)))
|
window t))))
|
||||||
|
(add-hook 'purpose-mode-hook #'spacemacs/window-purpose-sync-popwin)
|
||||||
|
(spacemacs/window-purpose-sync-popwin))))
|
||||||
|
|
||||||
(defun spacemacs-purpose/init-purpose-popwin ()
|
(defun spacemacs-purpose/init-purpose-popwin ()
|
||||||
(use-package spacemacs-purpose-popwin
|
(use-package spacemacs-purpose-popwin
|
||||||
|
|
Loading…
Reference in a new issue