bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#9873: 24.0.90; dired - window changes size when trying to delete mor


From: Juri Linkov
Subject: bug#9873: 24.0.90; dired - window changes size when trying to delete more than one file
Date: Mon, 31 Oct 2011 12:11:18 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.90 (x86_64-pc-linux-gnu)

>> Are we waiting for a conclusion whether to set `window-nest' to t by default
>> or to bind it individually where necessary?
>
> Setting it to t by default and _not_ binding it individually will have
> detrimental consequences for people who don't want it always t.  Juanma
> wants it always t because he wants to control the layout of his windows.
> I'm more sloppy in this respect.  Hence if we choose to handle this via
> `window-nest' we should bind that individually.
>
>> Are there other options?
>
> You could try writing a suitable buffer display function ;-)

Below is a new buffer display function created from `dired-pop-to-buffer'
that can be used in all packages that need this functionality like
Dired and Proced (more could be fixed later if this is the right approach):

=== modified file 'lisp/window.el'
--- lisp/window.el      2011-10-30 08:29:56 +0000
+++ lisp/window.el      2011-10-31 10:05:16 +0000
@@ -4851,6 +4851,24 @@ (defun display-buffer-pop-up-window (buf
       (set-window-prev-buffers window nil)
       window)))
 
+(defun display-buffer-pop-up-window-below (buffer alist)
+  "Display BUFFER by popping up a new window below the selected window."
+  (let (
+       ;; Stay within the confines of the initial window.
+       ;; Don't resize other windows.  (Bug#1806 Bug#9873)
+       (window-nest t)
+       (split-window-preferred-function
+        (lambda (window)
+          (or (and (let ((split-height-threshold 0))
+                     (window-splittable-p (selected-window)))
+                   ;; Try to split the selected window vertically if
+                   ;; that's possible.  (Bug#1806)
+                   (split-window-below))
+              ;; Otherwise, try to split WINDOW sensibly.
+              (split-window-sensibly window))))
+       pop-up-frames)
+    (display-buffer-pop-up-window buffer alist)))
+
 (defun display-buffer--maybe-pop-up-frame-or-window (buffer alist)
   "Try displaying BUFFER based on `pop-up-frames' or `pop-up-windows'.
 
=== modified file 'lisp/dired.el'
--- lisp/dired.el       2011-10-30 01:56:03 +0000
+++ lisp/dired.el       2011-10-31 10:06:19 +0000
@@ -2873,17 +2873,7 @@ (defun dired-mark-prompt (arg files)
 
 (defun dired-pop-to-buffer (buf)
   "Pop up buffer BUF in a way suitable for Dired."
-  (let ((split-window-preferred-function
-        (lambda (window)
-          (or (and (let ((split-height-threshold 0))
-                     (window-splittable-p (selected-window)))
-                   ;; Try to split the selected window vertically if
-                   ;; that's possible.  (Bug#1806)
-                   (split-window-below))
-              ;; Otherwise, try to split WINDOW sensibly.
-              (split-window-sensibly window))))
-       pop-up-frames)
-    (pop-to-buffer (get-buffer-create buf)))
+  (pop-to-buffer (get-buffer-create buf) '(display-buffer-pop-up-window-below))
   ;; If dired-shrink-to-fit is t, make its window fit its contents.
   (when dired-shrink-to-fit
     ;; Try to not delete window when we want to display less than

=== modified file 'lisp/proced.el'
--- lisp/proced.el      2011-08-24 18:09:18 +0000
+++ lisp/proced.el      2011-10-31 10:07:56 +0000
@@ -1730,8 +1730,7 @@ (defun proced-send-signal (&optional sig
           (save-window-excursion
             ;; Analogous to `dired-pop-to-buffer'
             ;; Don't split window horizontally.  (Bug#1806)
-            (let (split-width-threshold)
-              (pop-to-buffer (current-buffer)))
+            (pop-to-buffer (current-buffer) 
'(display-buffer-pop-up-window-below))
             (fit-window-to-buffer (get-buffer-window) nil 1)
             (let* ((completion-ignore-case t)
                    (pnum (if (= 1 (length process-alist))





reply via email to

[Prev in Thread] Current Thread [Next in Thread]