1

I think, it'd make a lot more sense to have desktops be identified by names (like bookmarks). If it's deemed desirable that they can be stored in different locations, it'd make sense to select what file shall be used to store the desktop. So why does one have to select a directory instead (with the file name always being the same)?

1

I like the question, and I agree with its suggestion.

I don't think there is any good reason why desktop.el accepts only a directory (folder) argument and not, alternatively or additionally, a file argument for desktop-read.

After all, that function is about reading a desktop file. Why make it impossible to pass a file to the function? Why make the function only get the file to read from a directory or set of directories?

In effect, the design is that you can have only one desktop file per directory. Why? No reason, as far as I can see.

I think it was just a design oversight, based on a limited view of what desktops can be or how users could use them. One particular use case was hard-coded in such a way that it is impossible, using only the vanilla desktop.el code, to work with multiple desktop files in the same directory.

In Bookmark+ I had a need to let users bookmark multiple desktops and be able to put the desktop files in arbitrary folders anywhere - including multiple files in the same directory. So I defined function bmkp-desktop-read as a replacement (for the Bookmark+ code) for desktop-read.

What desktop.el should have done (should do) is to define desktop-read to read a desktop file (argument FILE). And on top of that it could easily also have code that lets you have a path of directories (option desktop-path), which is used as today, expecting (as a convenience for one use case) a single desktop file in those directories.


Above is my answer to "why" it is the way it is. You can get the feature you're apparently looking for, which is multiple desktop files per folder, by using Bookmark+. You can have any number of desktop bookmarks, and their desktop files can be anywhere. You need not even care where their files are.

To change to a given desktop, just "jump" to its bookmark, as you would jump to any bookmark. You can use key C-x j K to complete against only desktop bookmarks, i.e., to have only desktop bookmarks to choose from.

1

I believe a directory was used primarily because more than one file is saved there.

As well as the desktop file itself (desktop-base-file-name) there is also a lock file (desktop-base-lock-name).

Those are just variables, so there's nothing stopping you from writing a custom command to read a desktop-base-file-name from the user, derive an appropriate desktop-base-lock-name, and load that desktop file instead of the default.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.