summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Ankarström <john@ankarstrom.se>2021-10-21 00:30:50 +0200
committerJohn Ankarström <john@ankarstrom.se>2021-10-21 00:30:50 +0200
commitd776574f954fa08205f0879d31feaa56733b96a3 (patch)
treeb45109148b4a02950f234b224f7ec8776ac4b6bd
parent9b9884e715aebcd85bfcada8333d9309d3b54ff2 (diff)
downloadebsd-d776574f954fa08205f0879d31feaa56733b96a3.tar.gz
Emacs: Improve layout functions
-rw-r--r--.emacs.d/init.el20
1 files 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)