diff --git a/core/core-popup.el b/core/core-popup.el index 55010aa3f..93825b361 100644 --- a/core/core-popup.el +++ b/core/core-popup.el @@ -66,23 +66,9 @@ (defvar narf-popup-windows '() "A list of windows that have been opened via shackle. Do not touch this!") - ;; Popup hook - (defvar shackle-popup-hook '() "Hook run whenever a popup is opened.") - (defun narf|run-popup-hooks (&rest _) - (with-current-buffer shackle-last-buffer - (run-hooks 'shackle-popup-hook))) + ;; 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 - (defun narf|popup-init () - (add-to-list 'narf-popup-windows (get-buffer-window)) - (local-set-key [escape escape] 'narf/popup-close) - (when (or (bound-and-true-p repl-toggle-mode) - (derived-mode-p 'tabulated-list-mode) - (memq major-mode '(messages-buffer-mode flycheck-error-list-mode-hook esup-mode))) - (let ((map evil-normal-state-local-map)) - (define-key map [escape] 'narf/popup-close) - (define-key map (kbd "ESC") 'narf/popup-close)))) (add-hook! 'shackle-popup-hook '(narf|popup-init narf|hide-mode-line)) diff --git a/core/defuns/defuns-popups.el b/core/defuns/defuns-popups.el index 8cf1a9fda..366875d82 100644 --- a/core/defuns/defuns-popups.el +++ b/core/defuns/defuns-popups.el @@ -79,5 +79,22 @@ (narf|hide-mode-line) (goto-char (point-max)))) +;;;###autoload +(defun narf|popup-init () + (add-to-list 'narf-popup-windows (get-buffer-window)) + (local-set-key [escape escape] 'narf/popup-close) + (when (or (bound-and-true-p repl-toggle-mode) + (derived-mode-p 'tabulated-list-mode) + (memq major-mode '(messages-buffer-mode flycheck-error-list-mode-hook esup-mode))) + (let ((map evil-normal-state-local-map)) + (define-key map [escape] 'narf/popup-close) + (define-key map (kbd "ESC") 'narf/popup-close)))) + +(defvar shackle-popup-hook '() "Hook run whenever a popup is opened.") +;;;###autoload +(defun narf|run-popup-hooks (&rest _) + (with-current-buffer shackle-last-buffer + (run-hooks 'shackle-popup-hook))) + (provide 'defuns-popups) ;;; defuns-popups.el ends here