summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Ankarström <john@ankarstrom.se>2021-10-16 21:12:58 +0200
committerJohn Ankarström <john@ankarstrom.se>2021-10-16 21:12:58 +0200
commita78c835e88316f94544cfaca19fe341b5e7fdb31 (patch)
tree3a45534b54f9cc08f1f8306d6a3c605ed551657f
parent16db26c60b1be680cf8873f89208bfd7a4765e16 (diff)
downloadebsd-a78c835e88316f94544cfaca19fe341b5e7fdb31.tar.gz
Emacs: Fix buffer layout bugs
-rw-r--r--.emacs.d/init.el42
1 files changed, 27 insertions, 15 deletions
diff --git a/.emacs.d/init.el b/.emacs.d/init.el
index 15c8a03..26ef5ff 100644
--- a/.emacs.d/init.el
+++ b/.emacs.d/init.el
@@ -147,6 +147,7 @@
([?\M-f] . [C-right])
([?\M-b] . [C-left])))
(setq exwm-input-global-keys '(("" . exwm-input-send-next-key)))
+(setf (car exwm-input-prefix-keys) ?\C-§)
(setq exwm-manage-force-tiling t)
(exwm-enable)
@@ -187,14 +188,18 @@
;;; Layouts
(defvar *buffer-layouts* (list) "Buffer-layout associations")
+(defvar *protect-buffer-layouts* nil "Temporarily protect buffer layouts")
(defun restore-buffer-layout ()
"Restore the layout associated with the current buffer."
(interactive)
(let ((conf (alist-get (current-buffer) *buffer-layouts*)))
- (when (not conf)
- (error "No layout associated with buffer."))
- (set-window-configuration conf)
- (message "Restored buffer layout.")))
+ (if conf
+ (progn
+ (set-window-configuration conf)
+ (message "Restored buffer layout."))
+ (setf (alist-get (current-buffer) *buffer-layouts*)
+ (current-window-configuration))
+ (message "Set buffer layout."))))
(defun switch-to-buffer-with-layout ()
"Switch to the window layout associated with a buffer. At the
same time, associate the original buffer with the original
@@ -203,18 +208,25 @@ layout.
If the new buffer has no associated layout, it is displayed as
the only window in the frame."
(interactive)
- (dolist (window (window-list))
- (setf (alist-get (window-buffer window) *buffer-layouts*)
- (current-window-configuration)))
- (call-interactively #'helm-multi-files)
- (delete-other-windows)
- (let* ((buf (current-buffer))
- (conf (alist-get buf *buffer-layouts*)))
- (when conf
- (set-window-configuration conf)
- (select-window (get-buffer-window buf)))))
+ (let ((*protect-buffer-layouts* t))
+ (dolist (window (window-list))
+ (setf (alist-get (window-buffer window) *buffer-layouts*)
+ (current-window-configuration)))
+ (call-interactively #'helm-multi-files)
+ (delete-other-windows)
+ (let* ((buf (current-buffer))
+ (conf (alist-get buf *buffer-layouts*)))
+ (when conf
+ (set-window-configuration conf)
+ (select-window (get-buffer-window buf))))))
+(defun delete-layouts-before-delete-other-windows (&optional window)
+ (when (not *protect-buffer-layouts*)
+ (dolist (window (window-list))
+ (setf (alist-get (window-buffer window) *buffer-layouts*) nil))))
(defun delete-layout-before-delete-window (window)
- (setf (alist-get (window-buffer window) *buffer-layouts*) nil))
+ (when (not *protect-buffer-layouts*)
+ (setf (alist-get (window-buffer window) *buffer-layouts*) nil)))
+(advice-add #'delete-other-windows :before #'delete-layouts-before-delete-other-windows)
(advice-add #'delete-window :before #'delete-layout-before-delete-window)
(advice-add #'quit-window :before #'delete-layout-before-delete-window)
(set-keys "C-c b" switch-to-buffer-with-layout