Update & refactor core-popups
Updates core-popups for new doom-kill-buffer-less workflow, and gives it is last refactor. Within the next couple of days core-popups will be replaced with a new and improved feature/popup module.
This commit is contained in:
parent
ab0223144c
commit
f1268b130f
2 changed files with 49 additions and 42 deletions
|
@ -199,7 +199,7 @@ available), it will select the nearest popup window."
|
|||
property."
|
||||
(interactive)
|
||||
(when (doom-popup-p window)
|
||||
(delete-window (or window (selected-window)))))
|
||||
(delete-window window)))
|
||||
|
||||
;;;###autoload
|
||||
(defun doom/popup-close-all (&optional force-p)
|
||||
|
@ -217,19 +217,9 @@ If FORCE-P is non-nil (or this function is called interactively), ignore popups'
|
|||
(setq doom-popup-history (delq nil (mapcar #'doom--popup-data popups)))
|
||||
(dolist (window popups success)
|
||||
(when (or force-p (doom-popup-property :autoclose window))
|
||||
(delete-window window)
|
||||
(kill-buffer (window-buffer window))
|
||||
(setq success t))))))
|
||||
|
||||
;;;###autoload
|
||||
(defun doom/popup-kill-all ()
|
||||
"Like `doom/popup-close-all', but kill *all* popups, including :static ones,
|
||||
without leaving any trace behind (muahaha)."
|
||||
(interactive)
|
||||
(when-let* ((popups (doom-popup-windows)))
|
||||
(let (doom-popup-remember-history)
|
||||
(setq doom-popup-history nil)
|
||||
(mapc #'delete-window popups))))
|
||||
|
||||
;;;###autoload
|
||||
(defun doom/popup-close-maybe ()
|
||||
"Close the current popup *if* its window doesn't have a noesc parameter."
|
||||
|
@ -239,7 +229,18 @@ without leaving any trace behind (muahaha)."
|
|||
(if (featurep 'evil)
|
||||
#'evil-force-normal-state
|
||||
#'keyboard-quit))
|
||||
(quit-restore-window nil 'kill)))
|
||||
(kill-this-buffer)))
|
||||
|
||||
;;;###autoload
|
||||
(defun doom/popup-kill-all ()
|
||||
"Like `doom/popup-close-all', but kill *all* popups, including :static ones,
|
||||
without leaving any trace behind (muahaha)."
|
||||
(interactive)
|
||||
(when-let* ((popups (doom-popup-windows)))
|
||||
(let (doom-popup-remember-history)
|
||||
(setq doom-popup-history nil)
|
||||
(dolist (win popups)
|
||||
(kill-buffer (window-buffer win))))))
|
||||
|
||||
;;;###autoload
|
||||
(defun doom/popup-this-buffer ()
|
||||
|
@ -408,9 +409,9 @@ prevent the popup(s) from messing up the UI (or vice versa)."
|
|||
|
||||
;;;###autoload
|
||||
(defun doom*delete-popup-window (&optional window)
|
||||
"Ensure that popups are deleted properly, and killed if they have :autokill
|
||||
properties."
|
||||
(or window (setq window (selected-window)))
|
||||
"Do popup bookkeeping before the popup window is deleted."
|
||||
(unless window
|
||||
(setq window (selected-window)))
|
||||
(when (doom-popup-p window)
|
||||
(setq doom-popup-windows (delq window doom-popup-windows))
|
||||
(when doom-popup-remember-history
|
||||
|
|
|
@ -133,6 +133,8 @@ recognized by DOOM's popup system. They are:
|
|||
("^ ?\\*" :regexp t :size 15 :noselect t :autokill t :autoclose t)))
|
||||
|
||||
:config
|
||||
(add-hook 'doom-unreal-buffer-p #'doom-popup-p)
|
||||
|
||||
;; NOTE This is a temporary fix while I rewrite core-popups
|
||||
(defun doom-display-buffer-condition (buffer _action)
|
||||
(and (cl-loop for re in doom-popup-blacklist
|
||||
|
@ -145,42 +147,46 @@ recognized by DOOM's popup system. They are:
|
|||
(shackle-display-buffer buffer alist (shackle-match buffer)))
|
||||
|
||||
(defun doom|autokill-popups ()
|
||||
"TODO"
|
||||
(or (not (doom-popup-p))
|
||||
(prog1 (when (and (not doom-popup-inhibit-autokill)
|
||||
(if (and (not doom-popup-inhibit-autokill)
|
||||
(plist-get doom-popup-rules :autokill))
|
||||
(doom-popup-mode -1)
|
||||
(progn
|
||||
(when-let* ((process (get-buffer-process (current-buffer))))
|
||||
(set-process-query-on-exit-flag process nil))
|
||||
t))))
|
||||
t)
|
||||
(doom-popup-mode -1)
|
||||
(delete-window)
|
||||
nil)))
|
||||
|
||||
(add-hook! doom-post-init
|
||||
(defun doom|init-popups ()
|
||||
"TODO"
|
||||
(setq display-buffer-alist
|
||||
(cons '(doom-display-buffer-condition doom-display-buffer-action)
|
||||
display-buffer-alist))
|
||||
(add-hook 'kill-buffer-query-functions #'doom|autokill-popups))
|
||||
|
||||
;; no modeline in popups
|
||||
(add-hook 'doom-popup-mode-hook #'doom|hide-modeline-in-popup)
|
||||
;; ensure every rule without an :align, :same or :frame property has an
|
||||
;; implicit :align (see `shackle-default-alignment')
|
||||
(advice-add #'shackle--match :filter-return #'doom*shackle-always-align)
|
||||
|
||||
;; bootstrap popup system
|
||||
(advice-add #'shackle-display-buffer :around #'doom*popup-init)
|
||||
(advice-add #'balance-windows :around #'doom*popups-save)
|
||||
(advice-add #'delete-window :before #'doom*delete-popup-window)
|
||||
|
||||
;; ensure every rule without an :align, :same or :frame property has an
|
||||
;; implicit :align (see `shackle-default-alignment')
|
||||
(advice-add #'shackle--match :filter-return #'doom*shackle-always-align)
|
||||
;; autokill popups with a non-nil :autokill property
|
||||
(add-hook 'kill-buffer-query-functions #'doom|autokill-popups)
|
||||
;; no modeline in popups
|
||||
(add-hook 'doom-popup-mode-hook #'doom|hide-modeline-in-popup)
|
||||
;; Tell `window-state-get' and `current-window-configuration' to recognize
|
||||
;; these custom parameters. Helpful for `persp-mode' and persisting window
|
||||
;; configs that have popups in them.
|
||||
(dolist (param `(popup ,@doom-popup-window-parameters))
|
||||
(push (cons param 'writable) window-persistent-parameters))
|
||||
(push (cons param 'writable) window-persistent-parameters)))
|
||||
(add-hook 'doom-post-init-hook #'doom|init-popups)
|
||||
|
||||
(let ((map doom-popup-mode-map))
|
||||
(define-key map [escape] #'doom/popup-close-maybe)
|
||||
(define-key map (kbd "ESC") #'doom/popup-close-maybe)
|
||||
(define-key map [remap quit-window] #'doom/popup-close-maybe)
|
||||
(define-key map [remap doom/kill-this-buffer] #'doom/popup-close-maybe)
|
||||
(define-key map [remap kill-buffer] #'doom/popup-close)
|
||||
(define-key map [remap split-window-right] #'ignore)
|
||||
(define-key map [remap split-window-below] #'ignore)
|
||||
(define-key map [remap split-window-horizontally] #'ignore)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue