From mboxrd@z Thu Jan 1 00:00:00 1970 Path: quimby.gnus.org!not-for-mail From: storm@cua.dk (Kim F. Storm) Newsgroups: gmane.emacs.devel Subject: Re: Session management patch, please comment. Date: 21 Feb 2002 22:18:12 +0100 Message-ID: <5x1yfe5yaz.fsf@kfs2.cua.dk> References: <200202211957.UAA00205@gaffa.gaia.swipnet.se> NNTP-Posting-Host: quimby2.netfonds.no Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: quimby2.netfonds.no 1014326381 29352 195.204.10.66 (21 Feb 2002 21:19:41 GMT) X-Complaints-To: usenet@quimby2.netfonds.no NNTP-Posting-Date: 21 Feb 2002 21:19: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 16e0cu-0007dK-00 for ; Thu, 21 Feb 2002 22:19:41 +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 16e0bW-00078C-00; Thu, 21 Feb 2002 16:18:14 -0500 Original-Received: from mail.filanet.dk ([195.215.206.179]) by fencepost.gnu.org with smtp (Exim 3.33 #1 (Debian)) id 16e0aZ-00076l-00 for ; Thu, 21 Feb 2002 16:17:15 -0500 Original-Received: from kfs2.cua.dk.cua.dk (unknown [10.1.82.3]) by mail.filanet.dk (Postfix) with SMTP id 386367C035; Thu, 21 Feb 2002 21:17:05 +0000 (GMT) Original-To: "Jan D." In-Reply-To: <200202211957.UAA00205@gaffa.gaia.swipnet.se> Original-Lines: 71 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2.50 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:1402 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:1402 "Jan D." writes: > > 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. Yes, that would be a possibility, but in lisp you (and others) have much more freedom to tune the behaviour, such as defining the cancel-shutdown variable, store everything in one file, etc. I think the general philosophy is to have the basic functionality in C and as much flexibility in lisp. E.g. you can define the save function in lisp like this (defun save-myself-function (prev-session-id cur-session-id) (let ((cancel-shutdown nil) (filename (concat .... session-id)) (buf (get-buffer-create (concat "*SES " cur-session-id)))) (with-current-buffer buf ;; save hooks should use `insert' to add to the save file (run-hook save-session-hook) (unless cancel-shutdown (write-file filename))) (kill-buffer buf) cancel-shutdown)) Another problem is how to restore things after restarting emacs. I don't think you can rely on a hook to do this. Some things may not have been added to the restore-hook when you run it (e.g. if gnus stores its state in a file, there need to be a gnus-restore-session function in the hook list for this to work.) One possible fix would be to let the save-hook functions insert lisp code in the session save file which - when emacs restarts - is eval'ed to restore the previous state. You should make a default choice of how the session file is named based on the session-id (define a function emacs-session-save-filename in x-win.el which the user can rewrite), and then -- at the place where you now do (if (and (stringp x-sm-previous-id) (stringp x-sm-id)) (run-hook-with-args 'restart-yourself-hook x-sm-previous-id x-sm-id))) you should simply insert a call to a function: (if (and (stringp x-sm-previous-id) (stringp x-sm-id) (fboundp 'emacs-session-restore-session)) (emacs-session-restore-session x-sm-previous-id x-sm-id)) This function is defined in x-win.el along with your other lisp code and does something like this: (let ((filename (emacs-session-save-filename x-sm-previous-id)) (when (file-exists-p filename) (load-file filename) (delete-file filename) (message "Restored session data"))) Maybe you should look at desktop.el to see how it does things? (I don't know whether it is relevant, though). -- Kim F. Storm http://www.cua.dk _______________________________________________ Emacs-devel mailing list Emacs-devel@gnu.org http://mail.gnu.org/mailman/listinfo/emacs-devel