DesktopAid for (X)Emacs

What is it?

I got tired of opening XEmacs frames and loading a bunch of files whenever I started XEmacs so I created this little aid. When installed it will save your editing session when you quit (X)Emacs and reload it when you start your favorite editor again.

A DesktopAid session is made up of a list of the files you have open and the cursor positions in the buffers visiting the files. It also contains the list of frames you are using and which files are being displayed in those frames. A third element in the session is the file name history, i.e. the history you get when pressing [C-x] [C-f].

Besides the automagic loading and saving of the session when starting and stopping (X)Emacs, it is also possible to save the session at any other moment in time. This will enable you to have multiple session configurations, one for each project your working on for instance. It will be very easy to switch from one project to another because you only have to load the corresponding session after which all your files will be present again and you can continue working from where you left off.

I have been using this code for a few years now with my XEmacs 21.1. Some changes have been made over that period of time to improve and fix some of the features. I haven't, however, tested this with a version of Emacs. So if you find any bugs or have any suggestions for things to add the just let me know.

How do you use it?

To make sure that (X)Emacs can find the desktopaid.elc file, you will have to add the following lines in your .emacs or .xemacs/init.el file:

      (setq load-path (cons "<path-to-desktopaid.elc>/" load-path))
      (autoload 'dta-hook-up "desktopaid.elc" "Desktop Aid" t)

You have to substitute <path-to-desktopaid.elc> by the directory in which you installed the compiled DesktopAid code (desktopaid.elc). If, in addition, you want to enable the automatic loading and saving of your editing session you will also have to add the next line:

      (dta-hook-up)

When you start (X)Emacs, you will get asked to specify which session you want to restore. By just pressing [Enter] the session that was saved when you last exited (X)Emacs will be restored. You can of course choose any other previously saved session.

If you want to save your session at an intermediate stage then just execute M-x dta-save-session. You will be prompted to specify a name for the session file that you want to use. This file will be saved in the DesktopAid directory. I suggest to always append a .conf extension to these files to easily identify them.

There is a similar command to load a session, just execute M-x dta-load-session. It has the same behaviour as the session restoring when you start (X)Emacs.

The dta-switch-session function is a small variation of the load function. It also loads a new session but first kills all existing buffers so you can start with a clean sheet.

Configuration

Some configuration of DesktopAid is possible. All the customizable values can be found in the Environment|Desktopaid customization group.

dta-cfg-dir
The directory in which the session files will be saved. Its default value is ~/.desktopaid.
dta-default-cfg
The name of the default session file. This file is used to save the session when you exit (X)Emacs. It is also the file that is used when you restore a session without selecting a file name. Its default value is desktopaid.conf.
dta-default-auto
When this option is enabled, then the dta-default-cfg variable will be automatically changed (and saved to your ~/.emacs file) whenever you load or save a session configuration. When you switch sessions using the dta-switch-session command, the current session will first be saved before loading the new one if this option is enabled. Conclusion: this option will make sure that the default configuration file is always the last one you used.
dta-max-history-length
This is the number of elements from the history that will be saved into the session. If this value is nil then all elements will be saved. Its default value is 10.

Where do you get it?

For our Un*x friends: desktopaid-1.0.5.tar.gz

For our Windows friends: desktopaid-1.0.5.zip

Difference with desktop.el?

I got a couple of remarks lately about the standard Emacs utility package desktop.el; questions like why my DesktopAid would be better. Let me say this first, I didn't know about desktop.el until a few weeks ago. DesktopAid saw its first light as a couple of functions in my .emacs file.

After checking the code of desktop.el I must say that both packages are quite alike. Their interfaces might be different, but their functionality is very similar. An extra feature of desktop.el is that it can also save dired, rmail, mh and info buffers. For file buffers it also saves the major and minor modes that are active.

So what can DesktopAid do better? Well, it also saves and restores your (X)Emacs frames.

A user's comment about DesktopAid and desktop.el:
    I've been using desktop.el for about two years, now, but have always been frustrated that it didn't remember my frames. I was very happy to discover Desktop Aid a few weeks ago, and have been happily using since then, but I didn't turn desktop.el off, and it seems to work fine. Desktop.el loads all of my buffers back, including dired, etc., and then desktop aid restores my frames the way they were. So far, I've not discovered any reason not to use them together. (M.G.)

Complaints

If you have any remarks, bugs, fixes, ... you can use the SourceForge forums and/or tracker to submit them or you can contact me here

SourceForge Logo Created by XEmacs Valid CSS! Valid XHTML 1.0! Valid HTML 4.01!

airborne @ SF Last modified: Sun Apr 7 20:11:51 CEST 2002