Restore Emacs Session/Desktop

2019-02-03 08:09发布

I've been searching for how to restore an emacs session, with no luck. I'm looking to restore all previously open buffers, some of which might contain erc, shells, directory listings, files, etc.

Every time I open emacs, I spend a considerable amount of time arranging my buffers; splitting them into rows and columns, opening a shell, arranging irc channels. It takes a while to get onto work.

I've tried adding the following to my init.el

(desktop-save-mode 1)

And then using M-x desktop-save. This only seems to restore files that are open, not shells or anything else running within buffers.

I've also checked the following questions:

And read through:

Here's a screenshot example of my emacs session.

A simple answer would be to just focus on real work :P

3条回答
等我变得足够好
2楼-- · 2019-02-03 08:27

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.

查看更多
虎瘦雄心在
3楼-- · 2019-02-03 08:30

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.

查看更多
闹够了就滚
4楼-- · 2019-02-03 08:35

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.

查看更多
登录 后发表回答