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)?
2 Answers
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)
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.)
-
3If it is needed only for undo tree then the variable can be set temporarily in an advice wrapped around the undo-tree-visualize function.– TomAug 29, 2011 at 5:59
-
@Tom I would give you an upvote if you write the code snippet for that advice in an answer ;) Mar 19, 2013 at 16:33
-
1@DanielDinnyes I know it's a year and a half later, but you can check my answer for that code snippet. :)– meqifAug 10, 2014 at 12:09