From: Stefan Monnier Date: Mon, 23 Nov 2009 05:32:25 +0000 (+0000) Subject: (move-to-window-line-last-op): New var. X-Git-Tag: emacs-pretest-23.1.90~268 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=216349f89edbd3476f04fc971ab545cea6239ee6;p=emacs.git (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. --- diff --git a/etc/NEWS b/etc/NEWS index 87c11dd17a2..543d6612578 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -150,6 +150,9 @@ For instance, this can complete M-x lch to list-command-history. ** Completions in the *Completions* buffer are sorted vertically when the value of the new variable `completions-format' is `vertical'. +** M-r is bound to the new `move-to-window-line-top-bottom' +to mirror the new behavior of C-l in Emacs-23.1. + * Changes in Specialized Modes and Packages in Emacs 23.2 diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 797e258b339..70a183b7764 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,9 @@ +2009-11-23 Deniz Dogan (tiny change) + + * window.el (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. + 2009-11-23 Sven Joachim * dired-x.el (dired-guess-shell-alist-default): diff --git a/lisp/window.el b/lisp/window.el index 6d32e42ef1d..e93d3a55d26 100644 --- a/lisp/window.el +++ b/lisp/window.el @@ -1652,6 +1652,39 @@ Top and bottom destinations are actually `scroll-margin' lines (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.")