Handle and document that `delete-frame' may call functions in `delete-frame-functions...
authorKaroly Lorentey <lorentey@elte.hu>
Wed, 6 Jul 2005 01:41:56 +0000 (01:41 +0000)
committerKaroly Lorentey <lorentey@elte.hu>
Wed, 6 Jul 2005 01:41:56 +0000 (01:41 +0000)
* 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

lisp/frame.el
lisp/server.el
src/frame.c

index 5bb58c5..b034f9a 100644 (file)
@@ -1484,7 +1484,8 @@ selected frame's terminal)."
   ;; 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))))
 
index 91a74d6..dab3cde 100644 (file)
@@ -314,7 +314,8 @@ message."
 (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 @@ message."
                                (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)
index f32ad7a..8ebcbc9 100644 (file)
@@ -4326,7 +4326,14 @@ when the mouse is over clickable text.  */);
   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,