From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Peter Neidhardt Newsgroups: gmane.emacs.bugs Subject: bug#28945: 25.2; desktop auto save timer does not work Date: Sun, 22 Oct 2017 17:19:07 +0100 Message-ID: <87k1znuphh.fsf@gmail.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1508690599 23120 195.159.176.226 (22 Oct 2017 16:43:19 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 22 Oct 2017 16:43:19 +0000 (UTC) User-Agent: mu4e 0.9.18; emacs 25.2.1 To: 28945@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Oct 22 18:43:13 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e6JLE-0004yb-1Q for geb-bug-gnu-emacs@m.gmane.org; Sun, 22 Oct 2017 18:43:12 +0200 Original-Received: from localhost ([::1]:33597 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e6JLL-0005NK-Ct for geb-bug-gnu-emacs@m.gmane.org; Sun, 22 Oct 2017 12:43:19 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:46952) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e6JLA-0005MC-T5 for bug-gnu-emacs@gnu.org; Sun, 22 Oct 2017 12:43:10 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e6JL6-0007WG-Ar for bug-gnu-emacs@gnu.org; Sun, 22 Oct 2017 12:43:08 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:47439) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e6JL6-0007W9-5t for bug-gnu-emacs@gnu.org; Sun, 22 Oct 2017 12:43:04 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1e6JL5-0001Rm-PF for bug-gnu-emacs@gnu.org; Sun, 22 Oct 2017 12:43:03 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Peter Neidhardt Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 22 Oct 2017 16:43:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 28945 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.15086905525516 (code B ref -1); Sun, 22 Oct 2017 16:43:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 22 Oct 2017 16:42:32 +0000 Original-Received: from localhost ([127.0.0.1]:56120 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e6JKa-0001Qu-50 for submit@debbugs.gnu.org; Sun, 22 Oct 2017 12:42:32 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:51326) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e6IyC-0000qa-EE for submit@debbugs.gnu.org; Sun, 22 Oct 2017 12:19:24 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e6Iy5-0007JT-SA for submit@debbugs.gnu.org; Sun, 22 Oct 2017 12:19:19 -0400 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:43644) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e6Iy5-0007JK-Or for submit@debbugs.gnu.org; Sun, 22 Oct 2017 12:19:17 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:42282) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e6Iy4-0000Y5-Dy for bug-gnu-emacs@gnu.org; Sun, 22 Oct 2017 12:19:17 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e6Iy1-0007Fe-9S for bug-gnu-emacs@gnu.org; Sun, 22 Oct 2017 12:19:16 -0400 Original-Received: from mail-wm0-x22b.google.com ([2a00:1450:400c:c09::22b]:52722) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e6Iy0-0007ET-Ut for bug-gnu-emacs@gnu.org; Sun, 22 Oct 2017 12:19:13 -0400 Original-Received: by mail-wm0-x22b.google.com with SMTP id 78so2823327wmb.1 for ; Sun, 22 Oct 2017 09:19:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20161025; h=from:user-agent:to:subject:message-id:date:mime-version; bh=9rVd9MkKVNU7bqx/c9/J0JHd8SkzmMg5zIM/Nap6ZE0=; b=qN1tpLwa/2NI1EMNtBGd6Fslz2F+kIEzXRlyADEWz4dLjLzWUWjFi6MvribfAf+/0Y J4SsenyJ3Hhu6fBWGLZ15AFwAHODSKtUPA32x3TRDZIpFuY13R0E+whGXgWCk8y/c8zK qtXIUp4EYD8a8pc0DnxLHwDWbt4+bGwlPaCoo5tmfVSSY4Ow8Go8/CVjN8wfxdKCgPRY sWXNOVaTuHCTAb/LYQsm7cqQH88f0JshpMHnre5azhlvjho0fy/PF6J9MVVFDwIgI41E MYc0yJhNF/lsJtlSY8pXq7TB1JqGUD0cup8SF0ewOH/mFv4Je62+5l2YzYHwlQlN55Vc SnNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:user-agent:to:subject:message-id:date :mime-version; bh=9rVd9MkKVNU7bqx/c9/J0JHd8SkzmMg5zIM/Nap6ZE0=; b=I+8FMM63lVA4lLKNsdLc+6i76cBcT9VhQXutV59FH/W80JF3Fgk6m9J3ULLeZ2Hi67 74J4LHcnudBXixJLBPOw15kXNXwYRB3DkodRbhezxzawd6fLMAurHFYdcUdkccXupbwU fSAbiDoXX30NpkDAKeXleAx4cwzblReSjr+uYi4wxMn1+gojRvz2nyFj8UTKL18U6zIr pH275dvyaKCiiWKSLycEbfhi30SMLEjL8CP0vq626e1+ggsi269Xx9PggWzA2Xv2Encl vj99JxmFML/P6x+MXV8zdXi5hUngCB8/iYYcpTY1PV9lRbJ5zvw3t02mW3TyUbUBnPp0 r6PA== X-Gm-Message-State: AMCzsaWy7mw3D21FvyT3rRDbipfMhPjVwkTpabCETy8qM5mrOe6Tlqhi PJzpZmLZSXsflQfEvfU12miLnw== X-Google-Smtp-Source: ABhQp+SxYWG7LquPWqC+wJ+37RS6R77dScaPyI/eLt50z/90LYc4BkRxa8xo5O+3QVC29egBhJDfgA== X-Received: by 10.28.128.194 with SMTP id b185mr3270677wmd.152.1508689150010; Sun, 22 Oct 2017 09:19:10 -0700 (PDT) Original-Received: from dhiov23k ([197.1.53.85]) by smtp.gmail.com with ESMTPSA id 5sm10170732wrt.59.2017.10.22.09.19.08 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 22 Oct 2017 09:19:09 -0700 (PDT) X-Google-Original-From: Peter Neidhardt X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Mailman-Approved-At: Sun, 22 Oct 2017 12:42:30 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:138858 Archived-At: 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