comparison lisp/window.el @ 106199:eaae8a5d935f

(move-to-window-line-last-op): New var. (move-to-window-line-top-bottom): New command. (global-map): Bind M-r move-to-window-line-top-bottom.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Mon, 23 Nov 2009 05:32:25 +0000
parents 57f23ca20a76
children 34a3dd721f80
comparison
equal deleted inserted replaced
106198:97b90713fd52 106199:eaae8a5d935f
1650 ((eq recenter-last-op 'top) 1650 ((eq recenter-last-op 'top)
1651 (setq recenter-last-op 'bottom) 1651 (setq recenter-last-op 'bottom)
1652 (recenter (- -1 this-scroll-margin)))))))) 1652 (recenter (- -1 this-scroll-margin))))))))
1653 1653
1654 (define-key global-map [?\C-l] 'recenter-top-bottom) 1654 (define-key global-map [?\C-l] 'recenter-top-bottom)
1655
1656 (defvar move-to-window-line-last-op nil
1657 "Indicates the last move-to-window-line operation performed.
1658 Possible values: `top', `middle', `bottom'.")
1659
1660 (defun move-to-window-line-top-bottom (&optional arg)
1661 "Position point relative to window.
1662
1663 With an argument, acts like `move-to-window-line'.
1664
1665 With no argument, positions point at center of window.
1666 Successive calls positions point at the top, the bottom and again
1667 at the center of the window."
1668 (interactive "P")
1669 (cond
1670 (arg (move-to-window-line arg)) ; Always respect ARG.
1671 ((or (not (eq this-command last-command))
1672 (eq move-to-window-line-last-op 'bottom))
1673 (setq move-to-window-line-last-op 'middle)
1674 (call-interactively 'move-to-window-line))
1675 (t
1676 (let ((this-scroll-margin
1677 (min (max 0 scroll-margin)
1678 (truncate (/ (window-body-height) 4.0)))))
1679 (cond ((eq move-to-window-line-last-op 'middle)
1680 (setq move-to-window-line-last-op 'top)
1681 (move-to-window-line this-scroll-margin))
1682 ((eq move-to-window-line-last-op 'top)
1683 (setq move-to-window-line-last-op 'bottom)
1684 (move-to-window-line (- -1 this-scroll-margin))))))))
1685
1686 (define-key global-map [?\M-r] 'move-to-window-line-top-bottom)
1687
1655 1688
1656 (defvar mouse-autoselect-window-timer nil 1689 (defvar mouse-autoselect-window-timer nil
1657 "Timer used by delayed window autoselection.") 1690 "Timer used by delayed window autoselection.")
1658 1691
1659 (defvar mouse-autoselect-window-position nil 1692 (defvar mouse-autoselect-window-position nil