all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@jurta.org>
To: Glenn Morris <rgm@gnu.org>
Cc: Alan Mackenzie <acm@muc.de>, 17351@debbugs.gnu.org
Subject: bug#17351: Trunk emacs splats .emacs.desktop at startup
Date: Mon, 23 Jun 2014 02:01:16 +0300	[thread overview]
Message-ID: <87y4wo5ynb.fsf@mail.jurta.org> (raw)
In-Reply-To: <1ud2e177bf.fsf@fencepost.gnu.org> (Glenn Morris's message of "Sun, 22 Jun 2014 03:05:24 -0400")

> 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'."






  reply	other threads:[~2014-06-22 23:01 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-26 18:04 bug#17351: Trunk emacs splats .emacs.desktop at startup Alan Mackenzie
2014-04-27  8:22 ` Juri Linkov
2014-04-27  9:15   ` Alan Mackenzie
2014-04-27  9:52     ` Juri Linkov
2014-04-27 14:31       ` Stefan Monnier
2014-04-27 22:13         ` Stefan Monnier
2014-06-22  7:05           ` Glenn Morris
2014-06-22 23:01             ` Juri Linkov [this message]
2014-06-23  0:05               ` Glenn Morris
2014-06-23 22:57                 ` Juri Linkov
2014-06-24 18:30                   ` Glenn Morris
2014-06-24 23:23                     ` Juri Linkov
2014-06-26 19:31                       ` Glenn Morris
2014-06-26 23:44                         ` Juri Linkov
2014-08-11  1:18                           ` Glenn Morris
2014-08-12  6:52                             ` Juri Linkov
2014-07-02 23:52                       ` Juri Linkov
2014-07-03  2:42                         ` Glenn Morris
2014-07-03 23:35                           ` Juri Linkov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87y4wo5ynb.fsf@mail.jurta.org \
    --to=juri@jurta.org \
    --cc=17351@debbugs.gnu.org \
    --cc=acm@muc.de \
    --cc=rgm@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.