From: Juri Linkov <juri@jurta.org>
To: martin rudalics <rudalics@gmx.at>
Cc: Juanma Barranquero <lekktu@gmail.com>,
Eli Zaretskii <eliz@gnu.org>,
emacs-devel@gnu.org
Subject: Re: desktop-auto-save-timeout
Date: Fri, 06 Jun 2014 02:35:42 +0300 [thread overview]
Message-ID: <87sinj55vd.fsf@mail.jurta.org> (raw)
In-Reply-To: <539020DA.3090206@gmx.at> (martin rudalics's message of "Thu, 05 Jun 2014 09:48:42 +0200")
>> 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 ()
next prev parent reply other threads:[~2014-06-05 23:35 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-29 18:24 desktop-auto-save-timeout Eli Zaretskii
2014-06-04 22:49 ` desktop-auto-save-timeout Juri Linkov
2014-06-05 7:48 ` desktop-auto-save-timeout martin rudalics
2014-06-05 23:35 ` Juri Linkov [this message]
2014-06-06 6:33 ` desktop-auto-save-timeout Eli Zaretskii
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87sinj55vd.fsf@mail.jurta.org \
--to=juri@jurta.org \
--cc=eliz@gnu.org \
--cc=emacs-devel@gnu.org \
--cc=lekktu@gmail.com \
--cc=rudalics@gmx.at \
/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 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).