unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Reuben Thomas <rrt@sc3d.org>
To: Juri Linkov <juri@jurta.org>
Cc: tomas@tuxteam.de, emacs-devel@gnu.org
Subject: Re: desktop.el: autosave?
Date: Wed, 10 Apr 2013 02:36:35 +0100	[thread overview]
Message-ID: <CAOnWdohjMO+0AsGr4WBSZyPOO=se+UTMMVS8st2qWgkH8nj3tQ@mail.gmail.com> (raw)
In-Reply-To: <alpine.DEB.0.99999.0712110042160.4186@localhost.localdomain>

[-- Attachment #1: Type: text/plain, Size: 2491 bytes --]

On 11 December 2007 00:42, Reuben Thomas <rrt@sc3d.org> wrote:

> On Tue, 11 Dec 2007, Juri Linkov wrote:
>
>  This is how other modes work: when you want a configuration change to
>> take effect, you should disable and re-enable this mode.
>>
>
> Fair enough, then.


[Some time passed]

I have just revisited this. Nothing much seems to have changed in
desktop.el in the mean time.

I have gathered together what was agreed on earlier in the thread, and
implemented it:

(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)
    (when (called-interactively-p 'interactive)
        (message "Desktop saved in %s" (abbreviate-file-name dirname)))))

(defun desktop-owner-save-in-desktop-dir ()
  "Save the desktop if we are its owner."
  (if (eq (desktop-owner) (emacs-pid))
      (desktop-save-in-desktop-dir)))

(define-minor-mode desktop-save-mode
  "Toggle desktop saving (Desktop Save mode).
With a prefix argument ARG, enable Desktop Save mode if ARG is
positive, and disable it otherwise.  If called from Lisp, enable
the mode if ARG is omitted or nil.

If Desktop Save mode is enabled, the state of Emacs is saved from
one session to another.  See variable `desktop-save' and function
`desktop-read' for details."
  :global t
  :group 'desktop
  (if desktop-save-mode
      (if desktop-auto-save
          (add-hook 'auto-save-hook 'desktop-owner-save-in-desktop-dir))
    (remove-hook 'auto-save-hook 'desktop-owner-save-in-desktop-dir)))

Remaining issues:

1. Here I have added the function desktop-owner-save-in-desktop-dir which
only saves the desktop if the current process owns it.

2. There was some discussion over whether by default we should use a
separate timer or auto-save-hook. For now I've used the latter.

3. It was desired to save the desktop only when it changed. Juri Linkov
previously said "This is easy to do once we will decide what auto-saving
method to use", so, since I don't know how to do it anyway, and since the
auto-saving method is not yet decided, I didn't implement that yet.

I've been happily using essentially the above code (mostly Juri's, with a
handful of lines by me) since this thread went quiet over five years ago.

-- 
http://rrt.sc3d.org

[-- Attachment #2: Type: text/html, Size: 3481 bytes --]

  reply	other threads:[~2013-04-10  1:36 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <alpine.DEB.0.99999.0711301407250.4037@localhost.localdomain>
2007-11-30 23:35 ` desktop.el: autosave? Richard Stallman
2007-12-01  0:35   ` Juri Linkov
2007-12-01 23:41     ` Richard Stallman
2007-12-03 22:57       ` Juri Linkov
2007-12-04  7:39         ` martin rudalics
2007-12-05  2:57           ` Richard Stallman
2007-12-05  9:02             ` martin rudalics
2007-12-05 22:28               ` Juri Linkov
2007-12-05 23:09                 ` martin rudalics
2007-12-05 23:41                   ` Juri Linkov
2007-12-06 15:12                     ` Richard Stallman
2007-12-06  2:11               ` Richard Stallman
2007-12-06 23:29                 ` Juri Linkov
2007-12-04 16:55         ` Richard Stallman
2007-12-06 14:58         ` Reuben Thomas
2007-12-06 15:38           ` tomas
2007-12-06 15:47             ` Reuben Thomas
2007-12-06 23:28               ` Juri Linkov
2007-12-06 23:44                 ` Reuben Thomas
2007-12-07  0:03                   ` Juri Linkov
2007-12-07  2:48                     ` Stefan Monnier
2007-12-09 20:35                     ` Reuben Thomas
2007-12-10  0:27                       ` Juri Linkov
2007-12-10  0:35                         ` Reuben Thomas
2007-12-10  0:50                           ` Drew Adams
2007-12-10  0:59                           ` Juri Linkov
2007-12-10  1:10                             ` Reuben Thomas
2007-12-10  3:03                         ` Stefan Monnier
2007-12-10 22:01                           ` Reuben Thomas
2007-12-10 23:55                             ` Juri Linkov
2007-12-11  0:10                               ` Reuben Thomas
2007-12-11  0:23                                 ` Juri Linkov
2007-12-11  0:42                                   ` Reuben Thomas
2013-04-10  1:36                                     ` Reuben Thomas [this message]
2013-04-10  7:05                                       ` Juri Linkov
2013-04-10 10:57                                         ` Reuben Thomas
2013-04-11  8:29                                           ` Juri Linkov
2013-04-11 11:04                                             ` Reuben Thomas
2013-04-27 20:57                                               ` Juri Linkov
2007-12-10 22:02                           ` Reuben Thomas
2007-12-10 22:12                             ` Drew Adams
2007-12-10 22:16                               ` Reuben Thomas
2007-12-10 23:57                                 ` Juri Linkov
2007-12-11  0:02                                   ` Reuben Thomas
2007-12-11  0:23                                     ` Juri Linkov
2007-12-11  0:48                                       ` Reuben Thomas
2007-12-11 19:01                                       ` Richard Stallman
2007-12-12  0:50                                         ` Reuben Thomas
2007-12-12 22:53                                           ` Richard Stallman
2007-12-12 23:59                                             ` Juri Linkov
2007-12-14 10:10                                               ` Richard Stallman
2007-12-07  2:47                 ` Stefan Monnier
2007-12-07 17:18             ` Richard Stallman
2007-12-03 21:14     ` Reuben Thomas
2007-12-03 22:57       ` Juri Linkov
2007-12-06 14:56         ` Reuben Thomas

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='CAOnWdohjMO+0AsGr4WBSZyPOO=se+UTMMVS8st2qWgkH8nj3tQ@mail.gmail.com' \
    --to=rrt@sc3d.org \
    --cc=emacs-devel@gnu.org \
    --cc=juri@jurta.org \
    --cc=tomas@tuxteam.de \
    /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).