all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* "Pager" page-up and -down, why not merge?
@ 2008-06-03 20:57 Adrian Robert
  2008-06-04 11:13 ` Richard M Stallman
  2008-06-04 16:14 ` Stefan Monnier
  0 siblings, 2 replies; 11+ messages in thread
From: Adrian Robert @ 2008-06-03 20:57 UTC (permalink / raw)
  To: emacs- devel

Hello,

The "pager" commands at:

http://user.it.uu.se/~mic/pager.el

seem to be an improvement over the existing definitions of scroll-down  
and scroll-up in emacs.  In particular, hitting sequences like [next]  
or Ctrl-v followed by [previous] or M-v leaves point in the same  
place, which is very calming.  ;-)  Is there any reason these could  
not be incorporated into emacs to replace scroll-up and scroll-down in  
these bindings?

It was discussed before with no conclusion:

http://article.gmane.org/gmane.emacs.devel/40324/match=pager
http://article.gmane.org/gmane.emacs.devel/69511/match=pager+el

I'm including below an improved version of this lisp that is used in  
Emacs.app.

----------------------

;;; page-down,page-up etc. leaves cursor in same place
;;; modified (ABR) from pager.el --- windows-scroll commands
;;; Version 2.0 - 97-10-06
;;; Copyright (C) 1992-1997 Mikael Sjodin (mic@docs.uu.se)
;;; http://user.it.uu.se/~mic/emacs.shtml

(defvar pager-temporary-goal-column 0
   "Similar to temporary-goal-column but used by the pager.el  
functions")
;(make-variable-buffer-local 'pager-temporary-goal-column)

(defconst pager-keep-column-commands
   '(pager-row-down pager-row-up row-dn row-up
		   pager-page-down pager-page-up pg-dn pg-up)
   "Commands which when called without any other intervening command  
should
keep the `pager-temporary-goal-column'")

(defun pager-page-down ()
   "Like scroll-up, but moves a fixed amount of lines (fixed relative  
the
`window-text-height') so that pager-page-up moves back to the same  
line."
   (interactive)
   (if (not (pos-visible-in-window-p (point-max)))
       (pager-scroll-screen (- (window-text-height)
			   next-screen-context-lines))))

(defun pager-page-up ()
   "Like scroll-down, but moves a fixed amount of lines (fixed  
relative the
`window-text-height') so that pager-page-down moves back to the same  
line."
   (interactive)
   (if (not (pos-visible-in-window-p (point-min)))
       (pager-scroll-screen (- next-screen-context-lines
			      (window-text-height)))))

(defun pager-scroll-screen (lines)
   "Scroll screen LINES, but keep the cursors position on screen."
   (if (not (memq last-command pager-keep-column-commands))
       (setq pager-temporary-goal-column (current-column)))
   (save-excursion
     (goto-char (window-start))
     (vertical-motion lines)
     (set-window-start (selected-window) (point)))
   (vertical-motion lines)
   (move-to-column pager-temporary-goal-column))

(global-set-key "\C-v"     'pager-page-down)
(global-set-key [next]     'pager-page-down)
(global-set-key "\ev"      'pager-page-up)
(global-set-key [prior]    'pager-page-up)






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

end of thread, other threads:[~2008-06-06 13:24 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-06-03 20:57 "Pager" page-up and -down, why not merge? Adrian Robert
2008-06-04 11:13 ` Richard M Stallman
2008-06-04 12:29   ` Adrian Robert
2008-06-04 13:46   ` Juanma Barranquero
2008-06-05 12:36     ` Richard M Stallman
2008-06-05 13:09       ` Juanma Barranquero
2008-06-04 16:14 ` Stefan Monnier
2008-06-04 22:09   ` Juanma Barranquero
2008-06-04 23:55     ` Adrian Robert
2008-06-05  3:58     ` Stefan Monnier
2008-06-06 13:24   ` Adrian Robert

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.