unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* How to scroll while keeping the position of the point with respect to the text?
@ 2007-09-05 19:08 Yevgeniy Makarov
  2007-09-05 19:33 ` Ekkehard Görlach
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Yevgeniy Makarov @ 2007-09-05 19:08 UTC (permalink / raw)
  To: help-gnu-emacs

Hello,

I am looking for a way to scroll text vertically without moving the
position of point with respect to the text. I'd like to do this
frequently when I am prepared to edit something and would like to see
a bit more of the context without moving the point from the selected
position.

I know that this is what the recenter function does; however, it asks
for the screen line number where to put the point, and I would like
for this to be determined automatically by adding or subtracting 1
from the current line number.

If the point is on the top window line, it would be natural to do
(scroll-up 1) instead of recenter, and similarly for the bottom line.
In this case, of course, the position of the point with respect to the
text would change.

If there is no such standard command, I could one myself, but with
changing line height I found a little tricky to figure out whether the
point is on the bottom or top line in the window. Is there a
convenient way to do this?

Thank you,
Yevgeniy

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: How to scroll while keeping the position of the point with respect to the text?
  2007-09-05 19:08 How to scroll while keeping the position of the point with respect to the text? Yevgeniy Makarov
@ 2007-09-05 19:33 ` Ekkehard Görlach
  2007-09-05 19:49   ` Yevgeniy Makarov
  2007-09-05 20:38 ` Ph. Ivaldi
  2007-09-05 21:42 ` Peter Dyballa
  2 siblings, 1 reply; 6+ messages in thread
From: Ekkehard Görlach @ 2007-09-05 19:33 UTC (permalink / raw)
  To: help-gnu-emacs


Hi,

I have 

(global-set-key [M-up] 
 (lambda() (interactive) (scroll-down 1) (previous-line 1)))
(global-set-key [M-down] 
 (lambda() (interactive) (scroll-up 1) (next-line 1)))
(global-set-key [S-up] 
 (lambda() (interactive) (scroll-up 1)))
(global-set-key [S-down] 
 (lambda() (interactive) (scroll-down 1)))

in my .emacs. Thus I could use Shift-up/down to scroll and keep the
position of the point wrt the text (Ithink that was what you were
looking for) or use M-up/down to scroll the text underneath the point.

Ekkehard

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: How to scroll while keeping the position of the point with respect to the text?
  2007-09-05 19:33 ` Ekkehard Görlach
@ 2007-09-05 19:49   ` Yevgeniy Makarov
  0 siblings, 0 replies; 6+ messages in thread
From: Yevgeniy Makarov @ 2007-09-05 19:49 UTC (permalink / raw)
  To: help-gnu-emacs

> (global-set-key [M-up]
>  (lambda() (interactive) (scroll-down 1) (previous-line 1)))
> (global-set-key [M-down]
>  (lambda() (interactive) (scroll-up 1) (next-line 1)))
> (global-set-key [S-up]
>  (lambda() (interactive) (scroll-up 1)))
> (global-set-key [S-down]
>  (lambda() (interactive) (scroll-down 1)))
>
> in my .emacs. Thus I could use Shift-up/down to scroll and keep the
> position of the point wrt the text (Ithink that was what you were
> looking for) or use M-up/down to scroll the text underneath the point.

I am sorry, something does not fit here. Your Shift-up does scroll-up,
which does change the position of the cursor. Second, "(scroll-down 1)
(previous-line 1)" moves the point *two* lines w.r.t. the text. You
probably meant "(scroll-down 1) (next-line 1)". Finally, the problem
with this is that the point is moved to the beginning of the line. And
preserving the horizontal position is not easy, because if some line
is shorter but the following one is long, I'd like for the point to
keep the horizontal position. This calls for watching for the unbroken
series of scrolling commands.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: How to scroll while keeping the position of the point with respect to the text?
  2007-09-05 19:08 How to scroll while keeping the position of the point with respect to the text? Yevgeniy Makarov
  2007-09-05 19:33 ` Ekkehard Görlach
@ 2007-09-05 20:38 ` Ph. Ivaldi
  2007-09-05 21:42 ` Peter Dyballa
  2 siblings, 0 replies; 6+ messages in thread
From: Ph. Ivaldi @ 2007-09-05 20:38 UTC (permalink / raw)
  To: help-gnu-emacs

Hello,

You tried scroll-in-place ?
 http://www.cs.utah.edu/~eeide/emacs/

In .emacs:
8<------8<------8<------8<------8<------8<------8<------8<------8<------
;; -------------------
;; * scroll-in-place *
;; scroll-in-place is a package that keeps the cursor on the same line
;; (and in the same column) when scrolling by a page using PgUp/PgDn.
(require 'scroll-in-place)
(defun scroll-move-up ()
  "* Scroll up without scroll-in-place."
  (interactive)
  (let ((scroll-in-place nil))
    (scroll-up 1)))
(defun scroll-move-down ()
  "* Scroll down without scroll-in-place."
  (interactive)
  (let ((scroll-in-place nil))
    (scroll-up -1)))
(global-set-key (kbd "<C-M-up>") 'scroll-move-up)
(global-set-key (kbd "<C-M-down>") 'scroll-move-down)

;; ----------------------------------
;; * naviguer dans une ligne longue *
;; C-up et C-down pour naviguer dans une ligne longue.
;; En plus le curseur reste immobile (en fait c'est un scroll!).
(defun move-one-up ()
  (interactive)
  (scroll-up 1))
(defun move-one-down ()
  (interactive)
  (scroll-up -1))
(global-set-key (kbd "<C-up>") 'move-one-down)
(global-set-key (kbd "<C-down>") 'move-one-up)
8<------8<------8<------8<------8<------8<------8<------8<------8<------

-- 
Regards,
   Philippe Ivaldi.
http://piprim.tuxfamily.org/

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: How to scroll while keeping the position of the point with respect to the text?
  2007-09-05 19:08 How to scroll while keeping the position of the point with respect to the text? Yevgeniy Makarov
  2007-09-05 19:33 ` Ekkehard Görlach
  2007-09-05 20:38 ` Ph. Ivaldi
@ 2007-09-05 21:42 ` Peter Dyballa
  2007-09-06 11:34   ` Yevgeniy Makarov
  2 siblings, 1 reply; 6+ messages in thread
From: Peter Dyballa @ 2007-09-05 21:42 UTC (permalink / raw)
  To: Yevgeniy Makarov; +Cc: help-gnu-emacs


Am 05.09.2007 um 21:08 schrieb Yevgeniy Makarov:

> I am looking for a way to scroll text vertically without moving the
> position of point with respect to the text.

I have these two functions from Jeff Peck:

	(defun scroll-down-in-place (n)
	  (interactive "p")
	  (previous-line n)
	  (scroll-down n))
	(defun scroll-up-in-place (n)
	  (interactive "p")
	  (next-line n)
	  (scroll-up n))

--
Greetings

   Pete

The human brain operates at only 10% of its capacity. The rest is  
overhead for the operating system.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: How to scroll while keeping the position of the point with respect to the text?
  2007-09-05 21:42 ` Peter Dyballa
@ 2007-09-06 11:34   ` Yevgeniy Makarov
  0 siblings, 0 replies; 6+ messages in thread
From: Yevgeniy Makarov @ 2007-09-06 11:34 UTC (permalink / raw)
  To: Ekkehard Görlach; +Cc: help-gnu-emacs

> May be there are other configurations affecting this.

You are right. I had (setq scroll-preserve-screen-position 1) in my
.emacs. (The reason for this is that when this variable is just t and
the point is on the top line, the scroll-down command without
arguments does not move the point wrt the text , but it moves the
point to the bottom of the window, which I did not like.) When
scroll-preserve-screen-position is t, (scroll-down 1) does not move
the point wrt the text, as you said, and this is what I also wanted.

Concerning scroll-in-place, I knew about it and it works well. I just
thought that maybe since 1994 the same functionality has been included
in Emacs.

Thank you,
Yevgeniy

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2007-09-06 11:34 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-09-05 19:08 How to scroll while keeping the position of the point with respect to the text? Yevgeniy Makarov
2007-09-05 19:33 ` Ekkehard Görlach
2007-09-05 19:49   ` Yevgeniy Makarov
2007-09-05 20:38 ` Ph. Ivaldi
2007-09-05 21:42 ` Peter Dyballa
2007-09-06 11:34   ` Yevgeniy Makarov

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).