Restore Emacs Session/Desktop

耗尽温柔 提交于 2019-11-30 05:15:07

I'd suggest a simple solution - create a function that sets up your preferred layout. For example I like to have some IRC channels in the second half of my screen in separate windows, so that I may have a look at them from time to time, while coding for instance in another window. So I've written some simple code to take care of the window splitting and arrange my buffers as I wish:

;; show some buffers
(defun show-some-buffers (buffer-list)
  (split-window-horizontally)
  (other-window 1)
  (dolist (buffer buffer-list)
    (split-window-vertically)
    (switch-to-buffer (get-buffer buffer))
    (other-window 1))
  ;; at the end we have one extra window we need to delete
  (delete-window)
  (balance-windows))

;; show some erc buffers
(defun show-erc-buffers ()
  (interactive)
  (show-some-buffers '("#emacs" "#clojure")))

The code is fairly simple and features no error checking, but it will give you a hint about what I mean.

You might want to consider using registers as well to store some window configurations.

As you've found, desktop.el and session.el are a good start, but they don't restore the window layouts.

However, using revive.el you can save/restore arbitrary window configurations, which are remembered between restarts.

Also check out these hints relating to window layouts, which cover winner-mode and the trick of saving window configurations into registers.

In addition to @Bozhidar's excellent answer on automating your window layout (which I do myself), you may also want to look into using GNU Screen which can be used to retain an arbitrary set of processes across log ins. There's a pretty good tutorial here, and since you'll be using emacs you'll also want to give this a read.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!