Subject: [PATCH] desktop-read re-enables desktop autosave when it shouldn't

From: Kelly Dean <[email-masked]>
Date: Fri, 23 Jan 2015 03:45:26 +0000

Since patches are allowed now...

--- emacs-24.4/lisp/desktop.el
+++ emacs-24.4/lisp/desktop.el
@@ -1119,7 +1119,8 @@
 	      (desktop-buffer-fail-count 0)
 	      (owner (desktop-owner))
 	      ;; Avoid desktop saving during evaluation of desktop buffer.
-	      (desktop-save nil))
+	      (desktop-save nil)
+	      (desktop-autosave-was-enabled))
 	  (if (and owner
 		   (memq desktop-load-locked-desktop '(nil ask))
 		   (or (null desktop-load-locked-desktop)
@@ -1135,6 +1136,8 @@
 	    ;; Temporarily disable the autosave that will leave it
 	    ;; disabled when loading the desktop fails with errors,
 	    ;; thus not overwriting the desktop with broken contents.
+	    (setq desktop-autosave-was-enabled
+		  (memq 'desktop-auto-save-set-timer window-configuration-change-hook))
 	    (desktop-auto-save-disable)
 	    ;; Evaluate desktop buffer and remember when it was modified.
 	    (load (desktop-full-file-name) t t t)
@@ -1188,7 +1191,7 @@
 				  (set-window-prev-buffers window nil)
 				  (set-window-next-buffers window nil))))
  	    (setq desktop-saved-frameset nil)
-	    (desktop-auto-save-enable)
+	    (if desktop-autosave-was-enabled (desktop-auto-save-enable))
 	    t))
       ;; No desktop file found.
       (desktop-clear)