Created
August 20, 2012 10:05
-
-
Save mads-hartmann/3402786 to your computer and use it in GitHub Desktop.
An Emacs function to temporarily make one buffer fullscreen. You can quickly restore the old window setup.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun toggle-maximize-buffer () "Maximize buffer" | |
(interactive) | |
(if (= 1 (length (window-list))) | |
(jump-to-register '_) | |
(progn | |
(set-register '_ (list (current-window-configuration))) | |
(delete-other-windows)))) | |
;; Bind it to a key. | |
;; (global-set-key [(super shift return)] 'toggle-maximize-buffer) |
Amazing! thanks ;)
Using this in my "make your own spacemacs" config. Thanks
Thank you for sharing :)
For those who want to integrate treemacs window, I left little bit modified code.
(defun toggle-maximize-buffer () "Maximize buffer"
(interactive)
(if (= 1 (length (remove-if #'treemacs-is-treemacs-window? (window-list))))
(jump-to-register '_)
(progn
(window-configuration-to-register '_)
(delete-other-windows))))
Thanks to all who wrote variations of this function. It's quite useful.
Based on previous comments:
here's a version that works with both neotree and treemacs
(defun toggle-maximize-buffer ()
"Maximize buffer."
(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))))
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Works like a charm! Thank you!