X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=setup%2Fmywin.el;h=6eda23b66fc2dd2d196d930ef0804dd48e55c842;hb=034fc1ee1b172aec924628567d0f484084f08d55;hp=63ab71dff12d624bd5a6ea65dc7e854cceff2c77;hpb=4ef831f9faaf8ca7ee36ca656c0d511be00ae1bc;p=emacs-init.git diff --git a/setup/mywin.el b/setup/mywin.el index 63ab71d..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) @@ -151,28 +158,32 @@ window smaller than MIN-HEIGHT lines." (global-set-key "\C-x7" 'split-window-3-horizontally) (global-set-key "\C-x8" (lambda () (interactive) (split-window-n-horizontally 100 50))) (global-set-key "\C-x9" 'setup-my-windows) -(global-set-key "\C-xp" 'other-window-reverse) (global-set-key "\C-\M-_" (lambda () (interactive) (safe-shrink-window 5))) -(defun my-swap-window-to-right (&optional stay) +(defun my-swap-window-to-right (&optional below) + "If swap buffer in this window with buffer on the right. If BELOW is set, +instead move current buffer to right and replace it with the next buffer from +the buffer stack in the current window." (interactive "P") (let ((cb (current-buffer)) (cw (selected-window))) + (if below + (switch-to-buffer nil)) (windmove-right) - (set-window-buffer cw (current-buffer)) - (switch-to-buffer cb) - (if stay - (select-window cw)))) + (if (not below) + (set-window-buffer cw (current-buffer))) + (switch-to-buffer cb))) -(defun my-swap-window-to-left (&optional stay) +(defun my-swap-window-to-left (&optional below) (interactive "P") (let ((cb (current-buffer)) (cw (selected-window))) + (if below + (switch-to-buffer nil)) (windmove-left) - (set-window-buffer cw (current-buffer)) - (switch-to-buffer cb) - (if stay - (select-window cw)))) + (if (not below) + (set-window-buffer cw (current-buffer))) + (switch-to-buffer cb))) (global-set-key "\C-x>" 'my-swap-window-to-right) (global-set-key "\C-x<" 'my-swap-window-to-left) @@ -203,3 +214,4 @@ window smaller than MIN-HEIGHT lines." (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)