all repos — nixfiles @ b53d38cfcd688467a7133d6077d62467946522ee

System and user configuration, managed by nix and home-manager

Emacs: Configure desktop mode

Auto-save Emacs' state if a desktop file exists.  This is probably as
DWIM as I need.
Alan Pearce alan@alanpearce.eu
Wed, 10 May 2017 16:10:53 +0200
commit

b53d38cfcd688467a7133d6077d62467946522ee

parent

7c3d8b535caa65ac6c861fd281af0147f0307855

1 files changed, 21 insertions(+), 0 deletions(-)

jump to
M emacs/.emacs.d/init.orgemacs/.emacs.d/init.org
@@ -944,6 +944,27 @@ (setq eyebrowse-new-workspace t)             (eyebrowse-mode +1)))
 #+END_SRC
 
+* Sessions
+
+** Desktop
+Save my Emacs session and restore it on startup.
+
+#+BEGIN_SRC emacs-lisp
+(use-package desktop
+  :ensure nil
+  :config (progn
+            (setq desktop-dirname (expand-file-name "desktop/" user-emacs-directory)
+                  desktop-base-file-name "emacs.desktop"
+                  desktop-base-lock-name "lock"
+                  desktop-path (list desktop-dirname)
+                  desktop-save 'if-exists
+                  desktop-files-not-to-save "^$"
+                  desktop-load-locked-desktop nil)
+            (unless (file-directory-p desktop-dirname)
+              (make-directory desktop-dirname))
+            (desktop-save-mode 1)))
+#+END_SRC
+
 ** winner
 
 Undo, for window-based commands.