Mercurial > emacs
diff 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 |
line wrap: on
line diff
--- a/lisp/window.el Mon Nov 23 00:32:37 2009 +0000 +++ b/lisp/window.el Mon Nov 23 05:32:25 2009 +0000 @@ -1652,6 +1652,39 @@ (recenter (- -1 this-scroll-margin)))))))) (define-key global-map [?\C-l] 'recenter-top-bottom) + +(defvar move-to-window-line-last-op nil + "Indicates the last move-to-window-line operation performed. +Possible values: `top', `middle', `bottom'.") + +(defun move-to-window-line-top-bottom (&optional arg) + "Position point relative to window. + +With an argument, acts like `move-to-window-line'. + +With no argument, positions point at center of window. +Successive calls positions point at the top, the bottom and again +at the center of the window." + (interactive "P") + (cond + (arg (move-to-window-line arg)) ; Always respect ARG. + ((or (not (eq this-command last-command)) + (eq move-to-window-line-last-op 'bottom)) + (setq move-to-window-line-last-op 'middle) + (call-interactively 'move-to-window-line)) + (t + (let ((this-scroll-margin + (min (max 0 scroll-margin) + (truncate (/ (window-body-height) 4.0))))) + (cond ((eq move-to-window-line-last-op 'middle) + (setq move-to-window-line-last-op 'top) + (move-to-window-line this-scroll-margin)) + ((eq move-to-window-line-last-op 'top) + (setq move-to-window-line-last-op 'bottom) + (move-to-window-line (- -1 this-scroll-margin)))))))) + +(define-key global-map [?\M-r] 'move-to-window-line-top-bottom) + (defvar mouse-autoselect-window-timer nil "Timer used by delayed window autoselection.")
