From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#16630: desktop-auto-save seems confusing Date: Wed, 05 Feb 2014 09:48:36 +0200 Organization: JURTA Message-ID: <8738jyqaqj.fsf@mail.jurta.org> References: <24d2j4vds1.fsf@fencepost.gnu.org> <87zjm8bmpt.fsf@mail.jurta.org> <87a9e7wc3o.fsf@mail.jurta.org> <10y51qkswe.fsf@fencepost.gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1391588053 9981 80.91.229.3 (5 Feb 2014 08:14:13 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 5 Feb 2014 08:14:13 +0000 (UTC) Cc: 16630@debbugs.gnu.org To: Glenn Morris Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Feb 05 09:14:19 2014 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1WAxch-0003iB-Ko for geb-bug-gnu-emacs@m.gmane.org; Wed, 05 Feb 2014 09:14:19 +0100 Original-Received: from localhost ([::1]:57865 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WAxch-0005RL-5b for geb-bug-gnu-emacs@m.gmane.org; Wed, 05 Feb 2014 03:14:19 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:35071) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WAxcX-0005Q3-Vy for bug-gnu-emacs@gnu.org; Wed, 05 Feb 2014 03:14:15 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WAxcR-0004Nz-Sd for bug-gnu-emacs@gnu.org; Wed, 05 Feb 2014 03:14:09 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:36086) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WAxcR-0004Nv-PO for bug-gnu-emacs@gnu.org; Wed, 05 Feb 2014 03:14:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1WAxcR-0003FY-JC for bug-gnu-emacs@gnu.org; Wed, 05 Feb 2014 03:14:03 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 05 Feb 2014 08:14:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 16630 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 16630-submit@debbugs.gnu.org id=B16630.139158798112338 (code B ref 16630); Wed, 05 Feb 2014 08:14:03 +0000 Original-Received: (at 16630) by debbugs.gnu.org; 5 Feb 2014 08:13:01 +0000 Original-Received: from localhost ([127.0.0.1]:50096 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WAxbR-0003Cq-6z for submit@debbugs.gnu.org; Wed, 05 Feb 2014 03:13:01 -0500 Original-Received: from [69.163.184.122] (port=54782 helo=ps18281.dreamhostps.com) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WAxbP-0003Cf-3O for 16630@debbugs.gnu.org; Wed, 05 Feb 2014 03:12:59 -0500 Original-Received: from localhost.jurta.org (ps18281.dreamhostps.com [69.163.184.122]) by ps18281.dreamhostps.com (Postfix) with ESMTP id 424413018E1382; Wed, 5 Feb 2014 00:12:57 -0800 (PST) In-Reply-To: <10y51qkswe.fsf@fencepost.gnu.org> (Glenn Morris's message of "Wed, 05 Feb 2014 00:52:49 -0500") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (x86_64-pc-linux-gnu) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.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-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:84601 Archived-At: > Why doesn't desktop-save-mode simply enable the auto-save timer? > The timer function itself seems to take the necessary steps to ensure it > only actually does something when appropriate. This would be simpler, and I guess there should not be much performance overhead of firing the timer that does nothing in some rare cases (when the desktop filename is not yet known or another instance acquires the lock). But `desktop-auto-save-set-timer' still needs to be called from :set of `desktop-auto-save-timeout' defcustom for the case when the user customizes the timeout either from 0 to a positive integer, or back to 0 that needs to cancel the timer. === modified file 'lisp/desktop.el' --- lisp/desktop.el 2014-01-01 07:43:34 +0000 +++ lisp/desktop.el 2014-02-05 07:47:45 +0000 @@ -162,7 +162,10 @@ (define-minor-mode desktop-save-mode one session to another. See variable `desktop-save' and function `desktop-read' for details." :global t - :group 'desktop) + :group 'desktop + (if desktop-save-mode + (desktop-auto-save-set-timer) + (desktop-auto-save-cancel-timer))) (defun desktop-save-mode-off () "Disable `desktop-save-mode'. Provided for use in hooks." @@ -1216,6 +1219,11 @@ (defun desktop-auto-save-set-timer () (run-with-idle-timer desktop-auto-save-timeout t 'desktop-auto-save)))) +(defun desktop-auto-save-cancel-timer () + (when desktop-auto-save-timer + (cancel-timer desktop-auto-save-timer) + (setq desktop-auto-save-timer nil))) + ;; ---------------------------------------------------------------------------- ;;;###autoload (defun desktop-revert () @@ -1465,10 +1471,9 @@ (add-hook (let ((key "--no-desktop")) (when (member key command-line-args) (setq command-line-args (delete key command-line-args)) - (setq desktop-save-mode nil))) + (desktop-save-mode 0))) (when desktop-save-mode (desktop-read) - (desktop-auto-save-set-timer) (setq inhibit-startup-screen t)))) ;; So we can restore vc-dir buffers.