all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@jurta.org>
To: Glenn Morris <rgm@gnu.org>
Cc: 16630@debbugs.gnu.org
Subject: bug#16630: desktop-auto-save seems confusing
Date: Wed, 05 Feb 2014 09:48:36 +0200	[thread overview]
Message-ID: <8738jyqaqj.fsf@mail.jurta.org> (raw)
In-Reply-To: <10y51qkswe.fsf@fencepost.gnu.org> (Glenn Morris's message of "Wed, 05 Feb 2014 00:52:49 -0500")

> 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.






  reply	other threads:[~2014-02-05  7:48 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-03  7:47 bug#16630: desktop-auto-save seems confusing Glenn Morris
2014-02-03  8:54 ` Juri Linkov
2014-02-04  2:47   ` Glenn Morris
2014-02-04  7:50     ` Juri Linkov
2014-02-05  5:52       ` Glenn Morris
2014-02-05  7:48         ` Juri Linkov [this message]
2014-02-07  7:45         ` Juri Linkov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8738jyqaqj.fsf@mail.jurta.org \
    --to=juri@jurta.org \
    --cc=16630@debbugs.gnu.org \
    --cc=rgm@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.