# HG changeset patch # User Karoly Lorentey # Date 1120614116 0 # Node ID 60208d3a0bb1b913513d2bf18b9b6f637e7482ea # Parent 6afa124501e69a80b15856b75849eebb6300034e Handle and document that `delete-frame' may call functions in `delete-frame-functions' twice. * src/frame.c (syms_of_frame): Add warning to `delete-frame-functions' description. * lisp/frame.el (terminal-handle-delete-frame): Check that the frame is alive. * lisp/server.el (server-handle-delete-frame): Ditto. Remove bogus comment. git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-375 diff -r 6afa124501e6 -r 60208d3a0bb1 lisp/frame.el --- a/lisp/frame.el Wed Jul 06 00:42:58 2005 +0000 +++ b/lisp/frame.el Wed Jul 06 01:41:56 2005 +0000 @@ -1484,7 +1484,8 @@ ;; XXX We assume that the display is closed immediately after the ;; last frame is deleted on it. It would be better to create a hook ;; called `delete-display-functions', and use it instead. - (when (= 1 (length (frames-on-display-list (frame-display frame)))) + (when (and (frame-live-p frame) + (= 1 (length (frames-on-display-list (frame-display frame))))) (setq terminal-parameter-alist (assq-delete-all (frame-display frame) terminal-parameter-alist)))) diff -r 6afa124501e6 -r 60208d3a0bb1 lisp/server.el --- a/lisp/server.el Wed Jul 06 00:42:58 2005 +0000 +++ b/lisp/server.el Wed Jul 06 01:41:56 2005 +0000 @@ -314,7 +314,8 @@ (defun server-handle-delete-frame (frame) "Delete the client connection when the emacsclient frame is deleted." (let ((proc (frame-parameter frame 'client))) - (when (and proc + (when (and (frame-live-p frame) + proc (or (window-system frame) ;; A terminal display must not yet be deleted if ;; there are other frames on it. @@ -326,10 +327,6 @@ (frame-list)) frame-num)))) (server-log (format "server-handle-delete-frame, frame %s" frame) proc) - ;; XXX Deleting the process causes emacsclient to exit - ;; immediately, which might happen before Emacs closes the - ;; display. I think we need a `delete-frame-after-functions' - ;; hook here. (server-delete-client proc 'noframe)))) ; Let delete-frame delete the frame later. (defun server-handle-suspend-tty (display) diff -r 6afa124501e6 -r 60208d3a0bb1 src/frame.c --- a/src/frame.c Wed Jul 06 00:42:58 2005 +0000 +++ b/src/frame.c Wed Jul 06 01:41:56 2005 +0000 @@ -4326,7 +4326,14 @@ DEFVAR_LISP ("delete-frame-functions", &Vdelete_frame_functions, doc: /* Functions to be run before deleting a frame. The functions are run with one arg, the frame to be deleted. -See `delete-frame'. */); +See `delete-frame'. + +Note that functions in this list may be called twice on the same +frame. In the second invocation, the frame is already deleted, and +the function should do nothing. (You can use `frame-live-p' to check +for this.) This wrinkle happens when an earlier function in +`delete-frame-functions' (indirectly) calls delete-frame +recursively. */); Vdelete_frame_functions = Qnil; DEFVAR_KBOARD ("default-minibuffer-frame", Vdefault_minibuffer_frame,