Currently I'm using the following display-buffer-alist, which works fine but resets the size on opening a new window.

Is there a way to only use the window-height when first creating the window? After this, any resizing I do should be kept instead of being reset (when viewing another commit in this example).

  "\\`magit-revision: "
  (list 'display-buffer-reuse-window 'display-buffer-below-selected)
  (cons 'window-height    0.8)
  (cons 'reusable-frames 'visible))
  • 3
    I don't know if there is a simple setting, but the display-buffer-alist accepts custom functions that can do whatever the heart desires: (add-to-list 'display-buffer-alist '("REGEXP" . (my-custom-function))) The custom function takes two arguments: BUFFER ALIST.
    – lawlist
    Oct 25, 2021 at 22:01
  • Thanks, I managed to use this to get the desired result (posted in answer).
    – ideasman42
    Oct 26, 2021 at 3:52

1 Answer 1


This can be done by wrapping display-buffer-reuse-window' to filter out the window-height from the alist, so it's only used for other functions (in this case display-buffer-below-selected').

(defun my-display-buffer-reuse-window-without-size (buffer alist)
  "Wrap `display-buffer-reuse-window' ignoring window-height."
  (let *((skip-params (list 'window-height 'window-width 'window-min-height))
          (delete nil (mapcar (lambda (x)
                                (if (and (consp x) (memq (car x) skip-params))
       (display-buffer-reuse-window buffer alist-filter)))

(push (list "\\`magit-revision: "
            (list 'my-display-buffer-reuse-window-without-height
            (cons 'reusable-frames 'visible)
            (cons 'window-height 0.9))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.