;;; -*- lexical-binding: t -*- (require 'cl-lib) (cl-pushnew "." load-path :test #'string=) (require 'luki-lisp) (-> 'window) (setq display-buffer-overriding-action '((display-buffer-full-frame))) (defmacro with-other-window (&rest body) `(with-selected-window (next-window) ,@body)) (defun apply-in-other-window (fn &rest args) (with-other-window (apply fn args))) (defun window-chars (&optional win) (pcase-let ((`(,beg ,_ ,end ,_) (window-inside-edges win))) (- end beg 1))) (defun window-lines (&optional win) (pcase-let ((`(,_ ,top ,_ ,bottom) (window-inside-edges win))) (- bottom top))) (defun window-char-resolution (&optional win silent pref-str) (i) (when win (select-window win)) (let* ((dta (list (window-chars) (window-lines))) (res ($ "%dx%d" (1st dta) (2nd dta)))) (prog1 (if pref-str res dta) (unless silent ($ "res: %s" res))))) (defalias 'res #'window-char-resolution) (defun beginning-of-line-at-top () (goto-char (pos-bol)) (recenter 0)) (defun other-window-or-split () (i) (when (one-window-p) (split-window-below)) (other-window 1)) (defun swap-windows () (i) (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 hori) (interactive "p") (or lines (setq lines 1)) (unless (one-window-p) (window-resize nil lines hori))) (defun window-decrease-size (&optional lines hori) (interactive "p") (or lines (setq lines 1)) (unless (one-window-p) (window-resize nil (* -1 lines) hori))) (<- 'll-window)