From 847537257e7304634cdc14a4ae9c349276d6e8d8 Mon Sep 17 00:00:00 2001 From: Riyyi Date: Mon, 22 Aug 2022 12:24:15 +0200 Subject: [PATCH] Emacs: Add window maximize toggle --- .config/emacs/config.org | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/.config/emacs/config.org b/.config/emacs/config.org index e3f1ec6..2fbec6f 100644 --- a/.config/emacs/config.org +++ b/.config/emacs/config.org @@ -553,6 +553,23 @@ Functions that only use built-in Emacs functionality. (set-fringe-mode '(nil . 0)) (set-fringe-mode 0))) +;; Reference: https://gist.github.com/mads-hartmann/3402786#gistcomment-4263171 +(defun dot/toggle-window-maximize () + "Toggle window maximize." + (interactive) + (save-excursion + (if (and (= 1 (length (cl-remove-if + (lambda (w) + (or (and (fboundp 'treemacs-is-treemacs-window?) + (treemacs-is-treemacs-window? w)) + (and (bound-and-true-p neo-global--window) + (eq neo-global--window w)))) + (window-list)))) + (assoc ?_ register-alist)) + (jump-to-register ?_) + (window-configuration-to-register ?_) + (delete-other-windows)))) + (defun dot/M-x (command) "Prompt and execute COMMAND." (interactive "CCommand: ") @@ -1064,6 +1081,7 @@ General.el ~leader key binds. "t j" '(centaur-tabs-select-end-tab :which-key "Tab select first") "t k" '(centaur-tabs-select-beg-tab :which-key "Tab select last") "t l" '(centaur-tabs-forward-group :which-key "Tab forward group") + "t m" '(dot/toggle-window-maximize :which-key "Toggle window maximize") "t n" '(neotree-toggle-in-project-root :which-key "Toggle Neotree") "t s" '(dot/flyspell-toggle :which-key "Toggle spell checker") "t w" '(visual-line-mode :which-key "Toggle line wrapping") @@ -1108,6 +1126,7 @@ General.el ~leader key binds. "w j" '(windmove-down :which-key "Focus window down") "w k" '(windmove-up :which-key "Focus window up") "w l" '(windmove-right :which-key "Focus window right") + "w m" '(dot/toggle-window-maximize :which-key "Toggle window maximize") "w o" '(delete-other-windows :which-key "Close other windows") "w s" '(split-follow-horizontally :which-key "Split horizontal") "w v" '(split-follow-vertically :which-key "Split vertical")