;;; -*- lexical-binding: t -*- ;; ;; this file: ;; https://dataswamp.org/~incal/emacs-init/window-incal.el (require 'cl-lib) (require 'window) (require 'window-other) (defun window-chars (&optional win) (let* ((edges (window-inside-edges win)) (beg (nth 0 edges)) (end (nth 2 edges))) (- end beg 1))) (defun window-lines (&optional win) (let* ((edges (window-inside-edges win)) (top (nth 1 edges)) (bottom (nth 3 edges))) (- bottom top))) (setq display-buffer-base-action '((display-buffer-reuse-window display-buffer-same-window) )) (defun beginning-of-line-at-top () (beginning-of-line) (recenter 0) ) (defun other-window-or-split () (interactive) (when (one-window-p) (split-window-below) ) (other-window 1) ) (defun swap-windows () (interactive) (let ((buf (current-buffer))) (other-window 1) (switch-to-buffer-other-window (current-buffer)) (other-window 1) (switch-to-buffer buf) )) (defun window-increase-size (&optional lines) (interactive "p") (or lines (setq lines 1)) (unless (one-window-p) (window-resize nil lines) )) (defun window-decrease-size (&optional lines) (interactive "p") (or lines (setq lines 1)) (unless (one-window-p) (window-resize nil (* -1 lines)) )) (provide 'window-incal)