+ (winner-mode 1)
+#+END_SRC
+** Eyebrowse
+
+#+BEGIN_SRC emacs-lisp
+ ;; (use-package eyebrowse
+ ;; :ensure t
+ ;; :diminish eyebrowse-mode
+ ;; :init (setq eyebrowse-keymap-prefix (kbd "C-c C-\\"))
+ ;; :config (progn
+ ;; (setq eyebrowse-wrap-around t)
+ ;; (eyebrowse-mode t)
+ ;;
+ ;; (defun my/eyebrowse-new-window-config ()
+ ;; (interactive)
+ ;; (let ((done nil))
+ ;; (dotimes (i 10)
+ ;; ;; start at 1 run till 0
+ ;; (let ((j (mod (+ i 1) 10)))
+ ;; (when (and (not done)
+ ;; (not (eyebrowse--window-config-present-p j)))
+ ;; (eyebrowse-switch-to-window-config j)
+ ;; (call-interactively 'eyebrowse-rename-window-config2 j)
+ ;; (setq done t)
+ ;; ))
+ ;; )))
+ ;;
+ ;; ;; I don't use latex-preview-pane
+ ;; ;; (require 'latex-preview-pane)
+ ;; ;; (defun my/close-latex-preview-pane-before-eyebrowse-switch ()
+ ;; ;; ;; latex-preview-pane uses window-parameters which are
+ ;; ;; ;; not preserved by eyebrowse, so we close the preview
+ ;; ;; ;; pane before switching, it will be regenerated when we
+ ;; ;; ;; edit the TeX file.
+ ;; ;; (when (lpp/window-containing-preview)
+ ;; ;; (delete-window (lpp/window-containing-preview))))
+ ;;
+ ;; ;; (add-to-list 'eyebrowse-pre-window-switch-hook
+ ;; ;; #'my/close-latex-preview-pane-before-eyebrowse-switch)
+ ;;
+ ;; ;; (my/set-menu-key "[" #'my/eyebrowse-new-window-config)
+ ;; ;; (my/set-menu-key ";" #'eyebrowse-prev-window-config)
+ ;; ;; (my/set-menu-key "'" #'eyebrowse-next-window-config)
+ ;; ;; (my/set-menu-key "]" #'eyebrowse-close-window-config)
+ ;; ;; (my/set-menu-key "\\" #'eyebrowse-rename-window-config)
+ ;; )
+ ;; )
+#+END_SRC
+
+** Window handling
+
+*** Splitting
+#+BEGIN_SRC emacs-lisp
+ (defun my/vsplit-last-buffer ()
+ "Split the window vertically and display the previous buffer."
+ (interactive)
+ (split-window-vertically)
+ (other-window 1 nil)
+ (switch-to-next-buffer))
+
+ (defun my/hsplit-last-buffer ()
+ "Split the window horizontally and display the previous buffer."
+ (interactive)
+ (split-window-horizontally)
+ (other-window 1 nil)
+ (switch-to-next-buffer))
+
+ (bind-key "C-x 2" 'my/vsplit-last-buffer)
+ (bind-key "C-x 3" 'my/hsplit-last-buffer)
+
+ (setq split-width-threshold 100)
+ (setq split-height-threshold 60)
+
+ (defun my/split-window-prefer-horizontally (window)
+ "If there's only one window (excluding any possibly active
+ minibuffer), then split the current window horizontally."
+ (if (and (one-window-p t)
+ (not (active-minibuffer-window))
+ ( > (frame-width) (frame-height))
+ )
+ (let ((split-height-threshold nil))
+ (split-window-sensibly window))
+ (split-window-sensibly window)))
+
+ (setq split-window-preferred-function #'my/split-window-prefer-horizontally)
+ (setq window-combination-resize t)
+#+END_SRC
+
+*** Compilation window
+
+If there is no compilation window, open one at the bottom, spanning
+the complete width of the frame. Otherwise, reuse existing window. In
+the former case, if there was no error the window closes
+automatically.
+
+#+BEGIN_SRC emacs-lisp
+ (add-to-list 'display-buffer-alist
+ `(,(rx bos "*compilation*" eos)
+ (display-buffer-reuse-window
+ display-buffer-in-side-window)
+ (reusable-frames . visible)
+ (side . bottom)
+ (window-height . 0.4)))