feature/popup: general refactor
Adds +popup-origin-window, which contains the last non-popup you were in before a popup was opened.
This commit is contained in:
parent
bff48e5ed7
commit
ad06eacdac
2 changed files with 13 additions and 13 deletions
|
@ -15,7 +15,9 @@
|
||||||
;; `save-popups!' macro).
|
;; `save-popups!' macro).
|
||||||
;;
|
;;
|
||||||
;; Keep in mind, all this black magic may break in future updates, and will need
|
;; Keep in mind, all this black magic may break in future updates, and will need
|
||||||
;; to be watched carefully for corner cases.
|
;; to be watched carefully for corner cases. Also, once this file is loaded, its
|
||||||
|
;; changes are irreversible without restarting Emacs! I don't like it either,
|
||||||
|
;; but I will address this over time.
|
||||||
;;
|
;;
|
||||||
;; Hacks should be kept in alphabetical order, named after the feature they
|
;; Hacks should be kept in alphabetical order, named after the feature they
|
||||||
;; modify, and should follow a ;; `package-name' header line.
|
;; modify, and should follow a ;; `package-name' header line.
|
||||||
|
|
|
@ -27,7 +27,7 @@ the buffer is visible, then set another timer and try again later."
|
||||||
(kill-process process))
|
(kill-process process))
|
||||||
(kill-buffer buffer)))))))
|
(kill-buffer buffer)))))))
|
||||||
|
|
||||||
(defun +popup--init (window alist)
|
(defun +popup--init (window &optional alist)
|
||||||
"Initializes a popup window. Run any time a popup is opened. It sets the
|
"Initializes a popup window. Run any time a popup is opened. It sets the
|
||||||
default window parameters for popup windows, clears leftover transient timers
|
default window parameters for popup windows, clears leftover transient timers
|
||||||
and enables `+popup-buffer-mode'."
|
and enables `+popup-buffer-mode'."
|
||||||
|
@ -35,19 +35,20 @@ and enables `+popup-buffer-mode'."
|
||||||
(window-preserve-size
|
(window-preserve-size
|
||||||
window (memq (window-parameter window 'window-side)
|
window (memq (window-parameter window 'window-side)
|
||||||
'(left right)) t)
|
'(left right)) t)
|
||||||
(when +popup--populate-wparams
|
(when (and alist +popup--populate-wparams)
|
||||||
;; Emacs 26+ will automatically map the window-parameters alist entry to
|
;; Emacs 26+ will automatically map the window-parameters alist entry to
|
||||||
;; the popup window, so we need this for Emacs 25.x users
|
;; the popup window, so we need this for Emacs 25.x users
|
||||||
(dolist (param (cdr (assq 'window-parameters alist)))
|
(dolist (param (cdr (assq 'window-parameters alist)))
|
||||||
(set-window-parameter window (car param) (cdr param))))
|
(set-window-parameter window (car param) (cdr param))))
|
||||||
(set-window-parameter window 'popup t)
|
(set-window-parameter window 'popup t)
|
||||||
(set-window-parameter window 'no-other-window t)
|
(set-window-parameter window 'no-other-window t)
|
||||||
(set-window-parameter window 'delete-window #'+popup--destroy)
|
(set-window-parameter window 'delete-window #'+popup--delete-window)
|
||||||
|
(set-window-parameter window 'delete-other-windows #'+popup/close-all)
|
||||||
(set-window-dedicated-p window 'popup)
|
(set-window-dedicated-p window 'popup)
|
||||||
(+popup-buffer-mode +1)
|
(+popup-buffer-mode +1)
|
||||||
(run-hooks '+popup-create-window-hook)))
|
(run-hooks '+popup-create-window-hook)))
|
||||||
|
|
||||||
(defun +popup--destroy (window)
|
(defun +popup--delete-window (window)
|
||||||
"Do housekeeping before destroying a popup window.
|
"Do housekeeping before destroying a popup window.
|
||||||
|
|
||||||
+ Disables `+popup-buffer-mode' so that any hooks attached to it get a chance to
|
+ Disables `+popup-buffer-mode' so that any hooks attached to it get a chance to
|
||||||
|
@ -262,12 +263,10 @@ disabled."
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun +popup|kill-buffer-hook ()
|
(defun +popup|kill-buffer-hook ()
|
||||||
"TODO"
|
"TODO"
|
||||||
(let ((buf (current-buffer))
|
(when-let* ((window (get-buffer-window)))
|
||||||
(+popup--inhibit-transient t))
|
|
||||||
(when (+popup-buffer-p buf)
|
|
||||||
(when-let* ((window (get-buffer-window buf)))
|
|
||||||
(when (+popup-window-p window)
|
(when (+popup-window-p window)
|
||||||
(+popup--destroy window))))))
|
(let ((+popup--inhibit-transient t))
|
||||||
|
(+popup--delete-window window)))))
|
||||||
|
|
||||||
|
|
||||||
;;
|
;;
|
||||||
|
@ -335,8 +334,7 @@ This window parameter is ignored if FORCE-P is non-nil."
|
||||||
the message buffer in a popup window."
|
the message buffer in a popup window."
|
||||||
(interactive)
|
(interactive)
|
||||||
(let ((+popup--inhibit-transient t))
|
(let ((+popup--inhibit-transient t))
|
||||||
(cond ((+popup-windows)
|
(cond ((+popup-windows) (+popup/close-all t))
|
||||||
(+popup/close-all t))
|
|
||||||
((ignore-errors (+popup/restore)))
|
((ignore-errors (+popup/restore)))
|
||||||
((display-buffer (get-buffer "*Messages*"))))))
|
((display-buffer (get-buffer "*Messages*"))))))
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue