;; place-corners.jl -- placement of windows by first using corners. ;; Copyright (C) 2000, Jimmy Mäkelä ;; This file is public domain. You may use it in any way you want. ;; To use this placement method you have to put this file somewhere in your ;; load-path and add (require 'place-corners) to your .sawmillrc. Now you should ;; have two fields in your placement methods configuration which reads ;; corners-or-best-fit and corners-or-interactively. Choose the one which fits your ;; mood best. (provide 'place-corners) (require 'place-window) (defun corner-not-used? (window x y right bottom) (let ((windows-on-corner (delete-if-not (lambda (w) (let ((delta-w (* right (car (window-frame-dimensions w)))) (delta-h (* bottom (cdr (window-frame-dimensions w))))) (and (= (+ delta-w (car (window-position w))) x) (= (+ delta-h (cdr (window-position w))) y) (windows-share-workspace-p w window) (not (eq w window))))) (managed-windows)))) (null windows-on-corner))) (defun place-corners (window func) (let ((size-x (car (window-frame-dimensions window))) (size-y (cdr (window-frame-dimensions window)))) (cond ((corner-not-used? window 0 0 0 0) (move-window-to window 0 0)) ((corner-not-used? window (screen-width) 0 1 0) (move-window-to window (- (screen-width) size-x) 0)) ((corner-not-used? window 0 (screen-height) 0 1) (move-window-to window 0 (- (screen-height) size-y))) ((corner-not-used? window (screen-width) (screen-height) 1 1) (move-window-to window (- (screen-width) size-x) (- (screen-height) size-y))) (t (func window))))) (defun place-window-corners-or-best-fit (window) (place-corners window place-window-best-fit)) (defun place-window-corners-or-interactively (window) (place-corners window place-window-interactively)) ;; Make these functions visible from the window-placement configuration. (setq place-window-modes (append place-window-modes '(corners-or-best-fit corners-or-interactively))) (custom-set-property 'place-window-mode ':options place-window-modes) (custom-set-property 'place-transient-mode ':options place-window-modes) (put 'corners-or-best-fit 'placement-mode place-window-corners-or-best-fit) (put 'corners-or-interactively 'placement-mode place-window-corners-or-interactively)