From: storm@cua.dk (Kim F. Storm)
Cc: emacs-devel@gnu.org
Subject: Re: Session management patch, please comment.
Date: 19 Feb 2002 23:43:26 +0100 [thread overview]
Message-ID: <5xk7t9cctt.fsf@kfs2.cua.dk> (raw)
In-Reply-To: <3C72B1AF.6090202@mbox200.swipnet.se>
"Jan D." <Jan.Djarv@mbox200.swipnet.se> writes:
> > + DEFUN ("x-sm-interact-done", Fx_sm_interact_done,
>
> Emacs is executing C code when this happens. To get into lisp code, a
> save-yourself-event is generated and the lisp function bound to the
> event executes (handle-save-yourself).
>
> handle-save-yourself then executes functions in the save-yourself-hook
> and by calling x-sm-interact-done it finally informs the C code that
> it shall send the interaction-done message to the session manager.
>
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).
The save-session-state function runs the save-session-state-hook hooks.
The return value from save-session-state is nil or t - corresponding
to the CANCEL argument of your x-sm-interact-done function.
I.e. instead of explicitly calling x-sm-interact-done, the return value
from the function bound to emacs-session-save-function indicates whether
it succeeded or not. So you wont need x-sm-interact-done.
Similarly, there should be a C level emacs-session-restore-function variable.
This is called with the previous and current session id as arguments.
It runs the restore-session-state-hook hooks.
> > + doc: /* The previous session id Emacs got from session manager.
> > + This is nil if Emacs was not started by the session manager.
> > + The value of this variable and `x-sm-id' may be the same, depending on how
> > + the session manager works.
> > + See also `x-sm-id'.*/);
> > This doc string should explain what the previous session id is good
> > for. What does it mean? Documentation for data should explain its
> > overall meaning, not just what it looks like and what values are found
> > when.
Does these really need to be a C-level lisp variables?
Isn't it enough that the previous session id is passed as an argument
to the emacs-session-restore-function and the current session id is an
argument to emacs-session-save-function?
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 necessary, the restore-session-state function could store it in a
lisp variable for the hooks to access -- or you can rely on the
dynamic binding of the argument to restore-session-state, e.g.
(defun save-session-state (session-id) ;; current session-id
...)
(defun restore-session-state (session-id) ;; previous session-id
...)
> > + DEFVAR_LISP ("x-sm-cancel-shutdown", &Vx_sm_cancel_shutdown,
With the suggested solution above, this variable could also be declared in lisp
(actually it could be dynamically bound in the save-session-state function):
(defun save-session-state (session-id)
(let ((cancel-session-shutdown nil))
(run-hooks 'save-session-state-hook)
cancel-session-shutdown))
--
Kim F. Storm <storm@cua.dk> http://www.cua.dk
_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/emacs-devel
next prev parent reply other threads:[~2002-02-19 22:43 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 [this message]
2002-02-20 20:29 ` Jan Djärv
2002-02-20 22:50 ` Kim F. Storm
2002-02-21 19:57 ` Jan D.
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5xk7t9cctt.fsf@kfs2.cua.dk \
--to=storm@cua.dk \
--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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.