help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: make ctrl+v (page-down) move even when near the end of document


From: Pavol Murin
Subject: Re: make ctrl+v (page-down) move even when near the end of document
Date: Thu, 3 Apr 2008 10:30:31 +0200

On Apr 2, 6:57 pm, "Lennart Borgman (gmail)" <lennart.borg...@gmail.com> wrote:
> B. T. Raven wrote:
> > Pavol Murin wrote:
> >> hello fellow emacs users,
> >>  I would like to makectrl+vlike page-down (and page-up) do in other
> >> applications when near the beginning or end of the document. This
> >> means that when the point cannot move by a full page, it moves to the
> >> first or last position in the document. I can program it in elisp, but
> >> there might be a simpler solution (maybe a different function to
> >> bind)?
>
> >>  thanks, muro
>
> > The pertinent code that would have to be hacked is in window.c and the
> > only other candidate I see is the variable next-screen-context-lines,
> > also in window.c  Maybe if you can make a good case for the usefulness
> > of this behavior, someone will change the code for you. Out of
> > curiosity, why do you care if the cursor is exactly at top or bottom of
> > buffer as long as you can see the text there.


muscle memory - using it like that in windows applications for 10+ years.


> > Immediately after the last
> > M-v or C-v you can M-< or M-> if you need extreme cursor movement.

that's exactly what I want the command to do :-)

>
> cua-mode has the code for this. It is however bound to PgUp/Down.

where can I find this code? I had a look at cua-base.el, cua-gmrk.el
and cua-rect.el and couldn't find it.

>
> Ed


I couldn't get (scroll-down) to work in lisp, when I was near the
beginning of buffer, then found condition-case. The final scrolling
function is now
8 lines in each direction:


(defun scroll-down-to-point-min ()
  (interactive)
  (let ((curr (window-start)))
    (condition-case ()
        (scroll-down)
      (error nil))
    (if (and (eq curr (window-start)) (/= (point) (point-min)))
        (goto-char (point-min)))))

(defun scroll-up-to-point-max ()
  (interactive)
  (let ((curr (window-start)))
    (condition-case ()
        (scroll-up)
      (error nil))
    (if (and (eq curr (window-start)) (/= (point) (point-max)))
        (goto-char (point-max)))))


(global-set-key [prior] 'scroll-down-to-point-min)
(global-set-key [next] 'scroll-up-to-point-max)


thanks for all hints, muro




reply via email to

[Prev in Thread] Current Thread [Next in Thread]