Subject: bug#7533: 24.0.50; `dired-mark-pop-up': delete frame afterwards if `pop-up-frames'

From: martin rudalics <[email-masked]>
Date: Fri, 06 Apr 2012 16:02:42 +0200

> emacs -Q
 >
 > (setq special-display-regexps '("[ ]?[*][^*]+[*]"))
 > (setq pop-up-frame t)

I suppose you mean

(setq pop-up-frames t)

but apparently this variable is no more supported by `display-buffer'
(I'm not sure whether that's by design).

 > C-x d whatever-dir
 >
 > Mark 4 files for deletion.  Hit `x'.  Answer `yes'.
 >
 > The *Deletions* frame remains displayed.

Would the attached patch fix it?

This is NOT a generic fix - it might fail miserably if the buffer in
question is shown in two windows simultaneously.  Apparently this is no
great issue in the case at hand since `dired-pop-to-buffer' already
calls `get-buffer-window'.  I earlier provided a variable called
`display-buffer-window' for this and related issues but Stefan didn't
like it.

martin
bzr diff
=== modified file 'lisp/dired.el'
--- lisp/dired.el	2012-04-01 02:44:24 +0000
+++ lisp/dired.el	2012-04-06 13:35:09 +0000
@@ -2950,8 +2950,7 @@
 		    ;; that's possible.  (Bug#1806)
 		    (split-window-below))
 	       ;; Otherwise, try to split WINDOW sensibly.
-	       (split-window-sensibly window))))
-	pop-up-frames)
+	       (split-window-sensibly window)))))
     (pop-to-buffer (get-buffer-create buf)))
   ;; If dired-shrink-to-fit is t, make its window fit its contents.
   (when dired-shrink-to-fit
@@ -2993,17 +2992,21 @@
 	  ;; If FILES defaulted to the current line's file.
 	  (= (length files) 1))
       (apply function args)
-    (with-current-buffer (get-buffer-create bufname)
-      (erase-buffer)
-      ;; Handle (t FILE) just like (FILE), here.
-      ;; That value is used (only in some cases), to mean
-      ;; just one file that was marked, rather than the current line file.
-      (dired-format-columns-of-files (if (eq (car files) t) (cdr files) files))
-      (remove-text-properties (point-min) (point-max)
-			      '(mouse-face nil help-echo nil)))
-    (save-window-excursion
-      (dired-pop-to-buffer bufname)
-      (apply function args))))
+    (let ((buffer (get-buffer-create bufname)))
+      (with-current-buffer buffer
+	(erase-buffer)
+	;; Handle (t FILE) just like (FILE), here.
+	;; That value is used (only in some cases), to mean
+	;; just one file that was marked, rather than the current line file.
+	(dired-format-columns-of-files (if (eq (car files) t) (cdr files) files))
+	(remove-text-properties (point-min) (point-max)
+				'(mouse-face nil help-echo nil))
+	(dired-pop-to-buffer buffer)
+	(let ((window (get-buffer-window buffer)))
+	  (prog1
+	      (apply function args)
+	    (when (and window (eq (window-buffer window) buffer))
+	      (quit-window nil window))))))))
 
 (defun dired-format-columns-of-files (files)
   (let ((beg (point)))