Function: forward-page
forward-page is an interactive and byte-compiled function defined in
page.el.gz.
Signature
(forward-page &optional COUNT)
Documentation
Move forward to page boundary. With arg, repeat, or go back if negative.
A page boundary is any line whose beginning matches the regexp
page-delimiter.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/textmodes/page.el.gz
;;; page.el --- page motion commands for Emacs -*- lexical-binding: t; -*-
;; Copyright (C) 1985, 2001-2024 Free Software Foundation, Inc.
;; Maintainer: emacs-devel@gnu.org
;; Keywords: wp convenience
;; Package: emacs
;; This file is part of GNU Emacs.
;; GNU Emacs is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
;;; Commentary:
;; This code provides the page-oriented movement and selection commands
;; documented in the Emacs manual.
;;; Code:
(defun forward-page (&optional count)
"Move forward to page boundary. With arg, repeat, or go back if negative.
A page boundary is any line whose beginning matches the regexp
`page-delimiter'."
(interactive "p")
(or count (setq count 1))
(while (and (> count 0) (not (eobp)))
(if (and (looking-at page-delimiter)
(> (match-end 0) (point)))
;; If we're standing at the page delimiter, then just skip to
;; the end of it. (But only if it's not a zero-length
;; delimiter, because then we wouldn't have forward progress.)
(goto-char (match-end 0))
;; In case the page-delimiter matches the null string,
;; don't find a match without moving.
(when (bolp)
(forward-char 1))
(unless (re-search-forward page-delimiter nil t)
(goto-char (point-max))))
(setq count (1- count)))
(while (and (< count 0) (not (bobp)))
;; In case the page-delimiter matches the null string,
;; don't find a match without moving.
(and (save-excursion (re-search-backward page-delimiter nil t))
(= (match-end 0) (point))
(goto-char (match-beginning 0)))
(unless (bobp)
(forward-char -1)
(if (re-search-backward page-delimiter nil t)
;; We found one--move to the end of it.
(goto-char (match-end 0))
;; We found nothing--go to beg of buffer.
(goto-char (point-min))))
(setq count (1+ count))))