Improve stability of popups
Now, popup windows are marked as dedicated to their buffer. This makes it much less likely (if not impossible) for new buffers to be loaded in that window, particularly through interactive file selecting tools, like projectile-find-file or counsel-recentf.
This commit is contained in:
parent
946e2d77dd
commit
604bcc0378
1 changed files with 25 additions and 28 deletions
|
@ -22,7 +22,25 @@
|
||||||
map)
|
map)
|
||||||
"Active keymap in popup windows.")
|
"Active keymap in popup windows.")
|
||||||
|
|
||||||
(advice-add 'doom/evil-window-move :around 'doom*popup-window-move)
|
;;;###autoload
|
||||||
|
(define-minor-mode doom-popup-mode
|
||||||
|
"Minor mode for pop-up windows. Enables local keymaps and sets state
|
||||||
|
variables."
|
||||||
|
:global nil
|
||||||
|
:init-value nil
|
||||||
|
:keymap doom-popup-mode-map
|
||||||
|
(let ((rules (--any (let ((key (car it)))
|
||||||
|
(when (cond ((symbolp key)
|
||||||
|
(or (eq major-mode key)
|
||||||
|
(derived-mode-p key)))
|
||||||
|
((stringp key)
|
||||||
|
(string-match-p key (buffer-name))))
|
||||||
|
(cdr it)))
|
||||||
|
doom-popup-rules)))
|
||||||
|
(set-window-dedicated-p nil doom-popup-mode)
|
||||||
|
(setq doom-last-popup (current-buffer))
|
||||||
|
(setq-local doom-popup-rule rules)))
|
||||||
|
(put 'doom-popup-mode 'permanent-local t)
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun doom*popup-window-move (orig-fn &rest args)
|
(defun doom*popup-window-move (orig-fn &rest args)
|
||||||
|
@ -80,12 +98,12 @@ window. Returns nil or the popup window."
|
||||||
;; If REPL...
|
;; If REPL...
|
||||||
(when (bound-and-true-p repl-toggle-mode)
|
(when (bound-and-true-p repl-toggle-mode)
|
||||||
(setq rtog/--last-buffer nil))
|
(setq rtog/--last-buffer nil))
|
||||||
(if (not (or dont-kill (memq :nokill doom-popup-rule)))
|
(doom-popup-mode -1)
|
||||||
(let ((kill-buffer-query-functions
|
(unless (or dont-kill (memq :nokill doom-popup-rule))
|
||||||
(delq 'process-kill-buffer-query-function
|
(let ((kill-buffer-query-functions
|
||||||
kill-buffer-query-functions)))
|
(delq 'process-kill-buffer-query-function
|
||||||
(kill-buffer (window-buffer window)))
|
kill-buffer-query-functions)))
|
||||||
(doom-popup-mode -1)))
|
(kill-buffer (window-buffer window)))))
|
||||||
(delete-window window)))
|
(delete-window window)))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
|
@ -136,26 +154,5 @@ window. Returns nil or the popup window."
|
||||||
"Prevents messing up a popup buffer on window changes"
|
"Prevents messing up a popup buffer on window changes"
|
||||||
(doom/popup-save (apply orig-fun args)))
|
(doom/popup-save (apply orig-fun args)))
|
||||||
|
|
||||||
(put 'doom-popup-mode 'permanent-local t)
|
|
||||||
(put 'doom-popup-rule 'permanent-local t)
|
|
||||||
|
|
||||||
;;;###autoload
|
|
||||||
(define-minor-mode doom-popup-mode
|
|
||||||
"Minor mode for pop-up windows. Enables local keymaps and sets state
|
|
||||||
variables."
|
|
||||||
:global nil
|
|
||||||
:init-value nil
|
|
||||||
:keymap doom-popup-mode-map
|
|
||||||
(let ((rules (--any (let ((key (car it)))
|
|
||||||
(when (cond ((symbolp key)
|
|
||||||
(or (eq major-mode key)
|
|
||||||
(derived-mode-p key)))
|
|
||||||
((stringp key)
|
|
||||||
(string-match-p key (buffer-name))))
|
|
||||||
(cdr it)))
|
|
||||||
doom-popup-rules)))
|
|
||||||
(setq doom-last-popup (current-buffer))
|
|
||||||
(setq-local doom-popup-rule rules)))
|
|
||||||
|
|
||||||
(provide 'defuns-popups)
|
(provide 'defuns-popups)
|
||||||
;;; defuns-popups.el ends here
|
;;; defuns-popups.el ends here
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue