unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: "Jan D." <Jan.Djarv@mbox200.swipnet.se>
Cc: emacs-devel@gnu.org
Subject: Re: Session management patch, please comment.
Date: Thu, 21 Feb 2002 20:57:35 +0100 (CET)	[thread overview]
Message-ID: <200202211957.UAA00205@gaffa.gaia.swipnet.se> (raw)
In-Reply-To: <5xit8rwywv.fsf@kfs2.cua.dk> "from Kim F. Storm at Feb 20, 2002 11:50:40 pm"

> Jan Djärv <Jan.Djarv@mbox200.swipnet.se> 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.

Okay.

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


_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/emacs-devel


  reply	other threads:[~2002-02-21 19:57 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-02-17 19:11 Session management patch, please comment Jan D.
2002-02-19  6:37 ` Richard Stallman
2002-02-19  8:40   ` Kim F. Storm
2002-02-19 20:13     ` Jan D.
2002-02-19 20:12   ` Jan D.
2002-02-19 22:43     ` Kim F. Storm
2002-02-20 20:29       ` Jan Djärv
2002-02-20 22:50         ` Kim F. Storm
2002-02-21 19:57           ` Jan D. [this message]
2002-02-21 21:18             ` Kim F. Storm
2002-02-26 22:49               ` New session management patch Jan D.
2002-02-27  5:51                 ` Richard Stallman
2002-02-27 10:23                   ` Eli Zaretskii
2002-02-27 15:25                     ` Andreas Schwab
2002-02-27 18:11                     ` Colin Walters
2002-02-28  4:08                     ` Richard Stallman
2002-02-27 19:43                   ` Jan D.
2002-02-28 18:22                     ` Richard Stallman
2002-02-28 15:36                   ` Kim F. Storm
2002-03-01  1:11                     ` Richard Stallman
2002-02-22  4:32           ` Session management patch, please comment Richard Stallman
2002-02-20 22:13     ` Richard Stallman
2002-02-21 20:01       ` Jan D.

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200202211957.UAA00205@gaffa.gaia.swipnet.se \
    --to=jan.djarv@mbox200.swipnet.se \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).