[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#17351: Trunk emacs splats .emacs.desktop at startup

From: Juri Linkov
Subject: bug#17351: Trunk emacs splats .emacs.desktop at startup
Date: Mon, 23 Jun 2014 02:01:16 +0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (x86_64-pc-linux-gnu)

> 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 
-    (remove-hook 'window-configuration-change-hook 
-    (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)
           (if (and (integerp value) (> value 0))
-              (add-hook 'window-configuration-change-hook 
-            (remove-hook 'window-configuration-change-hook 
-            (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-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 
@@ -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)
       ;; No desktop file found.
@@ -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'."

reply via email to

[Prev in Thread] Current Thread [Next in Thread]