Function: narrow-to-page
narrow-to-page is an interactive and byte-compiled function defined in
page.el.gz.
Signature
(narrow-to-page &optional ARG)
Documentation
Make text outside current page invisible.
A numeric arg specifies to move forward or backward by that many pages, thus showing a page other than the one point was originally in.
Probably introduced at or before Emacs version 19.1.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/textmodes/page.el.gz
(defun narrow-to-page (&optional arg)
"Make text outside current page invisible.
A numeric arg specifies to move forward or backward by that many pages,
thus showing a page other than the one point was originally in."
(interactive "P")
(setq arg (if arg (prefix-numeric-value arg) 0))
(save-excursion
(widen)
(if (> arg 0)
(forward-page arg)
(if (< arg 0)
(let ((adjust 0)
(opoint (point)))
;; If we are not now at the beginning of a page,
;; move back one extra time, to get to the start of this page.
(save-excursion
(beginning-of-line)
(or (and (looking-at page-delimiter)
(eq (match-end 0) opoint))
(setq adjust 1)))
(forward-page (- arg adjust)))))
;; Find the end of the page.
(set-match-data nil)
(forward-page)
;; If we stopped due to end of buffer, stay there.
;; If we stopped after a page delimiter, put end of restriction
;; at the beginning of that line.
;; Before checking the match that was found,
;; verify that forward-page actually set the match data.
(if (and (match-beginning 0)
(save-excursion
(goto-char (match-beginning 0)) ; was (beginning-of-line)
(looking-at page-delimiter)))
(goto-char (match-beginning 0))) ; was (beginning-of-line)
(narrow-to-region (point)
(progn
;; Find the top of the page.
(forward-page -1)
;; If we found beginning of buffer, stay there.
;; If extra text follows page delimiter on same line,
;; include it.
;; Otherwise, show text starting with following line.
(if (and (eolp) (not (bobp)))
(forward-line 1))
(point)))))