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