EXWM: Move switch-to-last-buffer and toggle-single-window to functions.el
parent
57997da0b2
commit
7ba8097619
|
@ -339,6 +339,11 @@ The shell can use it to automatically change directory to it."
|
|||
(other-window 1))
|
||||
(global-set-key (kbd "C-x \\") 'swap-windows)
|
||||
|
||||
(defun switch-to-last-buffer ()
|
||||
"Switch to last open buffer in current window."
|
||||
(interactive)
|
||||
(switch-to-buffer (other-buffer (current-buffer) 1)))
|
||||
|
||||
(defun tabify-leading ()
|
||||
"Call `tabify' on leading spaces only.
|
||||
Works on whole buffer if region is unactive."
|
||||
|
@ -354,6 +359,21 @@ Works on whole buffer if region is unactive."
|
|||
(tabify start end))
|
||||
(setq tabify-regexp tabify-regexp-old))))
|
||||
|
||||
;; TODO: Store window configurations in a buffer-name-indexed alist? Not
|
||||
;; sure that would ever be useful.
|
||||
(defvar single-window--last-configuration nil "Last window configuration before calling `delete-other-windows'.")
|
||||
(defun toggle-single-window ()
|
||||
"Un-maximize current window.
|
||||
If multiple windows are active, save window configuration and
|
||||
delete other windows. If only one window is active and a window
|
||||
configuration was previously save, restore that configuration."
|
||||
(interactive)
|
||||
(if (= (count-windows) 1)
|
||||
(when single-window--last-configuration
|
||||
(set-window-configuration single-window--last-configuration))
|
||||
(setq single-window--last-configuration (current-window-configuration))
|
||||
(delete-other-windows)))
|
||||
|
||||
(defun toggle-window-dedicated ()
|
||||
"Toggle whether the current active window is dedicated or not.
|
||||
Run it in each window you want to 'freeze', i.e. prevent Emacs
|
||||
|
|
|
@ -36,22 +36,14 @@
|
|||
(exwm-input-set-key (kbd "s-f") #'find-file)
|
||||
(exwm-input-set-key (kbd "s-SPC") #'exwm-floating-toggle-floating)
|
||||
|
||||
(defvar exwm--last-window-configuration nil "Last window configuration before calling `delete-other-windows'.")
|
||||
(defun exwm-layout-toggle-fullscreen-or-single-window ()
|
||||
(interactive)
|
||||
(if (eq major-mode 'exwm-mode)
|
||||
;; REVIEW:`exwm-layout-toggle-fullscreen' needs to be called interactively.
|
||||
;; See https://github.com/ch11ng/exwm/issues/282.
|
||||
(call-interactively 'exwm-layout-toggle-fullscreen)
|
||||
;; TODO: Store window configurations in a buffer-name-indexed alist? Not
|
||||
;; sure that would ever be useful.
|
||||
;; TODO: Make the following a `toggle-single-window' defun and store in functions.el?
|
||||
(if (/= (count-windows) 1)
|
||||
(progn
|
||||
(setq exwm--last-window-configuration (current-window-configuration))
|
||||
(delete-other-windows))
|
||||
(when exwm--last-window-configuration
|
||||
(set-window-configuration exwm--last-window-configuration)))))
|
||||
(require 'functions)
|
||||
(toggle-single-window)))
|
||||
(exwm-input-set-key (kbd "s-o") #'exwm-layout-toggle-fullscreen-or-single-window)
|
||||
|
||||
(when (require 'functions)
|
||||
|
@ -63,10 +55,7 @@
|
|||
(exwm-input-set-key (kbd "s-g") #'helm-grep-git-or-ag)
|
||||
(exwm-input-set-key (kbd "s-G") #'helm-grep-git-all-or-ag))
|
||||
|
||||
;; TODO: Move `switch-to-last-buffer' to functions.el.
|
||||
(defun switch-to-last-buffer ()
|
||||
(interactive)
|
||||
(switch-to-buffer (other-buffer (current-buffer) 1)))
|
||||
(require 'functions)
|
||||
(exwm-input-set-key (kbd "s-<tab>") #'switch-to-last-buffer)
|
||||
(when (require 'evil nil t)
|
||||
(exwm-input-set-key (kbd "s-<tab>") #'evil-switch-to-windows-last-buffer)
|
||||
|
|
Loading…
Reference in New Issue