* Re: Scrolling the screen vertically
@ 2012-07-04 18:19 Valera Rozuvan
2012-07-04 20:20 ` Eli Zaretskii
0 siblings, 1 reply; 5+ messages in thread
From: Valera Rozuvan @ 2012-07-04 18:19 UTC (permalink / raw)
To: help-gnu-emacs
From: Eli Zaretskii
> Did you know about "C-x <" and "C-x >"? If they don't do what you
> want, then please explain more.
Those commands are not exactly what I am looking for. I will try to
explain myself in detail.
Suppose you have a line that is 200 characters long. If you run the
command C-a, then the cursor moves to the beginning of the line, and
you are at column 0. If you run the command C-e, then the cursor moves
to the end of the line, and you are at column 199.
Now, suppose the screen is 80 columns wide (you have two windows open
side by side). If the cursor is positioned at column X, I want to be
able to do the following:
1.) move to the column X + ((80 / 2) - 2) (scroll by half the screen's
width to the right, with an overlap of 2 columns)
2.) move to the column X - ((80 / 2) - 2) (scroll by half the screen's
width to the left, with an overlap of 2 columns)
3.) move the cursor to Y - 2, where Y is the right-most column visible
on the screen
4.) move the cursor to Z + 2, where Z is the left-most column visible
on the screen
Note that cases 1 and 3 are not the same, because the cursor can be
positioned anywhere (for example X = Y - 2). Same with cases 2 and 4.
So I need functions to determine X, Y, Z, and the screen's width. Then
I can write a function which will move the cursor forward and backward
by a calculated number of characters.
Regards,
Valera Rozuvan
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Scrolling the screen vertically
2012-07-04 18:19 Scrolling the screen vertically Valera Rozuvan
@ 2012-07-04 20:20 ` Eli Zaretskii
0 siblings, 0 replies; 5+ messages in thread
From: Eli Zaretskii @ 2012-07-04 20:20 UTC (permalink / raw)
To: help-gnu-emacs
> Date: Wed, 4 Jul 2012 21:19:08 +0300
> From: Valera Rozuvan <valera.rozuvan@gmail.com>
>
> 1.) move to the column X + ((80 / 2) - 2) (scroll by half the screen's
> width to the right, with an overlap of 2 columns)
> 2.) move to the column X - ((80 / 2) - 2) (scroll by half the screen's
> width to the left, with an overlap of 2 columns)
> 3.) move the cursor to Y - 2, where Y is the right-most column visible
> on the screen
> 4.) move the cursor to Z + 2, where Z is the left-most column visible
> on the screen
>
> Note that cases 1 and 3 are not the same, because the cursor can be
> positioned anywhere (for example X = Y - 2). Same with cases 2 and 4.
>
> So I need functions to determine X, Y, Z, and the screen's width. Then
> I can write a function which will move the cursor forward and backward
> by a calculated number of characters.
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).
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Scrolling the screen vertically
@ 2012-07-06 15:38 Valera Rozuvan
0 siblings, 0 replies; 5+ messages in thread
From: Valera Rozuvan @ 2012-07-06 15:38 UTC (permalink / raw)
To: help-gnu-emacs
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
^ permalink raw reply [flat|nested] 5+ messages in thread
* Scrolling the screen vertically
@ 2012-07-04 14:29 Valera Rozuvan
2012-07-04 15:34 ` Eli Zaretskii
0 siblings, 1 reply; 5+ messages in thread
From: Valera Rozuvan @ 2012-07-04 14:29 UTC (permalink / raw)
To: help-gnu-emacs
Hi all,
While horizontal scrolling of a screen is easy with the default key
combos C-v and M-v, most times I run into the problem of quickly
scrolling sideways. This is a problem for me because I use
(setq truncate-lines t)
in my ~/.emacs
There is the C-a to go to the beginning of the line, and also the C-e
to go to the end of the line. But if the line is very long, I would
like fine-grained control - to scroll by the screen's width with an
overlap of a few characters. Currently I use M-f and M-b to go right
or left by words (this is faster then just using the right and left
keys on the keyboard to move by a single character), but this method
is still slow.
Ideally I would like to write some key combo which lets me peek on any
off-screen text (lines that are longer than the screen's width), and
then go back to the location of the cursor (ideally the cursor
shouldn't move). Is it possible to shift the "view-port" (don't know
how to properly call it) 50 characters left or right?
Any input on this problem will be appreciated.
Regards,
Valera Rozuvan
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Scrolling the screen vertically
2012-07-04 14:29 Valera Rozuvan
@ 2012-07-04 15:34 ` Eli Zaretskii
0 siblings, 0 replies; 5+ messages in thread
From: Eli Zaretskii @ 2012-07-04 15:34 UTC (permalink / raw)
To: help-gnu-emacs
> Date: Wed, 4 Jul 2012 17:29:22 +0300
> From: Valera Rozuvan <valera.rozuvan@gmail.com>
>
> While horizontal scrolling of a screen is easy with the default key
> combos C-v and M-v, most times I run into the problem of quickly
> scrolling sideways. This is a problem for me because I use
>
> (setq truncate-lines t)
>
> in my ~/.emacs
>
> There is the C-a to go to the beginning of the line, and also the C-e
> to go to the end of the line. But if the line is very long, I would
> like fine-grained control - to scroll by the screen's width with an
> overlap of a few characters. Currently I use M-f and M-b to go right
> or left by words (this is faster then just using the right and left
> keys on the keyboard to move by a single character), but this method
> is still slow.
>
> Ideally I would like to write some key combo which lets me peek on any
> off-screen text (lines that are longer than the screen's width), and
> then go back to the location of the cursor (ideally the cursor
> shouldn't move). Is it possible to shift the "view-port" (don't know
> how to properly call it) 50 characters left or right?
Did you know about "C-x <" and "C-x >"? If they don't do what you
want, then please explain more.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2012-07-06 15:38 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-07-04 18:19 Scrolling the screen vertically Valera Rozuvan
2012-07-04 20:20 ` Eli Zaretskii
-- strict thread matches above, loose matches on Subject: below --
2012-07-06 15:38 Valera Rozuvan
2012-07-04 14:29 Valera Rozuvan
2012-07-04 15:34 ` Eli Zaretskii
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).