X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=setup%2Fmywin.el;fp=setup%2Fmywin.el;h=11891c8a9cdca2848b1bfb88207d6cba22625133;hb=a13a166794e1e6f22407e13110fe83b9cb095ab8;hp=4fde816acaf86e2544452f50f42315a238b9311e;hpb=844f5833be3c5f0d48e1b3b900c592841f0516d6;p=emacs-init.git diff --git a/setup/mywin.el b/setup/mywin.el index 4fde816..11891c8 100644 --- a/setup/mywin.el +++ b/setup/mywin.el @@ -22,7 +22,7 @@ to 80." window smaller than MIN-HEIGHT lines." (interactive) ;; this algorithm is copied from window.el / balance-windows() - (let ((min-height (or min-height i(+ window-min-height 0))) + (let ((min-height (or min-height (+ window-min-height 0))) (count -1) size) ;; Don't count the lines that are above the uppermost windows. @@ -61,6 +61,15 @@ window smaller than MIN-HEIGHT lines." (defvar my-windows-count nil) +(defun get-top-windows () + (let (topwindows) + (walk-windows (function (lambda (w) + (let ((e (window-edges w))) + (if (< (nth 1 e) window-min-height) + (setq topwindows (cons (cons (nth 0 e) w) topwindows))))))) + (loop for w in (sort topwindows (function (lambda (a b) (< (car a) (car b))))) + collect (cdr w) ))) + (defun setup-my-windows (&optional n) (interactive "P") (if n @@ -73,27 +82,22 @@ window smaller than MIN-HEIGHT lines." (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) - (setq topwindows (cons (list (nth 0 e) - w - (window-buffer w) - (window-point w) - (window-start w) - (equal w currentwindow)) - topwindows)))))) - 'nomini) - (setq topwindows (sort topwindows (function (lambda (a b) (< (car a) (car b)))))) - (setq topwindows (loop for w in topwindows - for (pos win buf point start iscurrent) = w - if (not (member (buffer-name buf) setup-my-windows-junk-buffers)) - collect w)) + (topwindows (loop for w in (get-top-windows) + for b = (window-buffer w) + if (not (member (buffer-name b) + setup-my-windows-junk-buffers)) + collect (list (nth 0 (window-edges w)) + w + b + (window-point w) + (window-start w) + (equal w currentwindow)))) + firstwindow newwindow newtopwindows newbottomwindow) (delete-other-windows (nth 1 (car topwindows))) (save-selected-window - (select-window (split-window-vertically - (- (window-height) (max 5 (/ (* (frame-height) 15) 100)) -1))) + (setq newbottomwindow (split-window-vertically + (- (window-height) (max 5 (/ (* (frame-height) 15) 100)) -1))) + (select-window newbottomwindow) (switch-to-buffer (get-buffer-create "*compilation*")) (if (eq currentbuffer (current-buffer)) (setq newwindow (selected-window)))) @@ -148,19 +152,39 @@ window smaller than MIN-HEIGHT lines." (pjb-balance-windows t)) (select-window newwindow) (if (not (member (buffer-name currentbuffer) setup-my-windows-junk-buffers)) - (switch-to-buffer currentbuffer)))) + (switch-to-buffer currentbuffer)) + newbottomwindow)) (defun my-split-window-sensibly (window) (if (and (> (window-height window) (- (frame-height (window-frame window)) window-min-height)) (> (window-height window) (max 5 (/ (* (frame-height) 15) 100)))) (split-window-sensibly window))) +(defun my-pop-to-buffer (buffer) + ;; display buffer in rightmost window if not displayed currently + (let ((w (get-buffer-window buffer))) + (unless w + (setq w (car (last (get-top-windows))))) + (select-window w) + (switch-to-buffer buffer))) + +(defun my-display-at-bottom (&optional buffer) + ;; call my-setup-window and display current-buffer or BUFFER in bottom frame + (interactive) + (if (not buffer) (setq buffer (current-buffer))) + (bury-buffer) + ;; why does save-selected-window not work here ??? + (save-selected-window + (select-window (setup-my-windows)) + (switch-to-buffer buffer))) + (setq split-window-preferred-function 'my-split-window-sensibly) (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-\M-_" (lambda () (interactive) (safe-shrink-window 5))) +(global-set-key "\C-x_" 'my-display-at-bottom) (defun my-swap-window-to-right (&optional below) "If swap buffer in this window with buffer on the right. If BELOW is set, @@ -217,8 +241,10 @@ the buffer stack in the current window." (defun safe-max-window () (interactive) - (safe-max-window-horizontally) - (maximize-window 5)) + (maximize-window 5) + (condition-case nil + (safe-max-window-horizontally) + (error nil))) (global-set-key "\C-x=" 'safe-max-window) (global-set-key "\C-x-" 'maximize-window-15)