From: Stefan Bund Date: Tue, 25 Apr 2017 16:08:10 +0000 (+0200) Subject: optional prefix argument for setup-my-windows (C-x 9) X-Git-Url: http://g0dil.de/git?p=emacs-init.git;a=commitdiff_plain;h=034fc1ee1b172aec924628567d0f484084f08d55 optional prefix argument for setup-my-windows (C-x 9) --- diff --git a/setup/mywin.el b/setup/mywin.el index 1887b52..6eda23b 100644 --- a/setup/mywin.el +++ b/setup/mywin.el @@ -59,12 +59,19 @@ window smaller than MIN-HEIGHT lines." (defconst setup-my-windows-junk-buffers '("*scratch*" "*Messages*" "*Calculator" "*Calc Trail*" "*compilation*" "*fetchmail*")) -(defun setup-my-windows () - (interactive) - (let ((width 100) (min 100) (distribute t) - (currentbuffer (current-buffer)) - (currentwindow (selected-window)) - topwindows firstwindow newwindow newtopwindows) +(defvar my-windows-count nil) + +(defun setup-my-windows (&optional n) + (interactive "P") + (if n + (if (integerp n) + (setq my-windows-count n) + (setq my-windows-count nil))) + (let* ((width (if my-windows-count (- (/ (frame-width) my-windows-count) 4) 100)) + (min width) (distribute t) + (currentbuffer (current-buffer)) + (currentwindow (selected-window)) + topwindows firstwindow newwindow newtopwindows) (walk-windows (function (lambda (w) (let ((e (window-edges w))) (if (< (nth 1 e) window-min-height) @@ -207,4 +214,4 @@ the buffer stack in the current window." (shrink-window-horizontally (- (- width (window-width) (* window-min-width (1- count))))))) (global-set-key "\C-x=" 'safe-max-window-horizontally) -(global-set-key "\C-x-" 'maximize-window-15) \ No newline at end of file +(global-set-key "\C-x-" 'maximize-window-15)