diff --git a/core/core-popup.el b/core/core-popup.el index 93825b361..6cf36af18 100644 --- a/core/core-popup.el +++ b/core/core-popup.el @@ -68,9 +68,16 @@ ;; There is no shackle-popup hook, so I hacked one in (advice-add 'shackle-display-buffer :after 'narf|run-popup-hooks) - ;; Keep track of popups - (add-hook! 'shackle-popup-hook '(narf|popup-init narf|hide-mode-line)) + (add-hook 'shackle-popup-hook 'narf|popup-init) ; Keep track of popups + (add-hook 'shackle-popup-hook 'narf|hide-mode-line) ; No mode line in popups + + ;; Prevents popups from messaging with windows-moving functions + (after! defuns-popup + (defun narf*save-popups (orig-fun &rest args) + (narf/popup-save (apply orig-fun args))) + (advice-add 'narf--evil-window-move :around 'narf*save-popups) + (advice-add 'narf--evil-swap-windows :around 'narf*save-popups)) ;; ;; Hacks diff --git a/core/core-project.el b/core/core-project.el index 6d17fa692..9cd4d1cfe 100644 --- a/core/core-project.el +++ b/core/core-project.el @@ -124,9 +124,11 @@ (apply orig-fun args))) (advice-add 'neotree-create-node :around 'narf*neotree-create-node) + (defun narf*save-neotree (orig-fun &rest args) + (narf/neotree-save (apply orig-fun args))) ;; Prevents messing up the neotree buffer on window changes - (advice-add 'narf--evil-window-move :before 'narf|neotree-close-on-window-change) - (advice-add 'narf--evil-swap-windows :before 'narf|neotree-close-on-window-change) + (advice-add 'narf--evil-window-move :around 'narf*save-neotree) + (advice-add 'narf--evil-swap-windows :around 'narf*save-neotree) ;; A custom and simple theme for neotree (advice-add 'neo-buffer--insert-fold-symbol :override 'narf*neo-buffer-fold-symbol)) diff --git a/core/defuns/defuns-neotree.el b/core/defuns/defuns-neotree.el index 32e0915f8..060996850 100644 --- a/core/defuns/defuns-neotree.el +++ b/core/defuns/defuns-neotree.el @@ -17,6 +17,15 @@ (neotree-dir project-root)) (neotree-find path project-root))))) +;;;###autoload +(defmacro narf/neotree-save (&rest body) + `(let ((neo-p (neo-global--window-exists-p))) + (when neo-p (neotree-hide)) + ,@body + (when neo-p + (save-selected-window + (neotree-show))))) + ;;;###autoload (defun narf|neotree-close-on-window-change (&rest _) "Close neotree to prevent ensuing mindow buggery." diff --git a/core/defuns/defuns-popups.el b/core/defuns/defuns-popups.el index 366875d82..4d572a284 100644 --- a/core/defuns/defuns-popups.el +++ b/core/defuns/defuns-popups.el @@ -15,6 +15,15 @@ (-any? (lambda (w) (eq window w)) narf-popup-windows) t))) +;;;###autoload +(defmacro narf/popup-save (&rest body) + `(let ((popup-p (narf/popup-p))) + (when popup-p (narf/popup-close-all t)) + ,@body + (when popup-p + (save-selected-window + (narf/popup-last-buffer))))) + ;;;###autoload (defun narf/popup-buffer (buffer &optional plist) "Display BUFFER in a shackle popup."