Simplify doom/window-enlargen & doom/window-maximize-buffer

+ No longer toggle window conf on consecutive presses. It's redundant
  with winner-undo and only adds a degree of uncertainty to the command.
+ `doom/window-maximize-buffer` now works with popup windows (before
  it'd spout an unhelp error about running +popup/raise).
This commit is contained in:
Henrik Lissner 2021-01-28 18:36:15 -05:00
parent 334e054ab0
commit 56e9d273e1

View file

@ -127,48 +127,16 @@ Activate again to undo this. If prefix ARG is non-nil, don't restore the last
window configuration and re-maximize the current window. Alternatively, use window configuration and re-maximize the current window. Alternatively, use
`doom/window-enlargen'." `doom/window-enlargen'."
(interactive "P") (interactive "P")
(let ((param 'doom--maximize-last-wconf))
(cl-destructuring-bind (window . wconf)
(or (frame-parameter nil param)
(cons nil nil))
(set-frame-parameter
nil param
(if (and (equal window (selected-window))
(not arg)
(null (cdr (cl-remove-if #'window-dedicated-p (window-list))))
wconf)
(ignore
(let ((source-window (selected-window)))
(set-window-configuration wconf)
(when (window-live-p source-window)
(select-window source-window))))
(when (and (bound-and-true-p +popup-mode) (when (and (bound-and-true-p +popup-mode)
(+popup-window-p)) (+popup-window-p))
(user-error "Cannot maximize a popup, use `+popup/raise' first or use `doom/window-enlargen' instead")) (+popup/raise (selected-window)))
(prog1 (cons (selected-window) (or wconf (current-window-configuration))) (delete-other-windows))
(delete-other-windows)
(add-hook 'doom-switch-window-hook #'doom--enlargened-forget-last-wconf-h)))))))
;;;###autoload ;;;###autoload
(defun doom/window-enlargen (&optional arg) (defun doom/window-enlargen (&optional arg)
"Enlargen the current window to focus on this one. Does not close other "Enlargen the current window to focus on this one. Does not close other
windows (unlike `doom/window-maximize-buffer'). Activate again to undo." windows (unlike `doom/window-maximize-buffer'). Activate again to undo."
(interactive "P") (interactive "P")
(let ((param 'doom--enlargen-last-wconf))
(cl-destructuring-bind (window . wconf)
(or (frame-parameter nil param)
(cons nil nil))
(set-frame-parameter
nil param
(if (and (equal window (selected-window))
(not arg)
wconf)
(ignore
(let ((source-window (selected-window)))
(set-window-configuration wconf)
(when (window-live-p source-window)
(select-window source-window))))
(prog1 (cons (selected-window) (or wconf (current-window-configuration)))
(let* ((window (selected-window)) (let* ((window (selected-window))
(dedicated-p (window-dedicated-p window)) (dedicated-p (window-dedicated-p window))
(preserved-p (window-parameter window 'window-preserved-size)) (preserved-p (window-parameter window 'window-preserved-size))
@ -184,8 +152,7 @@ windows (unlike `doom/window-maximize-buffer'). Activate again to undo."
(maximize-window window)) (maximize-window window))
(set-window-dedicated-p window dedicated-p) (set-window-dedicated-p window dedicated-p)
(when preserved-p (when preserved-p
(set-window-parameter window 'window-preserved-size preserved-p)) (set-window-parameter window 'window-preserved-size preserved-p)))))
(add-hook 'doom-switch-window-hook #'doom--enlargened-forget-last-wconf-h)))))))))
;;;###autoload ;;;###autoload
(defun doom/window-maximize-horizontally () (defun doom/window-maximize-horizontally ()