[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Questions round session management.
Questions round session management.
Thu, 31 Jan 2002 20:54:51 +0100 (CET)
I've been looking at adding session management support to Emacs (the
-lSM library kind). Just getting Emacs to save state and restart
itself is not complicated. However, I have some questions about
how Emacs should behave in this regard. To get things into context,
a brief description about how this kind of session management works
follows, and the questions after.
First one establish a connection to the session manager. This is
a separate connection (separate file descriptor) from any X connection.
When one opens the connection, four callbacks are established, the most
important is save_yourself. You can also supply a previous client id
(see below) if you have one, or NULL if this is the first time
a connection is done.
On successful connection a client id is returned (a string). This
shall be the previous client id when the program is restarted. See
below for how to get the previous id after a restart.
When data arrives on the file descriptor, one calls IceProcessMessages
to handle all data. That function calls the registered callbacks.
When save_yourself is called, it has parameters that tell you if
the session manager is shutting down and if it is allowed to interact
with the user. To make it possible for the session manager to
restart the program, one sets properties (not X properties, but
SM properties) in this callback. The important ones are uid of the
user, and the command line (i.e. argv) that shall be used when restarting
the program. Here one usually adds an option like '--smid=CLIENT_ID'
where CLIENT_ID is the current client id. When restarted, one
checks the argv and if there is an '--smid' option, this
becomes the previous id in the open connection call.
If save_yourself is called and it is allowed to interact with the user
and one wishes to do so, a call to SmcInteractRequest is made. This
function takes another callback as a parameter. This callback is called
when the session manager sends an "Interact OK" message to the program,
thus one needs to wait for more messages on the file descriptor.
When the interact callback is called, one can interact with the user.
After interaction is done, SmcInteractDone is called, and then
SmcSaveYourselfDone to indicate that the program is done.
Now for the questions.
Should Emacs save all buffers when shutting down? That is, a
shutting down from the session manager would be treated the same
as an C-x C-c.
Should Emacs attempt to save state (frame parameters, open files,
and so on) when shutting down? The client id can be used in a filename
that saves state, and then be read back in when restarted. The SM
documetation says "It is expected that the client will save its state in
such a way that the client can be restarted at a later time and
resume its operation as if it had never been terminated."
Some applications tries to do this, others just restart with the
same command line (xterm for example).
If yes, what is the best way to do that? Call a lisp function perhaps
(can one safely do that inside XTread_socket)?
How much state can be saved, do one want the same (or even more) than
what desktop-save saves? Is there any code that saves frame sizes
and positions in a format that can be read back?
Or should we do the simple solution, just restart Emacs with the
same command line, and don't do anything special when shutting down.
- Questions round session management.,
Jan D. <=