[Top][All Lists]
[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: |
21 Feb 2002 22:18:12 +0100 |
User-agent: |
Gnus/5.09 (Gnus v5.9.0) Emacs/21.2.50 |
"Jan D." <address@hidden> 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 <address@hidden> http://www.cua.dk
- Session management patch, please comment., Jan D., 2002/02/17
- Re: Session management patch, please comment., Richard Stallman, 2002/02/19
- Re: Session management patch, please comment., Kim F. Storm, 2002/02/19
- Re: Session management patch, please comment., Jan D., 2002/02/19
- Re: Session management patch, please comment., Kim F. Storm, 2002/02/19
- Re: Session management patch, please comment., Jan Djärv, 2002/02/20
- Re: Session management patch, please comment., Kim F. Storm, 2002/02/20
- Re: Session management patch, please comment., Jan D., 2002/02/21
- Re: Session management patch, please comment.,
Kim F. Storm <=
- New session management patch., Jan D., 2002/02/26
- Re: New session management patch., Richard Stallman, 2002/02/27
- Re: New session management patch., Eli Zaretskii, 2002/02/27
- Re: New session management patch., Andreas Schwab, 2002/02/27
- Re: New session management patch., Colin Walters, 2002/02/27
- Re: New session management patch., Richard Stallman, 2002/02/27
- Re: New session management patch., Jan D., 2002/02/27
- Re: New session management patch., Richard Stallman, 2002/02/28
- Re: New session management patch., Kim F. Storm, 2002/02/28
- Re: New session management patch., Richard Stallman, 2002/02/28