summaryrefslogtreecommitdiff
path: root/src/terminal.c
diff options
context:
space:
mode:
authorStefan Monnier <monnier@iro.umontreal.ca>2008-03-29 01:46:10 +0000
committerStefan Monnier <monnier@iro.umontreal.ca>2008-03-29 01:46:10 +0000
commit58555d8187f3425f69e57316cfcd296f8fe08433 (patch)
tree6483ae1ed8053ad2f3ec7c41241a2e7ab443a5f1 /src/terminal.c
parent769087cead629d7ad1fd5cfc15ce75625a78e6b3 (diff)
downloademacs-58555d8187f3425f69e57316cfcd296f8fe08433.tar.gz
* keyboard.c (pending_funcalls): New var.
(timer_check): Run it. (syms_of_keyboard): Initialize it. * terminal.c (Qrun_hook_with_args, Qdelete_terminal_functions) (Vdelete_terminal_functions): New vars. (syms_of_terminal): Initialize them. (Fdelete_terminal): Run delete-terminal-functions. * xdisp.c (safe_eval): Rewrite. (safe_call2): New fun. * frame.c (Qdelete_frame_functions): New var. (syms_of_frame): Initialize it. (Fdelete_frame): Use it and use safe_call2 and pending_funcalls. * lisp.h (safe_call2, pending_funcalls): Declare.
Diffstat (limited to 'src/terminal.c')
-rw-r--r--src/terminal.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/terminal.c b/src/terminal.c
index bbc2fd74c2e..6a7cd37929c 100644
--- a/src/terminal.c
+++ b/src/terminal.c
@@ -295,6 +295,10 @@ delete_terminal (struct terminal *terminal)
#endif
}
+Lisp_Object Qrun_hook_with_args;
+static Lisp_Object Qdelete_terminal_functions;
+static Lisp_Object Vdelete_terminal_functions;
+
DEFUN ("delete-terminal", Fdelete_terminal, Sdelete_terminal, 0, 2, 0,
doc: /* Delete TERMINAL by deleting all frames on it and closing the terminal.
TERMINAL may be a terminal id, a frame, or nil (meaning the selected
@@ -320,6 +324,16 @@ but if the second argument FORCE is non-nil, you may do so. */)
error ("Attempt to delete the sole active display terminal");
}
+ if (NILP (Vrun_hooks))
+ ;
+ else if (EQ (force, Qnoelisp))
+ pending_funcalls
+ = Fcons (list3 (Qrun_hook_with_args,
+ Qdelete_terminal_functions, terminal),
+ pending_funcalls);
+ else
+ safe_call2 (Qrun_hook_with_args, Qdelete_terminal_functions, terminal);
+
if (t->delete_terminal_hook)
(*t->delete_terminal_hook) (t);
else
@@ -552,6 +566,17 @@ syms_of_terminal ()
The function should accept no arguments. */);
Vring_bell_function = Qnil;
+ DEFVAR_LISP ("delete-terminal-functions", &Vdelete_terminal_functions,
+ doc: /* Special hook run when a terminal is deleted.
+Each function is called with argument, the terminal.
+This may be called just before actually deleting the terminal,
+or some time later. */);
+ Vdelete_terminal_functions = Qnil;
+ Qdelete_terminal_functions = intern ("delete-terminal-functions");
+ staticpro (&Qdelete_terminal_functions);
+ Qrun_hook_with_args = intern ("run-hook-with-args");
+ staticpro (&Qrun_hook_with_args);
+
defsubr (&Sdelete_terminal);
defsubr (&Sframe_terminal);
defsubr (&Sterminal_live_p);