GNU bug report logs - #17351
Trunk emacs splats .emacs.desktop at startup

Previous Next

Package: emacs;

Reported by: Alan Mackenzie <acm <at> muc.de>

Date: Sat, 26 Apr 2014 18:09:02 UTC

Severity: important

Done: Juri Linkov <juri <at> jurta.org>

Bug is archived. No further changes may be made.

Full log


Message #26 received at 17351 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> jurta.org>
To: Glenn Morris <rgm <at> gnu.org>
Cc: Alan Mackenzie <acm <at> muc.de>, Stefan Monnier <monnier <at> iro.umontreal.ca>,
 17351 <at> debbugs.gnu.org
Subject: Re: bug#17351: Trunk emacs splats .emacs.desktop at startup
Date: Mon, 23 Jun 2014 02:01:16 +0300
> As a stopgap, how about disabling the autosave (with a warning, eg
> "error loading desktop; automatic save disabled until next manual save")
> if there were errors loading the desktop at startup?

It's not clear where to catch errors and handle them,
because they can occur everywhere and it's better to leave
the default error processing that enters the debugger.

But without such warning message, it's possible to disable
autosaving when loading desktop with a simple patch below.

> More generally, why does the autosaving actually save directly into the
> real desktop file? Why doesn't it use the normal autosave mechanism, ie
> write to a #desktop# file? Naively, it seems like this would be both
> simpler to implement and give better results.

This would keep the desktop file open all the time,
and users might not like to see it in the buffer list.
If this is not desirable then a backup copy needs to be saved
once per session after reading the desktop.

=== modified file 'lisp/desktop.el'
--- lisp/desktop.el	2014-06-06 23:38:40 +0000
+++ lisp/desktop.el	2014-06-22 22:52:31 +0000
@@ -174,11 +174,8 @@ (define-minor-mode desktop-save-mode
   :global t
   :group 'desktop
   (if desktop-save-mode
-      (when (and (integerp desktop-auto-save-timeout)
-		 (> desktop-auto-save-timeout 0))
-	(add-hook 'window-configuration-change-hook 'desktop-auto-save-set-timer))
-    (remove-hook 'window-configuration-change-hook 'desktop-auto-save-set-timer)
-    (desktop-auto-save-cancel-timer)))
+      (desktop-auto-save-enable)
+    (desktop-auto-save-disable)))
 
 (defun desktop-save-mode-off ()
   "Disable `desktop-save-mode'.  Provided for use in hooks."
@@ -219,9 +216,8 @@ (defcustom desktop-auto-save-timeout aut
          (set-default symbol value)
          (ignore-errors
 	   (if (and (integerp value) (> value 0))
-	       (add-hook 'window-configuration-change-hook 'desktop-auto-save-set-timer)
-	     (remove-hook 'window-configuration-change-hook 'desktop-auto-save-set-timer)
-	     (desktop-auto-save-cancel-timer))))
+	       (desktop-auto-save-enable value)
+	     (desktop-auto-save-disable))))
   :group 'desktop
   :version "24.4")
 
@@ -1132,6 +1128,7 @@ (defun desktop-read (&optional dirname)
 		(unless desktop-dirname
 		  (message "Desktop file in use; not loaded.")))
 	    (desktop-lazy-abort)
+	    (desktop-auto-save-disable)
 	    ;; Evaluate desktop buffer and remember when it was modified.
 	    (load (desktop-full-file-name) t t t)
 	    (setq desktop-file-modtime (nth 5 (file-attributes (desktop-full-file-name))))
@@ -1184,6 +1181,7 @@ (defun desktop-read (&optional dirname)
 				  (set-window-prev-buffers window nil)
 				  (set-window-next-buffers window nil))))
  	    (setq desktop-saved-frameset nil)
+	    (desktop-auto-save-enable)
 	    t))
       ;; No desktop file found.
       (desktop-clear)
@@ -1230,6 +1228,15 @@ (defun desktop-save-in-desktop-dir ()
 ;; Auto-Saving.
 (defvar desktop-auto-save-timer nil)
 
+(defun desktop-auto-save-enable (&optional timeout)
+  (when (and (integerp (or timeout desktop-auto-save-timeout))
+	     (> (or timeout desktop-auto-save-timeout) 0))
+    (add-hook 'window-configuration-change-hook 'desktop-auto-save-set-timer)))
+
+(defun desktop-auto-save-disable ()
+  (remove-hook 'window-configuration-change-hook 'desktop-auto-save-set-timer)
+  (desktop-auto-save-cancel-timer))
+
 (defun desktop-auto-save ()
   "Save the desktop periodically.
 Called by the timer created in `desktop-auto-save-set-timer'."





This bug report was last modified 10 years and 290 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.