From d776574f954fa08205f0879d31feaa56733b96a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Ankarstr=C3=B6m?= Date: Thu, 21 Oct 2021 00:30:50 +0200 Subject: Emacs: Improve layout functions --- .emacs.d/init.el | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/.emacs.d/init.el b/.emacs.d/init.el index 50b3ef2..6d27d71 100644 --- a/.emacs.d/init.el +++ b/.emacs.d/init.el @@ -184,20 +184,23 @@ (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." + "Restore the layout associated with the active buffer." (interactive) (let ((conf (alist-get (current-buffer) *buffer-layouts*))) (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")))) + (error "No layout associated with buffer")))) +(defun set-buffer-layout () + "Set the layout associated with the visible buffers." + (interactive) + (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 -layout. + "Switch to the window layout associated with a buffer. Before, +associate the currently visible buffers with the original layout. If the new buffer has no associated layout, it is displayed as the only window in the frame." @@ -231,7 +234,8 @@ the only window in the frame." (when (not *protect-buffer-layouts*) (setf (alist-get (window-buffer window) *buffer-layouts*) nil)))) (set-keys "C-c b" switch-to-buffer-with-layout - "C-c n" restore-buffer-layout) + "C-c n" set-buffer-layout + "C-c m" restore-buffer-layout) ;;; Lisp (autoload #'enable-paredit-mode "paredit" nil t) -- cgit v1.2.3