unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#28945: 25.2; desktop auto save timer does not work
@ 2017-10-22 16:19 Peter Neidhardt
  2017-10-22 17:11 ` Eli Zaretskii
  2017-10-28 12:12 ` Eli Zaretskii
  0 siblings, 2 replies; 24+ messages in thread
From: Peter Neidhardt @ 2017-10-22 16:19 UTC (permalink / raw)
  To: 28945


Recipe:

- Add (desktop-save-mode) to your init.el.

- Start Emacs.  Check the value of `window-configuration-change-hook':
the _global_ value should contain `desktop-auto-save-set-timer'.

- Save the desktop.

- Quit Emacs.

- Restart Emacs.

- Check `window-configuration-change-hook': the timer is gone.

I've narrowed down the issue to `desktop-read':

	;; ...
	(setq desktop-autosave-was-enabled
	  (memq 'desktop-auto-save-set-timer 'window-configuration-change-hook))
	(desktop-auto-save-disable)
	;; ...
	(if desktop-autosave-was-enabled (desktop-auto-save-enable))

The check is done on the _local_ value of
`window-configuration-change-hook', thus `desktop-auto-save-enable' will
never be re-run.

The fix is as simple as

	(setq desktop-autosave-was-enabled
	  (memq 'desktop-auto-save-set-timer (default-toplevel-value 'window-configuration-change-hook)))



I've been annoyed by this issue for years but before today I could not
find the logic behind the issue and did not know what to report.  The
issue effectively makes desktop-mode half-useless since desktop won't be
saved when Emacs gets killed too abruptly (crashes, power outage...).

Did nobody notice this before or is it that nobody could figure out the
logic like me?



While we are at it, we might change the documentation and value of `desktop-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 is terribly confusing, isn't it?  One might wonder whether it's a
timer that saves every 30 seconds or the configuration change.

The actual logic is as follow:

- On every window configuration change, the timer is _reset_.

- When idle for `desktop-auto-save-timeout', the desktop is saved.  The
  timer is run only _once_.

In practice, this means that the user actually be idle for 30 seconds or
else it won't get saved at all.  Does this happen a lot in practice?
I'm don't think so.  Considering the timer runs only once per window
conf change, it does not run very often, in particular it runs only once
when nothing is happening.

So I think it's wiser to set the default to something much lower, say 5
or 10.



Lastly, a minor nit: desktop.el adds a lambda to `after-init-hook'; can
we turn this into a named function?



In GNU Emacs 25.2.1 (x86_64-pc-linux-gnu, GTK+ Version 3.22.16)
 of 2017-09-02 built on dhiov23k
Windowing system distributor 'The X.Org Foundation', version 11.0.11905000
System Description:	Gentoo Base System release 2.4.1

Configured using:
 'configure --prefix=/usr --build=x86_64-pc-linux-gnu
 --host=x86_64-pc-linux-gnu --mandir=/usr/share/man
 --infodir=/usr/share/info --datadir=/usr/share --sysconfdir=/etc
 --localstatedir=/var/lib --disable-dependency-tracking
 --disable-silent-rules --docdir=/usr/share/doc/emacs-25.2
 --htmldir=/usr/share/doc/emacs-25.2/html --libdir=/usr/lib64
 --program-suffix=-emacs-25 --infodir=/usr/share/info/emacs-25
 --localstatedir=/var
 --enable-locallisppath=/etc/emacs:/usr/share/emacs/site-lisp
 --with-gameuser=:gamestat --without-compress-install
 --with-file-notification=inotify --enable-acl --without-dbus
 --without-modules --without-gpm --without-hesiod --without-kerberos
 --without-kerberos5 --with-xml2 --without-selinux --with-gnutls
 --without-wide-int --with-zlib --with-sound=alsa --with-x --without-ns
 --without-gconf --without-gsettings --without-toolkit-scroll-bars
 --with-gif --with-jpeg --with-png --with-rsvg --with-tiff --with-xpm
 --with-imagemagick --with-xft --without-cairo --without-libotf
 --without-m17n-flt --with-x-toolkit=gtk3 --without-xwidgets
 GENTOO_PACKAGE=app-editors/emacs-25.2 'CFLAGS=-march=ivybridge -O2
 -pipe' CPPFLAGS= 'LDFLAGS=-Wl,-O1 -Wl,--as-needed''

Configured features:
XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND NOTIFY ACL GNUTLS LIBXML2
FREETYPE XFT ZLIB GTK3 X11

Important settings:
  value of $LANG: en_US.utf8
  locale-coding-system: utf-8-unix

Major mode: Debbugs

Minor modes in effect:
  semantic-minor-modes-format: ((:eval (if (or semantic-highlight-edits-mode semantic-show-unmatched-syntax-mode)  S)))
  recentf-mode: t
  pdf-occur-global-minor-mode: t
  helm-top-poll-mode: t
  dired-async-mode: t
  helm-mode: t
  diff-auto-refine-mode: t
  helm-descbinds-mode: t
  global-evil-mc-extras-mode: t
  evil-mc-extras-mode: t
  global-evil-mc-mode: t
  evil-mc-mode: t
  async-bytecomp-package-mode: t
  global-undo-tree-mode: t
  undo-tree-mode: t
  shell-dirtrack-mode: t
  evil-mode: t
  evil-local-mode: t
  show-paren-mode: t
  savehist-mode: t
  save-place-mode: t
  desktop-save-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  window-divider-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  buffer-read-only: t
  size-indication-mode: t
  line-number-mode: t
  transient-mark-mode: t





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

* bug#28945: 25.2; desktop auto save timer does not work
  2017-10-22 16:19 bug#28945: 25.2; desktop auto save timer does not work Peter Neidhardt
@ 2017-10-22 17:11 ` Eli Zaretskii
  2017-10-22 17:41   ` Peter Neidhardt
  2017-10-28 12:12 ` Eli Zaretskii
  1 sibling, 1 reply; 24+ messages in thread
From: Eli Zaretskii @ 2017-10-22 17:11 UTC (permalink / raw)
  To: Peter Neidhardt; +Cc: 28945

> From: Peter Neidhardt <pe.neidhardt@googlemail.com>
> Date: Sun, 22 Oct 2017 17:19:07 +0100
> 
> Recipe:
> 
> - Add (desktop-save-mode) to your init.el.
> 
> - Start Emacs.  Check the value of `window-configuration-change-hook':
> the _global_ value should contain `desktop-auto-save-set-timer'.
> 
> - Save the desktop.
> 
> - Quit Emacs.
> 
> - Restart Emacs.
> 
> - Check `window-configuration-change-hook': the timer is gone.

Thank you for your report and analysis.  I need to read this
carefully, so for now just one comment about something that you only
touch tangentially:

> The actual logic is as follow:
> 
> - On every window configuration change, the timer is _reset_.
> 
> - When idle for `desktop-auto-save-timeout', the desktop is saved.  The
>   timer is run only _once_.
> 
> In practice, this means that the user actually be idle for 30 seconds or
> else it won't get saved at all.  Does this happen a lot in practice?
> I'm don't think so.  Considering the timer runs only once per window
> conf change, it does not run very often, in particular it runs only once
> when nothing is happening.
> 
> So I think it's wiser to set the default to something much lower, say 5
> or 10.

IME, that would be a mistake.  The problem with your logic is twofold:

  . "window configuration change" is actually something that happens a
    lot in a live Emacs session, because any change in windows layout,
    dimensions, the buffers they display, their values of point,
    etc. -- all of these constitute such a change.

  . saving a desktop in a large multi-frame session is expensive.

What this boils down to is that every automatic desktop-save produces
an annoying "hiccup" in Emacs responsiveness.  This is the main reason
why I disabled the desktop timer long ago, and save the desktop from a
midnight.el hook, once every day.  Yes, this means that I can lose
some of my configuration due to a crash, but (a) Emacs doesn't crash
so frequently, and (b) my sessions are organized in a way that makes
sure the loss is minimal, mainly some files that were visited will
need to be re-visited manually.

So if we are going to discuss the timer, I'd actually recommend making
the interval longer, not shorter, if only because auto-saving desktop
more often than we auto-save our edits (see auto-save-interval) makes
little sense to me.





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

* bug#28945: 25.2; desktop auto save timer does not work
  2017-10-22 17:11 ` Eli Zaretskii
@ 2017-10-22 17:41   ` Peter Neidhardt
  2017-10-22 17:58     ` Eli Zaretskii
  0 siblings, 1 reply; 24+ messages in thread
From: Peter Neidhardt @ 2017-10-22 17:41 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 28945


Eli Zaretskii <eliz@gnu.org> writes:

> What this boils down to is that every automatic desktop-save produces
> an annoying "hiccup" in Emacs responsiveness.

It's an idle timer, so if Emacs is idle, i.e. the user does not do
> anything, how to you notice the hiccup? 

-- 
Peter Neidhardt

Rainy days and Mondays always get me down.





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

* bug#28945: 25.2; desktop auto save timer does not work
  2017-10-22 17:41   ` Peter Neidhardt
@ 2017-10-22 17:58     ` Eli Zaretskii
  2017-10-23 19:28       ` Peter Neidhardt
  0 siblings, 1 reply; 24+ messages in thread
From: Eli Zaretskii @ 2017-10-22 17:58 UTC (permalink / raw)
  To: Peter Neidhardt; +Cc: 28945

> From: Peter Neidhardt <pe.neidhardt@googlemail.com>
> Cc: 28945@debbugs.gnu.org
> Date: Sun, 22 Oct 2017 18:41:50 +0100
> 
> Eli Zaretskii <eliz@gnu.org> writes:
> 
> > What this boils down to is that every automatic desktop-save produces
> > an annoying "hiccup" in Emacs responsiveness.
> 
> It's an idle timer, so if Emacs is idle, i.e. the user does not do
> anything, how to you notice the hiccup? 

I notice it when I resume typing during the time desktop.el
auto-saves.  The response to my typing is "sluggish", because once the
timer function starts running, it runs to completion, before Emacs
notices I typed something and responds.





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

* bug#28945: 25.2; desktop auto save timer does not work
  2017-10-22 17:58     ` Eli Zaretskii
@ 2017-10-23 19:28       ` Peter Neidhardt
  2017-10-23 19:35         ` Eli Zaretskii
  0 siblings, 1 reply; 24+ messages in thread
From: Peter Neidhardt @ 2017-10-23 19:28 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 28945


Eli Zaretskii <eliz@gnu.org> writes:

>> > What this boils down to is that every automatic desktop-save produces
>> > an annoying "hiccup" in Emacs responsiveness.
>>
>> It's an idle timer, so if Emacs is idle, i.e. the user does not do
>> anything, how to you notice the hiccup?
>
> I notice it when I resume typing during the time desktop.el
> auto-saves.  The response to my typing is "sluggish", because once the
> timer function starts running, it runs to completion, before Emacs
> notices I typed something and responds.

Correct me if I'm wrong:

- If you keep using Emacs for hours (that is "typing/moving the point
  around") without taking a 30 sec break, then the timer won't trigger
  the desktop saving.  Right?

- The sluggishness would only be noticed if you happen to do nothing for
  more than `desktop-auto-save-timeout' but for less than
  desktop-auto-save-timeout + "time needed for saving".  It seems
  improbable that this happens _often_.

- I've used desktop-mode for years and I've never noticed any
  sluggishness as it takes less than a fraction of a second to save.
  I've had crappy computers, but admitedly most of them had an SSD.  My
  current timeout is 5 and I don't see any performance impact even on a
  bad computer with an even worse HDD.

Either way, the default value is not that important since every user is free
to change the value.  What is more important is to document it
properly.  Something in the line of:

> If you experience any irresponsiveness everytime desktop gets saved,
> increase the timeout.
> If not, it's safe to have it around 10.

What do you think?

Cheers!

--
Peter Neidhardt

The difference between legal separation and divorce is that legal
separation gives the man time to hide his money.





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

* bug#28945: 25.2; desktop auto save timer does not work
  2017-10-23 19:28       ` Peter Neidhardt
@ 2017-10-23 19:35         ` Eli Zaretskii
  2017-10-23 19:57           ` Peter Neidhardt
  2017-10-24 21:46           ` Richard Stallman
  0 siblings, 2 replies; 24+ messages in thread
From: Eli Zaretskii @ 2017-10-23 19:35 UTC (permalink / raw)
  To: Peter Neidhardt; +Cc: 28945

> From: Peter Neidhardt <pe.neidhardt@googlemail.com>
> Cc: 28945@debbugs.gnu.org
> Date: Mon, 23 Oct 2017 20:28:34 +0100
> 
> 
> > I notice it when I resume typing during the time desktop.el
> > auto-saves.  The response to my typing is "sluggish", because once the
> > timer function starts running, it runs to completion, before Emacs
> > notices I typed something and responds.
> 
> Correct me if I'm wrong:
> 
> - If you keep using Emacs for hours (that is "typing/moving the point
>   around") without taking a 30 sec break, then the timer won't trigger
>   the desktop saving.  Right?

Right.

> - The sluggishness would only be noticed if you happen to do nothing for
>   more than `desktop-auto-save-timeout' but for less than
>   desktop-auto-save-timeout + "time needed for saving".  It seems
>   improbable that this happens _often_.

It happens quite often to me.  Believe it or not, I tend to think a
lot when I type in Emacs ;-)  30 sec is not such a long period for
thinking about your next word or phrase or implementation detail.

> - I've used desktop-mode for years and I've never noticed any
>   sluggishness as it takes less than a fraction of a second to save.
>   I've had crappy computers, but admitedly most of them had an SSD.  My
>   current timeout is 5 and I don't see any performance impact even on a
>   bad computer with an even worse HDD.

How many frames and how many buffers do you typically have in a
session?

> Either way, the default value is not that important since every user is free
> to change the value.  What is more important is to document it
> properly.

No argument here.

> > If you experience any irresponsiveness everytime desktop gets saved,
> > increase the timeout.
> > If not, it's safe to have it around 10.

This kind of advice generally belongs in the manual, not in the doc
string, IMO.





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

* bug#28945: 25.2; desktop auto save timer does not work
  2017-10-23 19:35         ` Eli Zaretskii
@ 2017-10-23 19:57           ` Peter Neidhardt
  2017-10-23 20:02             ` Eli Zaretskii
  2017-10-24 21:46           ` Richard Stallman
  1 sibling, 1 reply; 24+ messages in thread
From: Peter Neidhardt @ 2017-10-23 19:57 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 28945


Eli Zaretskii <eliz@gnu.org> writes:

> How many frames and how many buffers do you typically have in a
> session?

Only one frame (I use EXWM), but dozens of buffers, typically between 10-50.

>> > If you experience any irresponsiveness everytime desktop gets saved,
>> > increase the timeout.
>> > If not, it's safe to have it around 10.
>
> This kind of advice generally belongs in the manual, not in the doc
> string, IMO.

The manual has this:

> When ‘desktop-save-mode’ is active and the desktop file exists, Emacs
> auto-saves it every ‘desktop-auto-save-timeout’ seconds, if that is
> non-‘nil’ and non-zero.

It's terribly misleading: it does not mention that it only saves when
idle while "every" is wrong here considering that it saves only once
until the window configuration gets changed.

--
Peter Neidhardt

Calm down, it's *____\b\b\b\bonly* ones and zeroes.





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

* bug#28945: 25.2; desktop auto save timer does not work
  2017-10-23 19:57           ` Peter Neidhardt
@ 2017-10-23 20:02             ` Eli Zaretskii
  0 siblings, 0 replies; 24+ messages in thread
From: Eli Zaretskii @ 2017-10-23 20:02 UTC (permalink / raw)
  To: Peter Neidhardt; +Cc: 28945

> From: Peter Neidhardt <pe.neidhardt@googlemail.com>
> Cc: 28945@debbugs.gnu.org
> Date: Mon, 23 Oct 2017 20:57:17 +0100
> 
> > How many frames and how many buffers do you typically have in a
> > session?
> 
> Only one frame (I use EXWM), but dozens of buffers, typically between 10-50.

Well, I typically have around 5 frames, and several hundreds of
buffers.

> The manual has this:
> 
> > When ‘desktop-save-mode’ is active and the desktop file exists, Emacs
> > auto-saves it every ‘desktop-auto-save-timeout’ seconds, if that is
> > non-‘nil’ and non-zero.
> 
> It's terribly misleading: it does not mention that it only saves when
> idle while "every" is wrong here considering that it saves only once
> until the window configuration gets changed.

Yes, and your report mentioned it.  We'll get to that, my point was
just about the suggestion to make the default timeout shorter, not
about all the rest of your report.





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

* bug#28945: 25.2; desktop auto save timer does not work
  2017-10-23 19:35         ` Eli Zaretskii
  2017-10-23 19:57           ` Peter Neidhardt
@ 2017-10-24 21:46           ` Richard Stallman
  2017-10-25  2:32             ` Eli Zaretskii
  1 sibling, 1 reply; 24+ messages in thread
From: Richard Stallman @ 2017-10-24 21:46 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: pe.neidhardt, 28945

[[[ To any NSA and FBI agents reading my email: please consider    ]]]
[[[ whether defending the US Constitution against all enemies,     ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]

Standard Emacs auto saving used to save every N characters of keyboard
input, as well as after a certain amount of idleness.  Has this
feature been taken out?

-- 
Dr Richard Stallman
President, Free Software Foundation (gnu.org, fsf.org)
Internet Hall-of-Famer (internethalloffame.org)
Skype: No way! See stallman.org/skype.html.






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

* bug#28945: 25.2; desktop auto save timer does not work
  2017-10-24 21:46           ` Richard Stallman
@ 2017-10-25  2:32             ` Eli Zaretskii
  2017-10-26  3:42               ` Richard Stallman
  0 siblings, 1 reply; 24+ messages in thread
From: Eli Zaretskii @ 2017-10-25  2:32 UTC (permalink / raw)
  To: rms; +Cc: pe.neidhardt, 28945

> From: Richard Stallman <rms@gnu.org>
> CC: pe.neidhardt@googlemail.com, 28945@debbugs.gnu.org
> Date: Tue, 24 Oct 2017 17:46:29 -0400
> 
> Standard Emacs auto saving used to save every N characters of keyboard
> input, as well as after a certain amount of idleness.  Has this
> feature been taken out?

No, this is still as it always was.  But we are not talking about
auto-saving the buffers being edited, we are talking about auto-saving
the session via desktop.el.





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

* bug#28945: 25.2; desktop auto save timer does not work
  2017-10-25  2:32             ` Eli Zaretskii
@ 2017-10-26  3:42               ` Richard Stallman
  2017-10-26 10:01                 ` Pierre Neidhardt
  2017-10-26 15:53                 ` Eli Zaretskii
  0 siblings, 2 replies; 24+ messages in thread
From: Richard Stallman @ 2017-10-26  3:42 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: pe.neidhardt, 28945

[[[ To any NSA and FBI agents reading my email: please consider    ]]]
[[[ whether defending the US Constitution against all enemies,     ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]

  > No, this is still as it always was.  But we are not talking about
  > auto-saving the buffers being edited, we are talking about auto-saving
  > the session via desktop.el.

I see.

desktop.el says it saves status when Emacs is killed.
For that feature, why does it matter how long you have been editing?

Does desktop.el now do more than that?

-- 
Dr Richard Stallman
President, Free Software Foundation (gnu.org, fsf.org)
Internet Hall-of-Famer (internethalloffame.org)
Skype: No way! See stallman.org/skype.html.






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

* bug#28945: 25.2; desktop auto save timer does not work
  2017-10-26  3:42               ` Richard Stallman
@ 2017-10-26 10:01                 ` Pierre Neidhardt
  2017-10-27  2:42                   ` Richard Stallman
  2017-10-26 15:53                 ` Eli Zaretskii
  1 sibling, 1 reply; 24+ messages in thread
From: Pierre Neidhardt @ 2017-10-26 10:01 UTC (permalink / raw)
  To: rms; +Cc: 28945

It saves status when Emacs is killed but also once in a while when a
timer expires: this is to have a recent enough save in case of crash
and `kill-emacs-hook' is not run.

-- 
Pierre Neidhardt





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

* bug#28945: 25.2; desktop auto save timer does not work
  2017-10-26  3:42               ` Richard Stallman
  2017-10-26 10:01                 ` Pierre Neidhardt
@ 2017-10-26 15:53                 ` Eli Zaretskii
  2017-10-26 16:19                   ` Drew Adams
  1 sibling, 1 reply; 24+ messages in thread
From: Eli Zaretskii @ 2017-10-26 15:53 UTC (permalink / raw)
  To: rms; +Cc: pe.neidhardt, 28945

> From: Richard Stallman <rms@gnu.org>
> CC: pe.neidhardt@googlemail.com, 28945@debbugs.gnu.org
> Date: Wed, 25 Oct 2017 23:42:07 -0400
> 
> desktop.el says it saves status when Emacs is killed.
> For that feature, why does it matter how long you have been editing?
> 
> Does desktop.el now do more than that?

It does.  From the doc string:

  Once a desktop file exists, Emacs will auto-save it according to the
  option ‘desktop-auto-save-timeout’.





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

* bug#28945: 25.2; desktop auto save timer does not work
  2017-10-26 15:53                 ` Eli Zaretskii
@ 2017-10-26 16:19                   ` Drew Adams
  2017-10-26 17:10                     ` Eli Zaretskii
  0 siblings, 1 reply; 24+ messages in thread
From: Drew Adams @ 2017-10-26 16:19 UTC (permalink / raw)
  To: Eli Zaretskii, rms; +Cc: pe.neidhardt, 28945

> > desktop.el says it saves status when Emacs is killed.
> > For that feature, why does it matter how long you have been editing?
> >
> > Does desktop.el now do more than that?
> 
> It does.  From the doc string:
> 
>   Once a desktop file exists, Emacs will auto-save it according
>   to the option ‘desktop-auto-save-timeout’.

Why is the default value 30 instead of just nil (OFF)?
To be compatible with past behavior the default value
would be nil, no?





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

* bug#28945: 25.2; desktop auto save timer does not work
  2017-10-26 16:19                   ` Drew Adams
@ 2017-10-26 17:10                     ` Eli Zaretskii
  2017-10-26 18:28                       ` Drew Adams
  0 siblings, 1 reply; 24+ messages in thread
From: Eli Zaretskii @ 2017-10-26 17:10 UTC (permalink / raw)
  To: Drew Adams; +Cc: pe.neidhardt, rms, 28945

> Date: Thu, 26 Oct 2017 09:19:10 -0700 (PDT)
> From: Drew Adams <drew.adams@oracle.com>
> Cc: pe.neidhardt@googlemail.com, 28945@debbugs.gnu.org
> 
> >   Once a desktop file exists, Emacs will auto-save it according
> >   to the option ‘desktop-auto-save-timeout’.
> 
> Why is the default value 30 instead of just nil (OFF)?

I don't know.  But this question should have been asked when this
feature was introduced during development of Emacs 24.4.  Now it's a
fait accompli.





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

* bug#28945: 25.2; desktop auto save timer does not work
  2017-10-26 17:10                     ` Eli Zaretskii
@ 2017-10-26 18:28                       ` Drew Adams
  2017-10-26 18:46                         ` Eli Zaretskii
  0 siblings, 1 reply; 24+ messages in thread
From: Drew Adams @ 2017-10-26 18:28 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: pe.neidhardt, rms, 28945

> > > Once a desktop file exists, Emacs will auto-save it
> > > according to the option ‘desktop-auto-save-timeout’.
> >
> > Why is the default value 30 instead of just nil (OFF)?
> 
> I don't know.  But this question should have been asked when this
> feature was introduced during development of Emacs 24.4.  Now it's a
> fait accompli.

I see.  I wasn't aware of it back then.  Mea culpa.
(I don't use desktop in a way that would be affected by
this, so I wasn't aware of it until this bug thread.
It doesn't affect me directly.)

And I didn't realize when I sent my message that this
was baked-in way back in 24.4.  Too bad.

Kinda hard to believe that the default behavior would
be changed in an incompatible way like that, but so
be it.  Also hard to believe, if it was so easy to
change the default behavior in 24.4 from a longstanding
one, that it is now so hard to change it (e.g. back).
Fait accompli, maybe.  But once and for all, over and
done with?

Too bad also, if, as you say, this question should have
been asked back then, that it wasn't asked by those who
were looking at the possible new feature.  (I don't know
that it wasn't asked, but you seem to suggest that, by
saying that it should have been.)








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

* bug#28945: 25.2; desktop auto save timer does not work
  2017-10-26 18:28                       ` Drew Adams
@ 2017-10-26 18:46                         ` Eli Zaretskii
  0 siblings, 0 replies; 24+ messages in thread
From: Eli Zaretskii @ 2017-10-26 18:46 UTC (permalink / raw)
  To: Drew Adams; +Cc: pe.neidhardt, rms, 28945

> Date: Thu, 26 Oct 2017 11:28:08 -0700 (PDT)
> From: Drew Adams <drew.adams@oracle.com>
> Cc: rms@gnu.org, pe.neidhardt@googlemail.com, 28945@debbugs.gnu.org
> 
> Fait accompli, maybe.  But once and for all, over and
> done with?

No, of course not.  My point was just that the reasons why it was done
back then are no longer relevant; we should instead see whether we
have sufficient justification to change behavior that is the default
for the last 3 years.

> Too bad also, if, as you say, this question should have
> been asked back then, that it wasn't asked by those who
> were looking at the possible new feature.  (I don't know
> that it wasn't asked, but you seem to suggest that, by
> saying that it should have been.)

No, I don't know whether it was asked, I didn't do any research about
that.  I don't remember any discussions, but that doesn't mean there
were none.





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

* bug#28945: 25.2; desktop auto save timer does not work
  2017-10-26 10:01                 ` Pierre Neidhardt
@ 2017-10-27  2:42                   ` Richard Stallman
  2017-10-27  9:12                     ` Eli Zaretskii
  0 siblings, 1 reply; 24+ messages in thread
From: Richard Stallman @ 2017-10-27  2:42 UTC (permalink / raw)
  To: Pierre Neidhardt; +Cc: 28945

[[[ To any NSA and FBI agents reading my email: please consider    ]]]
[[[ whether defending the US Constitution against all enemies,     ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]

  > It saves status when Emacs is killed but also once in a while when a
  > timer expires: this is to have a recent enough save in case of crash
  > and `kill-emacs-hook' is not run.

Then I think it should save every N characters, too.

-- 
Dr Richard Stallman
President, Free Software Foundation (gnu.org, fsf.org)
Internet Hall-of-Famer (internethalloffame.org)
Skype: No way! See stallman.org/skype.html.






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

* bug#28945: 25.2; desktop auto save timer does not work
  2017-10-27  2:42                   ` Richard Stallman
@ 2017-10-27  9:12                     ` Eli Zaretskii
  2017-10-28 21:49                       ` Richard Stallman
  0 siblings, 1 reply; 24+ messages in thread
From: Eli Zaretskii @ 2017-10-27  9:12 UTC (permalink / raw)
  To: rms; +Cc: pe.neidhardt, 28945

> From: Richard Stallman <rms@gnu.org>
> Date: Thu, 26 Oct 2017 22:42:29 -0400
> Cc: 28945@debbugs.gnu.org
> 
>   > It saves status when Emacs is killed but also once in a while when a
>   > timer expires: this is to have a recent enough save in case of crash
>   > and `kill-emacs-hook' is not run.
> 
> Then I think it should save every N characters, too.

Maybe, but I'm not sure: the amount of typing doesn't necessarily
present evidence of changes to the window configuration, visiting new
files or killing buffers, and other changes saved by desktop.el.  The
correlation between the two does exist, but it is much weaker than in
the case of auto-save of buffers.





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

* bug#28945: 25.2; desktop auto save timer does not work
  2017-10-22 16:19 bug#28945: 25.2; desktop auto save timer does not work Peter Neidhardt
  2017-10-22 17:11 ` Eli Zaretskii
@ 2017-10-28 12:12 ` Eli Zaretskii
  2017-11-05 16:18   ` Peter Neidhardt
  1 sibling, 1 reply; 24+ messages in thread
From: Eli Zaretskii @ 2017-10-28 12:12 UTC (permalink / raw)
  To: Peter Neidhardt; +Cc: 28945

> From: Peter Neidhardt <pe.neidhardt@googlemail.com>
> Date: Sun, 22 Oct 2017 17:19:07 +0100
> 
> - Add (desktop-save-mode) to your init.el.
> 
> - Start Emacs.  Check the value of `window-configuration-change-hook':
> the _global_ value should contain `desktop-auto-save-set-timer'.
> 
> - Save the desktop.
> 
> - Quit Emacs.
> 
> - Restart Emacs.
> 
> - Check `window-configuration-change-hook': the timer is gone.

I tried this recipe, but couldn't reproduce the problem.  I wonder
what was missing from my reproduction experiment.  My .emacs for this
experiment had only one line:

  (desktop-save-mode 1)

Is this different from what you tried?  In my case, the timer is still
there after restarting Emacs.

> I've narrowed down the issue to `desktop-read':
> 
> 	;; ...
> 	(setq desktop-autosave-was-enabled
> 	  (memq 'desktop-auto-save-set-timer 'window-configuration-change-hook))
> 	(desktop-auto-save-disable)
> 	;; ...
> 	(if desktop-autosave-was-enabled (desktop-auto-save-enable))
> 
> The check is done on the _local_ value of
> `window-configuration-change-hook', thus `desktop-auto-save-enable' will
> never be re-run.

Did you somehow make changes to the local value of
window-configuration-change-hook?  In my case, both the local value
and the global value are identical.

> While we are at it, we might change the documentation and value of `desktop-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 is terribly confusing, isn't it?  One might wonder whether it's a
> timer that saves every 30 seconds or the configuration change.
> 
> The actual logic is as follow:
> 
> - On every window configuration change, the timer is _reset_.
> 
> - When idle for `desktop-auto-save-timeout', the desktop is saved.  The
>   timer is run only _once_.

I've changed the doc string of desktop-auto-save-timeout as follows:

    "Number of seconds of idle time before auto-saving the desktop.
  The desktop will be auto-saved when this amount of idle time have
  passed after some change in the window configuration.
  This applies to an existing desktop file when `desktop-save-mode' is enabled.
  Zero or nil means disable auto-saving due to idleness."

And the doc string of desktop-auto-save-set-timer now says this:

    "Set the desktop auto-save timer.
  Cancel any previous timer.  When `desktop-auto-save-timeout' is a positive
  integer, start a new idle timer to call `desktop-auto-save' after that many
  seconds of idle time.
  This function is called from `window-configuration-change-hook'."

OK?

> In practice, this means that the user actually be idle for 30 seconds or
> else it won't get saved at all.

It will be saved when Emacs exits.

> Lastly, a minor nit: desktop.el adds a lambda to `after-init-hook'; can
> we turn this into a named function?

Why is that important?  This hook runs long before the user starts
interacting with Emacs, so there doesn't seem to be any good reason
for the user to look into what this function does.  Or am I missing
something?

Thanks.





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

* bug#28945: 25.2; desktop auto save timer does not work
  2017-10-27  9:12                     ` Eli Zaretskii
@ 2017-10-28 21:49                       ` Richard Stallman
  0 siblings, 0 replies; 24+ messages in thread
From: Richard Stallman @ 2017-10-28 21:49 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: pe.neidhardt, 28945

[[[ To any NSA and FBI agents reading my email: please consider    ]]]
[[[ whether defending the US Constitution against all enemies,     ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]

  > > Then I think it should save every N characters, too.

  > Maybe, but I'm not sure: the amount of typing doesn't necessarily
  > present evidence of changes to the window configuration, visiting new
  > files or killing buffers, and other changes saved by desktop.el.

Does that make a difference?  The point is to make sure that the data
gets saved every so often if you keep working and are not idle.
The precise details are not crucial.
This method would do that.


-- 
Dr Richard Stallman
President, Free Software Foundation (gnu.org, fsf.org)
Internet Hall-of-Famer (internethalloffame.org)
Skype: No way! See stallman.org/skype.html.






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

* bug#28945: 25.2; desktop auto save timer does not work
  2017-10-28 12:12 ` Eli Zaretskii
@ 2017-11-05 16:18   ` Peter Neidhardt
  2017-11-11  9:58     ` Eli Zaretskii
  0 siblings, 1 reply; 24+ messages in thread
From: Peter Neidhardt @ 2017-11-05 16:18 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 28945


Eli Zaretskii <eliz@gnu.org> writes:

>> From: Peter Neidhardt <pe.neidhardt@googlemail.com>
>> Date: Sun, 22 Oct 2017 17:19:07 +0100
>>
>> - Add (desktop-save-mode) to your init.el.
>>
>> - Start Emacs.  Check the value of `window-configuration-change-hook':
>> the _global_ value should contain `desktop-auto-save-set-timer'.
>>
>> - Save the desktop.
>>
>> - Quit Emacs.
>>
>> - Restart Emacs.
>>
>> - Check `window-configuration-change-hook': the timer is gone.
>
> I tried this recipe, but couldn't reproduce the problem.  I wonder
> what was missing from my reproduction experiment.  My .emacs for this
> experiment had only one line:
>
>   (desktop-save-mode 1)
>
> Is this different from what you tried?  In my case, the timer is still
> there after restarting Emacs.

You are right, there is more to trigger the issue:

  (desktop-save-mode 1)
	(global-linum-mode)

What happens is that during intialization,
window-configuration-change-hook is mode buffer-local by
global-linum-mode.  After init, desktop.el loads the desktop session, at
which point the window-configuration-change-hook is still buffer-local
and `desktop-read' fails.

> I've changed the doc string of desktop-auto-save-timeout as follows:
>
>     "Number of seconds of idle time before auto-saving the desktop.
>   The desktop will be auto-saved when this amount of idle time have
>   passed after some change in the window configuration.
>   This applies to an existing desktop file when `desktop-save-mode' is enabled.
>   Zero or nil means disable auto-saving due to idleness."
>
> And the doc string of desktop-auto-save-set-timer now says this:
>
>     "Set the desktop auto-save timer.
>   Cancel any previous timer.  When `desktop-auto-save-timeout' is a positive
>   integer, start a new idle timer to call `desktop-auto-save' after that many
>   seconds of idle time.
>   This function is called from `window-configuration-change-hook'."
>
> OK?

OK, thank you.

>> Lastly, a minor nit: desktop.el adds a lambda to `after-init-hook'; can
>> we turn this into a named function?
>
> Why is that important?  This hook runs long before the user starts
> interacting with Emacs, so there doesn't seem to be any good reason
> for the user to look into what this function does.  Or am I missing
> something?

It is for debugging problems such as this one.  While investigating
after-init-hook, I saw that value:


										#[0 "\303\211\235\203\304\"\301\305!\210\210	\205\306 \210\307\211\207"
												[command-line-args desktop-save-mode inhibit-startup-screen "--no-desktop" delete 0 desktop-read t]
												4])

Thankfully the word "desktop" is mentioned, otherwise it would have been
hard to get the hunch that something was executed afterwards regarding
the desktop.

Function names make for good documentation, they make the
self-documentation more meaningful.


--
Peter Neidhardt

You can always pick up your needle and move to another groove.
		-- Tim Leary





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

* bug#28945: 25.2; desktop auto save timer does not work
  2017-11-05 16:18   ` Peter Neidhardt
@ 2017-11-11  9:58     ` Eli Zaretskii
  2017-11-11 11:59       ` Peter Neidhardt
  0 siblings, 1 reply; 24+ messages in thread
From: Eli Zaretskii @ 2017-11-11  9:58 UTC (permalink / raw)
  To: Peter Neidhardt; +Cc: 28945-done

> From: Peter Neidhardt <pe.neidhardt@googlemail.com>
> Cc: 28945@debbugs.gnu.org
> Date: Sun, 05 Nov 2017 17:18:07 +0100
> 
> > I tried this recipe, but couldn't reproduce the problem.  I wonder
> > what was missing from my reproduction experiment.  My .emacs for this
> > experiment had only one line:
> >
> >   (desktop-save-mode 1)
> >
> > Is this different from what you tried?  In my case, the timer is still
> > there after restarting Emacs.
> 
> You are right, there is more to trigger the issue:
> 
>   (desktop-save-mode 1)
> 	(global-linum-mode)

You may wish to try the new native display of line numbers in Emacs
26, which doesn't have this problem (and is significantly faster).

> What happens is that during intialization,
> window-configuration-change-hook is mode buffer-local by
> global-linum-mode.  After init, desktop.el loads the desktop session, at
> which point the window-configuration-change-hook is still buffer-local
> and `desktop-read' fails.

Thanks, now everything is clear.

I installed your suggested fix into the release branch, and I'm
marking this bug done.

> >> Lastly, a minor nit: desktop.el adds a lambda to `after-init-hook'; can
> >> we turn this into a named function?
> >
> > Why is that important?  This hook runs long before the user starts
> > interacting with Emacs, so there doesn't seem to be any good reason
> > for the user to look into what this function does.  Or am I missing
> > something?
> 
> It is for debugging problems such as this one.  While investigating
> after-init-hook, I saw that value:
> 										#[0 "\303\211\235\203\304\"\301\305!\210\210	\205\306 \210\307\211\207"
> 												[command-line-args desktop-save-mode inhibit-startup-screen "--no-desktop" delete 0 desktop-read t]
> 												4])
> 
> Thankfully the word "desktop" is mentioned, otherwise it would have been
> hard to get the hunch that something was executed afterwards regarding
> the desktop.
> 
> Function names make for good documentation, they make the
> self-documentation more meaningful.

Yes, but that's an argument against _any_ use of lambda functions in
Emacs (because we don't really have opaque APIs).  So I'm not sure we
need to convert this to a named function.





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

* bug#28945: 25.2; desktop auto save timer does not work
  2017-11-11  9:58     ` Eli Zaretskii
@ 2017-11-11 11:59       ` Peter Neidhardt
  0 siblings, 0 replies; 24+ messages in thread
From: Peter Neidhardt @ 2017-11-11 11:59 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 28945-done


Eli Zaretskii <eliz@gnu.org> writes:

>> What happens is that during intialization,
>> window-configuration-change-hook is mode buffer-local by
>> global-linum-mode.  After init, desktop.el loads the desktop session, at
>> which point the window-configuration-change-hook is still buffer-local
>> and `desktop-read' fails.
>
> Thanks, now everything is clear.
>
> I installed your suggested fix into the release branch, and I'm
> marking this bug done.

Thank you very much.

-- 
Peter Neidhardt





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

end of thread, other threads:[~2017-11-11 11:59 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-10-22 16:19 bug#28945: 25.2; desktop auto save timer does not work Peter Neidhardt
2017-10-22 17:11 ` Eli Zaretskii
2017-10-22 17:41   ` Peter Neidhardt
2017-10-22 17:58     ` Eli Zaretskii
2017-10-23 19:28       ` Peter Neidhardt
2017-10-23 19:35         ` Eli Zaretskii
2017-10-23 19:57           ` Peter Neidhardt
2017-10-23 20:02             ` Eli Zaretskii
2017-10-24 21:46           ` Richard Stallman
2017-10-25  2:32             ` Eli Zaretskii
2017-10-26  3:42               ` Richard Stallman
2017-10-26 10:01                 ` Pierre Neidhardt
2017-10-27  2:42                   ` Richard Stallman
2017-10-27  9:12                     ` Eli Zaretskii
2017-10-28 21:49                       ` Richard Stallman
2017-10-26 15:53                 ` Eli Zaretskii
2017-10-26 16:19                   ` Drew Adams
2017-10-26 17:10                     ` Eli Zaretskii
2017-10-26 18:28                       ` Drew Adams
2017-10-26 18:46                         ` Eli Zaretskii
2017-10-28 12:12 ` Eli Zaretskii
2017-11-05 16:18   ` Peter Neidhardt
2017-11-11  9:58     ` Eli Zaretskii
2017-11-11 11:59       ` Peter Neidhardt

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).