all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* desktop-auto-save-timeout
@ 2014-05-29 18:24 Eli Zaretskii
  2014-06-04 22:49 ` desktop-auto-save-timeout Juri Linkov
  0 siblings, 1 reply; 5+ messages in thread
From: Eli Zaretskii @ 2014-05-29 18:24 UTC (permalink / raw)
  To: Juanma Barranquero; +Cc: emacs-devel

I wonder if the default value of this option (equal to
auto-save-timeout) is TRT.  The latter is used to auto-save our edits,
which are by definition precious, so people are likely to customize it
to small values (I have it at 15 sec).  By contrast, important desktop
changes are relatively rare, and even if some of them are lost, it's
not a disaster, at least not in general.

I've run Emacs 24.3.9x with the default value (which for me means
15sec) for some time, and the results are unpleasant: Emacs becomes
sluggish in its response whenever you look at the screen for more than
the timeout without typing anything.  E.g., start an I-search, then
make a pause to look at the text you found, then type C-s to continue
the search -- it takes a few seconds for Emacs to respond, probably
because the desktop's idle timer invokes desktop-save, which needs to
collect a non-trivial amount of data in a temp buffer, then run that
buffer through md5.  Very annoying.

Why not make the value of this variable nil by default, and let users
who think their desktop configuration is precious customize the
variable to some non-nil value?



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: desktop-auto-save-timeout
  2014-05-29 18:24 desktop-auto-save-timeout Eli Zaretskii
@ 2014-06-04 22:49 ` Juri Linkov
  2014-06-05  7:48   ` desktop-auto-save-timeout martin rudalics
  0 siblings, 1 reply; 5+ messages in thread
From: Juri Linkov @ 2014-06-04 22:49 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Juanma Barranquero, emacs-devel

> I wonder if the default value of this option (equal to
> auto-save-timeout) is TRT.  The latter is used to auto-save our edits,
> which are by definition precious, so people are likely to customize it
> to small values (I have it at 15 sec).  By contrast, important desktop
> changes are relatively rare, and even if some of them are lost, it's
> not a disaster, at least not in general.
>
> I've run Emacs 24.3.9x with the default value (which for me means
> 15sec) for some time, and the results are unpleasant: Emacs becomes
> sluggish in its response whenever you look at the screen for more than
> the timeout without typing anything.  E.g., start an I-search, then
> make a pause to look at the text you found, then type C-s to continue
> the search -- it takes a few seconds for Emacs to respond, probably
> because the desktop's idle timer invokes desktop-save, which needs to
> collect a non-trivial amount of data in a temp buffer, then run that
> buffer through md5.  Very annoying.

I realized now that the right way to implement the desktop auto-saving
is to activate an idle timer only on changes in the window configuration
by window-configuration-change-hook.

The desktop file is mostly about remembering a list of buffers and
windows.  There is no point in auto-saving each time point moves.
This is what web browsers do by auto-saving a list of tabs
only when you open/close a tab.



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: desktop-auto-save-timeout
  2014-06-04 22:49 ` desktop-auto-save-timeout Juri Linkov
@ 2014-06-05  7:48   ` martin rudalics
  2014-06-05 23:35     ` desktop-auto-save-timeout Juri Linkov
  0 siblings, 1 reply; 5+ messages in thread
From: martin rudalics @ 2014-06-05  7:48 UTC (permalink / raw)
  To: Juri Linkov, Eli Zaretskii; +Cc: Juanma Barranquero, emacs-devel

 > I realized now that the right way to implement the desktop auto-saving
 > is to activate an idle timer only on changes in the window configuration
 > by window-configuration-change-hook.
 >
 > The desktop file is mostly about remembering a list of buffers and
 > windows.  There is no point in auto-saving each time point moves.
 > This is what web browsers do by auto-saving a list of tabs
 > only when you open/close a tab.

Agreed.  We might lose some window-points and some buffers that have not
been displayed yet in that case but this is no great harm.

martin



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: desktop-auto-save-timeout
  2014-06-05  7:48   ` desktop-auto-save-timeout martin rudalics
@ 2014-06-05 23:35     ` Juri Linkov
  2014-06-06  6:33       ` desktop-auto-save-timeout Eli Zaretskii
  0 siblings, 1 reply; 5+ messages in thread
From: Juri Linkov @ 2014-06-05 23:35 UTC (permalink / raw)
  To: martin rudalics; +Cc: Juanma Barranquero, Eli Zaretskii, emacs-devel

>> I realized now that the right way to implement the desktop auto-saving
>> is to activate an idle timer only on changes in the window configuration
>> by window-configuration-change-hook.
>>
>> The desktop file is mostly about remembering a list of buffers and
>> windows.  There is no point in auto-saving each time point moves.
>> This is what web browsers do by auto-saving a list of tabs
>> only when you open/close a tab.
>
> Agreed.  We might lose some window-points and some buffers that have not
> been displayed yet in that case but this is no great harm.

This is implemented by this patch.  Not sure whether it fixes a regression or not.

=== modified file 'lisp/desktop.el'
--- lisp/desktop.el	2014-04-27 08:22:11 +0000
+++ lisp/desktop.el	2014-06-05 23:34:41 +0000
@@ -174,7 +174,8 @@ (define-minor-mode desktop-save-mode
   :global t
   :group 'desktop
   (if desktop-save-mode
-      (desktop-auto-save-set-timer)
+      (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)))
 
 (defun desktop-save-mode-off ()
@@ -207,13 +208,18 @@ (defcustom desktop-save 'ask-if-new
 
 (defcustom desktop-auto-save-timeout auto-save-timeout
   "Number of seconds idle time before auto-save of the desktop.
+The idle timer activates auto-saving only when window configuration changes.
 This applies to an existing desktop file when `desktop-save-mode' is enabled.
 Zero or nil means disable auto-saving due to idleness."
   :type '(choice (const :tag "Off" nil)
                  (integer :tag "Seconds"))
   :set (lambda (symbol value)
          (set-default symbol value)
-         (ignore-errors (desktop-auto-save-set-timer)))
+         (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))))
   :group 'desktop
   :version "24.4")
 
@@ -1244,7 +1250,7 @@ (defun desktop-auto-save-set-timer ()
   (when (and (integerp desktop-auto-save-timeout)
 	     (> desktop-auto-save-timeout 0))
     (setq desktop-auto-save-timer
-	  (run-with-idle-timer desktop-auto-save-timeout t
+	  (run-with-idle-timer desktop-auto-save-timeout nil
 			       'desktop-auto-save))))
 
 (defun desktop-auto-save-cancel-timer ()




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: desktop-auto-save-timeout
  2014-06-05 23:35     ` desktop-auto-save-timeout Juri Linkov
@ 2014-06-06  6:33       ` Eli Zaretskii
  0 siblings, 0 replies; 5+ messages in thread
From: Eli Zaretskii @ 2014-06-06  6:33 UTC (permalink / raw)
  To: Juri Linkov; +Cc: rudalics, emacs-devel, lekktu

> From: Juri Linkov <juri@jurta.org>
> Cc: Eli Zaretskii <eliz@gnu.org>,  Juanma Barranquero <lekktu@gmail.com>,  emacs-devel@gnu.org
> Date: Fri, 06 Jun 2014 02:35:42 +0300
> 
> >> I realized now that the right way to implement the desktop auto-saving
> >> is to activate an idle timer only on changes in the window configuration
> >> by window-configuration-change-hook.
> >>
> >> The desktop file is mostly about remembering a list of buffers and
> >> windows.  There is no point in auto-saving each time point moves.
> >> This is what web browsers do by auto-saving a list of tabs
> >> only when you open/close a tab.
> >
> > Agreed.  We might lose some window-points and some buffers that have not
> > been displayed yet in that case but this is no great harm.
> 
> This is implemented by this patch.  Not sure whether it fixes a regression or not.

Thanks.  Since this is a new functionality in Emacs 24.4, I think we
can allow it on the emacs-24 branch.



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-06-06  6:33 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-29 18:24 desktop-auto-save-timeout Eli Zaretskii
2014-06-04 22:49 ` desktop-auto-save-timeout Juri Linkov
2014-06-05  7:48   ` desktop-auto-save-timeout martin rudalics
2014-06-05 23:35     ` desktop-auto-save-timeout Juri Linkov
2014-06-06  6:33       ` desktop-auto-save-timeout Eli Zaretskii

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.