emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: desktop.el: autosave?


From: Juri Linkov
Subject: Re: desktop.el: autosave?
Date: Tue, 11 Dec 2007 01:55:14 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.50 (gnu/linux)

> 1. A customizable preference, desktop-auto-save, which indicates whether
> desktop-save-in-desktop-dir should be added to auto-save-hook or not. Is
> the easiest way to do this to add a private function that desktop mode
> always adds to auto-save-hook and then have that private function test
> a boolean which is itself the customizable preference when it runs, to see
> whether to proceed or not?

No need for a separate function.  You could just change desktop-save-mode
as follows:

(define-minor-mode desktop-save-mode
  :global t
  :group 'desktop
  (if desktop-save-mode
      (if desktop-auto-save
          (add-hook 'auto-save-hook 'desktop-save-in-desktop-dir))
    (remove-hook 'auto-save-hook 'desktop-save-in-desktop-dir)))

But please note that I still think it would be better to use a timer.
You can look in savehist.el that it uses a separate non-idle timer.
It seems reasonable to do the same in desktop.el.

> 2. Change desktop-save-in-desktop-dir so that it only prompts for
> a directory if it is called interactively. The normal way seems to be to
> add an optional argument as described in the help for interactive-p.

I think it should be replaced with:

(defun desktop-save-in-desktop-dir (&optional dirname)
  "Save the desktop in directory `desktop-dirname'."
  (interactive
   (list (or desktop-dirname
             (read-directory-name "Directory to save desktop file in: "))))
  (when (and (null dirname) desktop-dirname)
    (setq dirname desktop-dirname))
  (when dirname
    (desktop-save dirname)
    (message "Desktop saved in %s" dirname)))

> 3. Change desktop-save-in-desktop-dir to be like savehist-mode, only
> actually writing the file when the history has changed since the
> last time.

This is easy to do once we will decide what auto-saving method to use.

-- 
Juri Linkov
http://www.jurta.org/emacs/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]