;;; kkk-windowsize.el --- Window Size -*- lexical-binding: t; -*- ;; Copyright (C) 2023 Vinicius Teshima ;; Author: Vinicius Teshima ;; This program is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by ;; the Free Software Foundation, either version 3 of the License, or ;; (at your option) any later version. ;; This program is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; GNU General Public License for more details. ;; You should have received a copy of the GNU General Public License ;; along with this program. If not, see . ;;; Commentary: ;; Window Size ;;; Code: (defgroup kkk-window nil "Group for the window group." :group 'info) (defcustom kkk-window-size 80 "Size of window." :type 'natnum :group 'kkk-window) (defun kkk-window-resize (&optional ignored) "This function change the size of the current window to 80 char wide. IGNORED is there to be complient with the 'window-state-change-functions' docs." (interactive) (let ((win (selected-window))) (unless (or (frame-root-window-p win) (minibufferp (current-buffer))) (let* ((width (window-text-width)) (delta (+ 6 (- kkk-window-size width)))) (if (> delta 0) (enlarge-window-horizontally delta) (shrink-window-horizontally (* delta -1)) ) ) ) ) ) (add-to-list 'window-state-change-functions #'kkk-window-resize) (provide 'kkk-windowsize) ;;; kkk-windowsize.el ends here