Sometimes when moving windows around in emacs, it will get to a state where there is a horizontal or vertical stack of windows which appears to be a single list, but is actually made up of multiple nested window lists.

For example, what appears on the screen is a single horizontal line of windows:
but what is stored in emacs is
(A (B C) D)

Is there a function that will remove this unnecessary nesting? I couldn't figure out any good way to do it.

1 Answer 1


I would use -flatten from the dash library.

  • Unfortunately, this doesn't seem to work as it combines horizontal and vertical stacks together. Even if it did, it returns the tree instead of setting it, and I don't know that there's a way to directly set the window tree.
    – Prismavoid
    Aug 11, 2021 at 3:01
  • @Prismavoid: set-window-configuration.
    – phils
    May 1, 2023 at 4:44

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.