From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.devel Subject: Re: desktop-auto-save-timeout Date: Fri, 06 Jun 2014 02:35:42 +0300 Organization: JURTA Message-ID: <87sinj55vd.fsf@mail.jurta.org> References: <838upkh29q.fsf@gnu.org> <878upcffys.fsf@mail.jurta.org> <539020DA.3090206@gmx.at> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1402011532 31698 80.91.229.3 (5 Jun 2014 23:38:52 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 5 Jun 2014 23:38:52 +0000 (UTC) Cc: Juanma Barranquero , Eli Zaretskii , emacs-devel@gnu.org To: martin rudalics Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Jun 06 01:38:45 2014 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1WshF6-0002KM-Hh for ged-emacs-devel@m.gmane.org; Fri, 06 Jun 2014 01:38:44 +0200 Original-Received: from localhost ([::1]:44274 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WshF5-0005JJ-VI for ged-emacs-devel@m.gmane.org; Thu, 05 Jun 2014 19:38:43 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:37240) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WshEv-00059x-Ng for emacs-devel@gnu.org; Thu, 05 Jun 2014 19:38:41 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WshEo-0000yT-8k for emacs-devel@gnu.org; Thu, 05 Jun 2014 19:38:33 -0400 Original-Received: from alc-vshost7.dreamhost.com ([69.163.216.107]:59688 helo=ps18281.dreamhostps.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WshEg-0000wf-CP; Thu, 05 Jun 2014 19:38:18 -0400 Original-Received: from localhost.jurta.org (ps18281.dreamhostps.com [69.163.222.226]) by ps18281.dreamhostps.com (Postfix) with ESMTP id 76E6B30A3F7782; Thu, 5 Jun 2014 16:38:12 -0700 (PDT) In-Reply-To: <539020DA.3090206@gmx.at> (martin rudalics's message of "Thu, 05 Jun 2014 09:48:42 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (x86_64-pc-linux-gnu) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] X-Received-From: 69.163.216.107 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:172379 Archived-At: >> 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 ()