[Top][All Lists]

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

bug#22025: Emacs 25 corrupts Emacs 24 .emacs.desktop.

From: Alan Mackenzie
Subject: bug#22025: Emacs 25 corrupts Emacs 24 .emacs.desktop.
Date: Wed, 2 Dec 2015 12:35:31 +0000
User-agent: Mutt/1.5.23 (2014-03-12)

Hello, Drew.

On Tue, Dec 01, 2015 at 09:46:57AM -0800, Drew Adams wrote:
> > I think (but I don't know for sure) that explicitly invoking
> > `desktop-save' is quite rare

> I and other Bookmark+ users use it all the time.  We create
> desktops as bookmarks, and switch among them - any number
> of them - by "jumping" to them.

Thanks.  I didn't know about this.  As a matter of interest, where is
the source for Bookmark+?

> > "- most desktop files will be saved at Emacs shutdown,

> Are you sure?  My guess is that most users who only do
> that content themselves with a single desktop file, or
> perhaps 2 or 3.  Users of desktop bookmarks might have
> dozens of them.

I have just a single desktop file.  The idea of having lots of them, and
switching between them is a new one to me.  A big problem with the
desktop idea is that of gradually accumulating files which must be
explicitly closed at some point.  I'm guessing that with lots of smaller
desktop files, you can just delete an entire desktop when you've finished
using it.

> And saving is independent of Emacs shutdown, logically,
> and in reality for desktop bookmarks.

> IMHO, it is a big mistake to assume that desktops are
> used only in the way provided out of the box.  This is
> one example of that.


> Another example:

> It is an unfortunate mistake that desktop.el is written in
> such a way that it hard-codes an assumption that there is
> only one desktop file per directory.  The code uses a
> desktop directory (argument or global var) everywhere,
> instead of a desktop file argument.  Yet the directory is
> used only to find the file.

> The basic functions, such as `desktop-change-dir' and
> `desktop-read', assume this, so they don't take a
> DESKTOP-FILE as an optional arg.  I needed to write simple
> wrapper functions for them, to let users have multiple
> desktop files in the same directory.  There is no reason
> why a desktop file must be associated with a directory -
> users should be able to store the files anywhere.

Here, I begin to get a little sceptical.  How will being able to store
desktop files "anywhere" actually be useful?  It seems to me that the
typical desktop file of many will, in fact, be associated with a
particular directory, the directory where work is actually being done for
some particular topic.  Being able to store it "anywhere" would add
complexity to desktop.el, and I don't think that extra complexity has
yet been justified.

> For example:

> (defun bmkp-desktop-change-dir (desktop-file)
>   "Change to desktop saved in DESKTOP-FILE.
> Kill the desktop as specified by variables `desktop-save-mode' and
>  `desktop-save'.
> Clear the desktop and load DESKTOP-FILE."
>   (interactive (list (read-file-name "Change to desktop file: ")))
>   (unless (file-name-absolute-p desktop-file)
>     (setq desktop-file  (expand-file-name desktop-file)))
>   (let ((desktop-base-file-name (file-name-nondirectory desktop-file))
>         (desktop-dir            (file-name-directory desktop-file))
>         (desktop-restore-eager  t) ; Don't bother with lazy restore.
>         (desktop-globals-to-save
>          (bmkp-remove-if
>            (lambda (elt) (memq elt bmkp-desktop-no-save-vars))
>            desktop-globals-to-save)))
>     (bmkp-desktop-kill)
>     (desktop-clear)
>     (desktop-read desktop-dir)))

> Fiddling to bind `desktop-base-file-name' etc. is silly,
> but necessary because of the desktop.el implementation's
> assumption about desktop files.

> This is the kind of thing that can result from thinking
> things like "explicitly invoking `desktop-save' is quite
> rare".  Don't assume that the originally intended use case
> is the only one.

> This said, I don't have anything particular to say now about
> a change in desktop format or prompting the user (once only)
> about upgrading the format used.  And I haven't looked at the
> proposed change.

> FWIW, bookmark.el handles evolution of the bookmark-file
> format across 3 versions in a way that is transparent to
> users.  Dunno whether the format change for desktop files is
> similar, but if it is, you might want to take a look at how
> bookmark.el handles it.  Search bookmark.el for "IMPORTANT
> NOTICE" to see a description of the changes and how they are
> dealt with.

In the new desktop format, the central function `desktop-create' now has
an extra argument.  Since `desktop-create' is written to the desktop
file as a function call, it has too many arguments for the old version of
desktop.el in Emacs <= 24.5.  There is no nice and easy way to deal with

> HTH. 

Alan Mackenzie (Nuremberg, Germany).

reply via email to

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