From: Adrian Robert <arobert@interstitiality.net>
To: emacs- devel <emacs-devel@gnu.org>
Subject: "Pager" page-up and -down, why not merge?
Date: Tue, 3 Jun 2008 16:57:38 -0400 [thread overview]
Message-ID: <5896C8E2-D065-4B8E-927F-8784062241EF@interstitiality.net> (raw)
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)
next reply other threads:[~2008-06-03 20:57 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-06-03 20:57 Adrian Robert [this message]
2008-06-04 11:13 ` "Pager" page-up and -down, why not merge? 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5896C8E2-D065-4B8E-927F-8784062241EF@interstitiality.net \
--to=arobert@interstitiality.net \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.