2

I like my Emacs to reopen all previously opened files when I start it up.

My setup is simple:

;; save desktop autosave sessions
(setq desktop-dirname             "~/"
      desktop-base-file-name      ".emacs.desktop"
      desktop-base-lock-name      "lock"
      desktop-path                (list desktop-dirname)
      desktop-save                t
      desktop-files-not-to-save   "^$" ;reload tramp paths
      desktop-load-locked-desktop nil)
(desktop-save-mode 1)
(setq desktop-restore-frames t)
(setq desktop-restore-in-current-display t)
(setq desktop-restore-forces-onscreen nil)

;; measured in autosave cycles
(setq desktop-recover-save-period 1)

;; ; if idle s save
(run-with-idle-timer 60.0 t 'desktop-save-in-desktop-dir)

The problem is that after startup, the .emacs.desktop file is not reloaded - the only thing reopened is the buffer that was active when I quit emacs.

The .emacs.desktop was correctly saved in the previous session (every 60s of idle time as per my setup) and the file looks ok to me... I can't reload it with desktop-read either I get this error:

desktop-create-buffer: Wrong number of arguments: #[(beg end length) "è è Æ=MÇ È!.GÉV.ÊË!.ËÉH!?IÌÍ#Æ=I ÉUI67ZÎU)Y89zÏ)e Ð=e Ñ=¦7eVè7SfzÏèÒvÓ :Ô;ÕÖxÉW²×Ø!ÉW²<Ö=>ÞÖ?;bÙÚÛÜ>Ý#ÞQ!)ÞÎÎ{=>?£ß àá=>âÜãä&Í#£?)£Ö?;bÙë!)£Í=ìíîÉÉ{\"!ïð!£ß ;bñÎ!.Eè ò=½ ÉUè Í=è7bÓ :óôõ6Í#çÆÉfF8ÀÉÉÉ#+È+" [auto-capitalize auto-capitalize-predicate this-command key global-map length self-insert-command this-command-keys vectorp 0 ...] 9 ("/home/rxs/.emacs.d/elpa/auto-capitalize-20131013.2205/auto-capitalize.elc" . 3420)], 1 desktop-create-buffer: Wrong number of arguments: #[(beg end length) "è è Æ=MÇ È!.GÉV.ÊË!.ËÉH!?IÌÍ#Æ=I ÉUI67ZÎU)Y89zÏ)e Ð=e Ñ=¦7eVè7SfzÏèÒvÓ :Ô;ÕÖxÉW²×Ø!ÉW²<Ö=>ÞÖ?;bÙÚÛÜ>Ý#ÞQ!)ÞÎÎ{=>?£ß àá=>âÜãä&Í#£?)£Ö?;bÙë!)£Í=ìíîÉÉ{\"!ïð!£ß ;bñÎ!.Eè ò=½ ÉUè Í=è7bÓ :óôõ6Í#çÆÉfF8ÀÉÉÉ#+È+" [auto-capitalize auto-capitalize-predicate this-command key global-map length self-insert-command this-command-keys vectorp 0 ...] 9 ("/home/rxs/.emacs.d/elpa/auto-capitalize-20131013.2205/auto-capitalize.elc" . 3420)], 1

My .emacs.desktop file:

;; -*- mode: emacs-lisp; coding: emacs-mule; -*-
;; --------------------------------------------------------------------------
;; Desktop File for Emacs
;; --------------------------------------------------------------------------
;; Created Thu Jan 21 11:26:04 2016
;; Desktop file format version 206
;; Emacs version 24.5.1

;; Global section:
(setq desktop-saved-frameset [frameset 1 (22176 45628 743516 309000) (desktop . "206") "rxs@localhost.localdomain" nil nil ((((font-backend xft x) (font . "-unknown-Liberation Mono-normal-normal-normal-*-12-*-*-*-m-0-iso10646-1") (font-parameter) (border-width . 0) (internal-border-width . 1) (right-divider-width . 0) (bottom-divider-width . 0) (vertical-scroll-bars) (foreground-color . "#f8f8f8") (background-color . "#26292c") (mouse-color . "black") (border-color . "black") (screen-gamma) (line-spacing) (left-fringe . 10) (right-fringe . 11) (scroll-bar-foreground) (scroll-bar-background . "grey75") (menu-bar-lines . 0) (tool-bar-lines . 0) (title) (wait-for-wm . t) (fullscreen) (tool-bar-position . top) (icon-type . t) (auto-raise) (auto-lower) (cursor-type . box) (scroll-bar-width . 0) (alpha) (horizontal-scroll-bars . t) (display-type . color) (background-mode . dark) (cursor-color . "brown3") (environment) (powerline-cache) (frameset--id . "1A06-6A10-F26F-68FD") (frameset--mini t . t) (height . 55) (width . 179) (modeline . t) (minibuffer . t) (unsplittable) (left . 0) (top . 0) (icon-name) (visibility . t) (display . ":0") (explicit-name)) ((min-height . 4) (min-width . 10) (min-height-ignore . 2) (min-width-ignore . 5) (min-height-safe . 1) (min-width-safe . 2) (min-pixel-height . 56) (min-pixel-width . 70) (min-pixel-height-ignore . 28) (min-pixel-width-ignore . 35) (min-pixel-height-safe . 14) (min-pixel-width-safe . 14)) leaf (pixel-width . 1276) (pixel-height . 762) (total-width . 182) (total-height . 54) (normal-height . 1.0) (normal-width . 1.0) (buffer "org-wiki.org" (selected . t) (hscroll . 0) (fringes 10 11 nil) (margins 3) (scroll-bars 0 0 t nil) (vscroll . 0) (dedicated) (point . 24576) (start . 1))))])
(setq desktop-missing-file-warning nil)
(setq tags-file-name nil)
(setq tags-table-list nil)
(setq search-ring '("ohio" "q" "someb" "revie" "exp" "grow" "goals" "make" "agile"))
(setq regexp-search-ring nil)
(setq register-alist '((48 . "")))
(setq file-name-history '("/home/rxs/org/wiki/org-wiki.org" "/home/rxs/org/agenda.org" "/home/rxs/.emacs.desktop"))

;; Buffer section -- buffers listed in same order as in buffer list:
(desktop-create-buffer 206
  "/home/rxs/org/wiki/org-wiki.org"
  "org-wiki.org"
  'org-mode
  '(rsk-minor-mode override-global-mode auto-compile-on-load-mode auto-capitalize which-key-mode beacon-mode modalka-mode helm-mode company-mode ivy-mode yas-minor-mode smartparens-mode)
  24576
  '(nil nil)
  nil
  nil
  '((buffer-file-coding-system . utf-8-unix) (truncate-lines . t)))

(desktop-create-buffer 206
  "/home/rxs/org/agenda.org"
  "agenda.org"
  'org-mode
  '(rsk-minor-mode override-global-mode auto-compile-on-load-mode auto-capitalize which-key-mode beacon-mode modalka-mode helm-mode company-mode ivy-mode yas-minor-mode smartparens-mode)
  1
  '(nil nil)
  nil
  nil
  '((buffer-file-coding-system . utf-8-unix) (truncate-lines . t)))

(desktop-create-buffer 206
  "/home/rxs/.emacs.desktop"
  ".emacs.desktop"
  'emacs-lisp-mode
  '(rsk-minor-mode override-global-mode auto-compile-on-load-mode which-key-mode beacon-mode modalka-mode helm-mode company-mode ivy-mode yas-minor-mode smartparens-mode)
  4510
  '(1 nil)
  nil
  nil
  '((buffer-file-coding-system . emacs-mule-unix)))
  • Did you upgrade or modify your Emacs installation in the meantime? Are you sure the file isn't corrupted? Please post the complete error message, and if possible your .emacs.desktop (censored for anything private). – Gilles 'SO- stop being evil' Jan 20 '16 at 21:08
  • Thank you. There was no upgrade in the meantime. I can re-create this problem for any session... I've added an example of the .emacs.desktop file and specified the question (actually what happens on restart is that one single file is reopened - the last active buffer in the previous session, nothing else). Desktop-read gives the error which I included in full length now. I wonder if it can have something to do with the encoding of the .emacs.desktop file - I use utf-8 everywhere, but .emacs.desktop has emacs-mule-unix. – user673592 Jan 21 '16 at 10:51
2

Regarding the comments, that encoding is fine (note that it's explicit in the desktop file's header, hence clearly intentional).

The seeming-gibberish is byte-compiled elisp, and we can see from the file path displayed that it's from auto-capitalize.elc.

I can infer from the full path that this is an ELPA package you got from MELPA, so I suspect you basically have a third-party library which doesn't play nicely with desktop.el.

I would try editing both instances of auto-capitalize out of the desktop file, and then attempting to read it again.

  • You got it! Editing the auto-capitalize files out of .emacs.desktop didn't help, but deactivating the whole auto-capitalize package did. I have no idea how is it conflicting with destkop-save, but I'm glad this got sorted out! Thank you! – user673592 Jan 21 '16 at 11:25
  • You're welcome. You might follow this up with the auto-capitalize package author -- they may well be keen to fix the issue. – phils Jan 21 '16 at 20:20
0

This is the solution

Here is how I set it up in my config:

(use-package auto-capitalize
  :ensure t
  :config
  (add-to-list 'auto-capitalize-words "http")
  (add-to-list 'desktop-minor-mode-handlers
               '(auto-capitalize . (lambda (desktop-buffer-locals)))))

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.