Refactor popup implementation
This commit is contained in:
parent
008cee1afc
commit
e2a60e8a9d
5 changed files with 39 additions and 22 deletions
|
@ -25,7 +25,6 @@
|
|||
|
||||
(add-hook! repl-toggle-mode
|
||||
(evil-initialize-state 'emacs)
|
||||
(narf|hide-mode-line)
|
||||
(setq repl-p t))
|
||||
|
||||
:config
|
||||
|
|
|
@ -97,13 +97,14 @@
|
|||
(ignore-errors
|
||||
(evil-ex-nohighlight))
|
||||
;; Close non-repl popups and clean up `narf-popup-windows'
|
||||
(unless (memq (get-buffer-window) narf-popup-windows)
|
||||
(mapc (lambda (w)
|
||||
(if (window-live-p w)
|
||||
(with-selected-window w
|
||||
(unless (derived-mode-p 'comint-mode)
|
||||
(narf/popup-close w)))
|
||||
(setq narf-popup-windows (delq w narf-popup-windows))))
|
||||
narf-popup-windows))
|
||||
(narf--popup-remove w)))
|
||||
narf-popup-windows)))
|
||||
|
||||
;; Fix disruptive errors w/ hidden buffers caused by workgroups killing windows
|
||||
;; TODO Delete timer on dead windows
|
||||
|
|
|
@ -19,8 +19,6 @@
|
|||
|
||||
(evil-initial-state 'flycheck-error-list-mode 'emacs)
|
||||
(map! :map flycheck-error-list-mode-map
|
||||
:n [escape] 'kill-this-buffer
|
||||
:n "q" 'kill-this-buffer
|
||||
:n "C-n" 'flycheck-error-list-next-error
|
||||
:n "C-p" 'flycheck-error-list-previous-error
|
||||
:n "j" 'flycheck-error-list-next-error
|
||||
|
|
|
@ -66,11 +66,34 @@
|
|||
(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)))
|
||||
(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)))
|
||||
(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))
|
||||
|
||||
|
||||
;;
|
||||
;; Hacks
|
||||
;;
|
||||
|
||||
(after! ert
|
||||
(add-hook! 'ert-results-mode-hook 'narf|hide-mode-line)
|
||||
(map! (:map ert-results-mode-map
|
||||
(map! :map ert-results-mode-map
|
||||
[escape] 'quit-window
|
||||
"<escape>" 'quit-window)))
|
||||
"<escape>" 'quit-window))
|
||||
|
||||
(after! help-mode
|
||||
;; So that help buffer links do not open in the help popup, we need to redefine these
|
||||
|
@ -164,8 +187,6 @@
|
|||
(let ((window (get-buffer-window quickrun/buffer-name)))
|
||||
(with-selected-window window
|
||||
(goto-char (point-min)))))
|
||||
(defun narf|quickrun-hook ()
|
||||
(narf|hide-mode-line))
|
||||
(add-hook 'quickrun-after-run-hook 'narf|quickrun-after-run)
|
||||
(add-hook 'quickrun/mode-hook 'narf|hide-mode-line))
|
||||
|
||||
|
@ -235,12 +256,7 @@
|
|||
(progn
|
||||
(if cmd-buf (switch-to-buffer cmd-buf))
|
||||
(message "Error running command: %s" (mapconcat 'identity cmd-args " ")))))
|
||||
cmd-buf)))
|
||||
|
||||
(after! flycheck
|
||||
(map! :map flycheck-error-list-mode-map
|
||||
:n "q" 'narf/popup-close
|
||||
:n [escape] 'narf/popup-close)))
|
||||
cmd-buf))))
|
||||
|
||||
(provide 'core-popup)
|
||||
;;; core-popup.el ends here
|
||||
|
|
|
@ -138,6 +138,9 @@
|
|||
(add-hook! focus-in (set-frame-parameter nil 'alpha 100))
|
||||
(add-hook! focus-out (set-frame-parameter nil 'alpha 85))
|
||||
|
||||
;; Hide mode-line in compile window
|
||||
(add-hook 'compilation-mode-hook 'narf|hide-mode-line)
|
||||
|
||||
|
||||
;;
|
||||
;; Plugins
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue