gpt4 book ai didi

emacs - 保存和恢复 elscreen 标签和分帧

转载 作者:行者123 更新时间:2023-12-04 12:08:14 25 4
gpt4 key购买 nike

我有许多水平和垂直拆分的 elscreen 选项卡(框架?)。我希望能够保存当前缓冲区、每帧中的窗口布局以及帧本身。

简而言之,我希望能够关闭 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com