我有许多水平和垂直拆分的elscreen选项卡(框架?)。我希望能够保存当前缓冲区,每个框架中的Windows布局以及框架本身。
简而言之,我希望能够关闭emacs并以与关闭时相同的状态重新打开。
(我认为我的术语正确)
最佳答案
这就是我在.emacs中完全出于此目的的内容(内联资源):
自动保存和恢复Elscreen session
;; http://stackoverflow.com/questions/803812/emacs-reopen-buffers-from-last-session-on-startup
(defvar emacs-configuration-directory
"~/.emacs.d/"
"The directory where the emacs configuration files are stored.")
(defvar elscreen-tab-configuration-store-filename
(concat emacs-configuration-directory ".elscreen")
"The file where the elscreen tab configuration is stored.")
在退出时自动保存Elscreen:
(defun elscreen-store ()
"Store the elscreen tab configuration."
(interactive)
(if (desktop-save emacs-configuration-directory)
(with-temp-file elscreen-tab-configuration-store-filename
(insert (prin1-to-string (elscreen-get-screen-to-name-alist))))))
;; (push #'elscreen-store kill-emacs-hook)
在启动时自动恢复Elscreen:
(defun elscreen-restore ()
"Restore the elscreen tab configuration."
(interactive)
(if (desktop-read)
(let ((screens (reverse
(read
(with-temp-buffer
(insert-file-contents elscreen-tab-configuration-store-filename)
(buffer-string))))))
(while screens
(setq screen (car (car screens)))
(setq buffers (split-string (cdr (car screens)) ":"))
(if (eq screen 0)
(switch-to-buffer (car buffers))
(elscreen-find-and-goto-by-buffer (car buffers) t t))
(while (cdr buffers)
(switch-to-buffer-other-window (car (cdr buffers)))
(setq buffers (cdr buffers)))
(setq screens (cdr screens))))))
;; (elscreen-restore)
关于emacs - 保存和还原elscreen选项卡和拆分帧,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/22445670/