emacs-devel
[Top][All Lists]
Advanced

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

Re: Session management patch, please comment.


From: Kim F. Storm
Subject: Re: Session management patch, please comment.
Date: 20 Feb 2002 23:50:40 +0100
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2.50

Jan Djärv <address@hidden> writes:

> > What about this approach:
> >
> > In C, you declare a hook variable emacs-session-save-function.
> >
> > In Lisp, you bind a save-session-state function to this variable.
> >
> > When the save_yourself event arrives, the function bound to
> > emacs-session-save-function is called (with whatever arguments you
> > think it needs).
> 
> I don't quite understand.  What purpose does the
> emacs-session-save-function serve, why not call a lisp function
> directly?  And if one can call lisp functions, why not call the
> functions in save-session-state-hook from C?

I believe the normal approach when calling lisp functions from C is to
run a hook, i.e. call the function(s) bound to a variable defined in C.

By doing that, you don't require lisp functions to have a specific
name (or being defined), and it uses a well-defined method to invoke a
lisp function from C.

> 
> The reason I did it the way presented, is was I think you can't call
> lisp functions from the X event input handler.  Thus an Emacs event is
> used to get control to the lisp part.

Using `special-event-map' as you do is the right approach (I think).
The only thing I suggest to change is to define the handle-save-yourself
function in C.

It should call the function bound to the variable `emacs-session-save-function'
(that function is written in lisp and runs the save session hooks), and
depending on whether that function returns nil or t, it will execute the
relevant parts of the code currently located in x-sm-interact-done.

That way, you don't need the x-sm-interact-done callback from lisp to C.

> >
> > In general, I would suspect that you only need to know either the
> > previous session id (when doing restore), or the current session id
> > (when doing save).
> 
> If you have saved state in a file with a filename based on the previous id,
>   you presumably would want remove or move that file, either when
>   doing restore or save session.

Ok, but if that is necessary, you can save the `session-id' parameter
(of the restore function) in a variable defined in lisp - to be used
later by the save function.

However, I would expect the restore function to remove that file. 
But again, that would be decided in lisp rather than the core emacs
functions.  

++kfs




reply via email to

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