[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Scrolling the screen vertically
From: |
Valera Rozuvan |
Subject: |
Re: Scrolling the screen vertically |
Date: |
Fri, 6 Jul 2012 18:38:05 +0300 |
From: Eli Zaretskii
> Look at window-width and window-hscroll, I think they give you all you
> need. The functions to actually scroll are those bound to the keys I
> mentioned, and you can control by how much to scroll by giving them an
> argument (see their doc strings).
Thanks! window-width and window-hscroll actually offer everything that
I need. Here is what I came up with:
(defun goto-window-left-margin ()
"Move point to the left edge of the window."
(interactive)
(setq leftEdge (window-hscroll))
(move-to-column leftEdge))
(defun goto-window-right-margin ()
"Move point to the right edge of the window."
(interactive)
(setq rightEdge (+ (window-hscroll) (window-width)))
(move-to-column rightEdge))
(defun goto-window-middle ()
"Move point to the middle of the window."
(interactive)
(setq rightEdge (+ (window-hscroll) (window-width)))
(move-to-column (- rightEdge (floor (* 0.5 (window-width))))))
(global-set-key [C-return] 'goto-window-left-margin)
(global-set-key [M-return] 'goto-window-right-margin)
(global-set-key [M-C-return] 'goto-window-middle)
Now if I want to peek off the screen to the right (or left), I do
M-return, see what is hidden, and then I do C-return, which brings me
back to my original point. Also I added a shortcut to move the cursor
to the center of the screen.
Regards,
Valera Rozuvan