I am trying to get session to work, and I am especially keen on having my registers persistent between sessions. I installed the package sessions.el via Melpa (M-x list-packages) and I added this to my .emacs

(require 'session)
(add-hook 'after-init-hook 'session-initialize)

and I also added this as recommended in the session.el file (even though desktop is not enabled)

(setq desktop-globals-to-save '(desktop-missing-file-warning))

This doesn't seem to be working though. I tried saving my registers but they are not persistent across sessions. I tried changing the value of session-globals-include via M-x customize-group RET session RET to include register. This is what emacs added to my .emacs file after the changes in custom

    ((kill-ring 10 nil)
     (session-file-alist 100 t)
     (file-name-history 200 nil)
     search-ring regexp-search-ring
     (register-alist 100 t))))
 '(session-use-package t nil (session)))

Still, when I try to invoke a register using C-x r j r (the set register from the previous session), it says "Register doesn't contain a buffer position or configuration". I am not even sure anything is being saved between sessions. What am I doing wrong?

  • Emacs's built-in desktop.el works out-of-box, simply put (desktop-save-mode) to your init.el or .emacs, the package is also documented in Emacs manual ((info "(emacs) Saving Emacs Sessions")).
    – xuchunyang
    Sep 25, 2015 at 14:42
  • @xuchunyang OK, I will try that. I found out about desktop after having already wasted 2 hours trying to get sessions to work, so I didn't want it to be for nothing... BTW, should it be (desktop-save-mode 1)?
    – Vivi
    Sep 25, 2015 at 14:43
  • (desktop-save-mode) is the same as (desktop-save-mode 1) for relatively new Emacs version (24?) according to its docstring "If called from Lisp, enable the mode if ARG is omitted or nil.", you can read its docstring with C-h f to make sure that,
    – xuchunyang
    Sep 25, 2015 at 14:51
  • @xuchunyang OK, makes sense. When I was typing desktop-save-mode my minibuffer displayed the name of the function followed by "optional arg" so of course you are right. Desktop worked by the way, thank you :)
    – Vivi
    Sep 25, 2015 at 14:52
  • @xuchunyang would you post this as an answer so this doesn't show as a question with no answers? Vivi, would you then accept this to show this has been addressed?
    – rocky
    Oct 18, 2015 at 12:56

2 Answers 2


You can use Emacs's built-in package desktop.el instead, it saves registers by default. To use it, put following to your init file:

;; prior to Emacs 24
(desktop-save-mode 1)

You can also use other packages, such as built-in package savehist.el, as long as you can use it to keep value of the variable register-alist across session.


This is what I use:

;; don't use desktop mode for terminal
(when (display-graphic-p)
  (desktop-save-mode 1);; is x window

;; Add variables to desktop saving
(add-to-list 'desktop-globals-to-save 'register-alist)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.