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.
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.
Some configuration of DesktopAid is possible. All the
customizable values can be found in the
Environment|Desktopaid
customization group.
dta-cfg-dir
~/.desktopaid
.
dta-default-cfg
desktopaid.conf
.
dta-default-auto
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
nil
then
all elements will be saved. Its default value is 10.For our Un*x friends: desktopaid-1.0.5.tar.gz
For our Windows friends: desktopaid-1.0.5.zip
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 anddesktop.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.) |
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
airborne @ SF | Last modified: Sun Apr 7 20:11:51 CEST 2002 |