From mboxrd@z Thu Jan 1 00:00:00 1970 Path: quimby.gnus.org!not-for-mail From: "Jan D." Newsgroups: gmane.emacs.devel Subject: Re: Session management patch, please comment. Date: Thu, 21 Feb 2002 20:57:35 +0100 (CET) Message-ID: <200202211957.UAA00205@gaffa.gaia.swipnet.se> NNTP-Posting-Host: quimby2.netfonds.no Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: quimby2.netfonds.no 1014321881 26033 195.204.10.66 (21 Feb 2002 20:04:41 GMT) X-Complaints-To: usenet@quimby2.netfonds.no NNTP-Posting-Date: 21 Feb 2002 20:04:41 GMT Cc: emacs-devel@gnu.org Original-Received: from fencepost.gnu.org ([199.232.76.164]) by quimby2.netfonds.no with esmtp (Exim 3.12 #1 (Debian)) id 16dzSK-0006ln-00 for ; Thu, 21 Feb 2002 21:04:40 +0100 Original-Received: from localhost ([127.0.0.1] helo=fencepost.gnu.org) by fencepost.gnu.org with esmtp (Exim 3.33 #1 (Debian)) id 16dzQu-0001RD-00; Thu, 21 Feb 2002 15:03:12 -0500 Original-Received: from aurora.natverket.com ([195.196.30.60]) by fencepost.gnu.org with esmtp (Exim 3.33 #1 (Debian)) id 16dzQX-0001QM-00 for ; Thu, 21 Feb 2002 15:02:49 -0500 Original-Received: from gaffa.gaia.swipnet.se (pc35.bodenonline.com [195.196.29.227] (may be forged)) by aurora.natverket.com (8.9.3/8.9.3) with ESMTP id VAA02459; Thu, 21 Feb 2002 21:42:53 +0100 (CET) In-Reply-To: <5xit8rwywv.fsf@kfs2.cua.dk> "from Kim F. Storm at Feb 20, 2002 11:50:40 pm" Original-To: "Kim F. Storm" X-MIME-Autoconverted: from 8bit to quoted-printable by aurora.natverket.com id VAA02459 Errors-To: emacs-devel-admin@gnu.org X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.0.5 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: Emacs development discussions. List-Unsubscribe: , List-Archive: Xref: quimby.gnus.org gmane.emacs.devel:1400 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:1400 > Jan Dj=E4rv writes: >=20 > > > 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). > >=20 > > 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? >=20 > 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. >=20 > 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 i= s > > used to get control to the lisp part. >=20 > 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-yoursel= f > function in C. >=20 > It should call the function bound to the variable `emacs-session-save-f= unction' > (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 th= e > relevant parts of the code currently located in x-sm-interact-done. >=20 > 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. >=20 > > > > > > 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). > >=20 > > If you have saved state in a file with a filename based on the previo= us id, > > you presumably would want remove or move that file, either when > > doing restore or save session. >=20 > 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. >=20 > However, I would expect the restore function to remove that file.=20 > But again, that would be decided in lisp rather than the core emacs > functions. =20 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