wdkrnls
wdkrnls

Reputation: 4692

Open 'undo-tree-visualize side by side to the buffer, and not "vertically"

Is there any way I can make undo-tree-mode display the visualization in a "horizontal" buffer (ie. C-x 3 vs. C-x 2)?

What I want](![enter image description here

Upvotes: 3

Views: 1079

Answers (2)

meqif
meqif

Reputation: 131

As per @Tom's suggestion, I whipped up a solution that applies only to undo-tree:

(defadvice undo-tree-visualize (around undo-tree-split-side-by-side activate)
  "Split undo-tree side-by-side"
  (let ((split-height-threshold nil)
        (split-width-threshold 0))
  ad-do-it))

2017-04-29: defadvice is now deprecated in favour of advice-add. The updated version of the solution above would be the following:

(defun undo-tree-split-side-by-side (original-function &rest args)
  "Split undo-tree side-by-side"
  (let ((split-height-threshold nil)
        (split-width-threshold 0))
    (apply original-function args)))

(advice-add 'undo-tree-visualize :around #'undo-tree-split-side-by-side)

Upvotes: 7

Aaron
Aaron

Reputation: 816

The undo-tree package uses standard Emacs buffer display functions to show the tree window (as opposed to a specific function). To control how Emacs splits windows, you can customize the variables split-window-preferred-function, split-height-threshold, and split-width-threshold. Also check out the documentation for the function split-window-sensibly.

If you are OK with Emacs in general preferring side-by-side windows over top-and-bottom ones, put this code in your init file:

(setq split-height-threshold 0)

(If you want side-by-side windows only for undo-tree-visualize, the story is a little more complicated.)

Upvotes: 1

Related Questions