diff --git a/thoom-emacs/modules/thoom-tweaks.el b/thoom-emacs/modules/thoom-tweaks.el index 10803a6..e0dfb63 100644 --- a/thoom-emacs/modules/thoom-tweaks.el +++ b/thoom-emacs/modules/thoom-tweaks.el @@ -1,10 +1,34 @@ (provide 'thoom-tweaks) +(defun consult-buffer-other-window-no-focus () + (interactive) + (with-selected-window (next-window) + (consult-buffer))) + +(defvar thoom/zoom-saved-windows nil + "Variable to store the current window configuration for thoom/zoom.") + +(defun thoom/zoom-window () + "Delete other windows, or restore the saved window configuration if available." + (interactive) + (if (and thoom/zoom-saved-windows + (not (window-configuration-p thoom/zoom-saved-windows))) + ;; Clean up if the saved config isn't valid anymore. + (setq thoom/zoom-saved-windows nil)) + + (if thoom/zoom-saved-windows + (progn + (set-window-configuration thoom/zoom-saved-windows) + (setq thoom/zoom-saved-windows nil)) + (setq thoom/zoom-saved-windows (current-window-configuration)) + (delete-other-windows))) + (use-package emacs :bind (("C-o" . nil) ("C-o C-o" . other-window) ("C-o o" . other-window) - ("C-o b" . consult-buffer-other-window) + ("C-o b" . consult-buffer-other-window-no-focus) + ("C-o B" . consult-buffer-other-window) ("C-o /" . split-window-right) ("C-o -" . split-window-below) ("C-o C-k" . delete-window) @@ -17,6 +41,7 @@ ;; TODO C-wasd for resizing ;; TODO C-/ for undo window state change ;; TODO z for zooming + ("C-o z" . thoom/zoom-window) ;; TODO other-window scrolling ("C-o n" . next-buffer) ("C-o p" . previous-buffer)