[Top][All Lists]

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

Re: Session management patch, please comment.

From: Jan D.
Subject: Re: Session management patch, please comment.
Date: Thu, 21 Feb 2002 20:57:35 +0100 (CET)

> 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.

Right, now I see.  I didn't think about that.  Good idea.
But if handle-save-yourself is in C, it should be able to call the save
session hooks by itself, and then do what x-sm-interact-done does, could
it not?  That way, less code (marginal) and more straight forward logic
is achived.

I'll send an updated patch shortly.

> > >
> > > 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.  

I just wanted to make all info available.  I haven't looked at other
implementations so I really don't know what the convention is.

        Jan D.

reply via email to

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