18

As a follow-up to What's the fastest way to reload my .emacs file when I make changes so all my affected buffers will pick up those changes?

It was suggested that the restart question should be asked separately.

Is there an easy way to reopen all the previous buffers and keep the M-p interactive history for commands?

b4hand
  • 1,995
  • 1
  • 19
  • 31

1 Answers1

19

desktop-save-mode handles storing, and restoring, the buffer state of your session. It can also handle window and frames. For persistence of variables across sessions, see savehist-mode. By default it handles the minibuffer history, but it's not limited to it. Another interesting thing that might be interesting to persist is for example the kill-ring.

In short:

(desktop-save-mode 1)
(savehist-mode 1)
(add-to-list 'savehist-additional-variables 'kill-ring) ;; for example
Sigma
  • 4,510
  • 21
  • 27
  • 3
    This is true only for Emacs 24.4 or later. – Drew Oct 03 '14 at 02:42
  • @Drew sorry, which part exactly ? – Sigma Oct 03 '14 at 02:52
  • 3
    I was speaking about `desktop.el`, not `savehist`. The saving and restoring of windows and frames was added to `desktop.el` in Emacs 24.4. And support for buffers not associated with files. IOW, pretty much all of it (about desktop). ;-) There is support for buffers associated with files before 24.4, however. – Drew Oct 03 '14 at 03:15
  • Is there any similar solution in Emacs 24.3? I'm using 24.3.1. – b4hand Oct 03 '14 at 22:55
  • No. As I said, it was added in Emacs 24.4. You can pick up the Emacs 24.4 version of libraries `desktop.el` and `frameset.el` (which is new in 24.4), and try using them with Emacs 24.3, however. – Drew Oct 17 '14 at 06:00