4.4BSD/usr/src/contrib/emacs-18.57/lisp/view.elc


(provide (quote view))

(defvar view-mode-map nil)

(if view-mode-map nil (setq view-mode-map (make-keymap)) (fillarray view-mode-map (quote View-undefined)) (define-key view-mode-map "" (quote exit-recursive-edit)) (define-key view-mode-map "" (quote suspend-emacs)) (define-key view-mode-map "q" (quote exit-recursive-edit)) (define-key view-mode-map "-" (quote negative-argument)) (define-key view-mode-map "0" (quote digit-argument)) (define-key view-mode-map "1" (quote digit-argument)) (define-key view-mode-map "2" (quote digit-argument)) (define-key view-mode-map "3" (quote digit-argument)) (define-key view-mode-map "4" (quote digit-argument)) (define-key view-mode-map "5" (quote digit-argument)) (define-key view-mode-map "6" (quote digit-argument)) (define-key view-mode-map "7" (quote digit-argument)) (define-key view-mode-map "8" (quote digit-argument)) (define-key view-mode-map "9" (quote digit-argument)) (define-key view-mode-map "" (quote universal-argument)) (define-key view-mode-map "" nil) (define-key view-mode-map "" (quote Control-X-prefix)) (define-key view-mode-map "-" (quote negative-argument)) (define-key view-mode-map "0" (quote digit-argument)) (define-key view-mode-map "1" (quote digit-argument)) (define-key view-mode-map "2" (quote digit-argument)) (define-key view-mode-map "3" (quote digit-argument)) (define-key view-mode-map "4" (quote digit-argument)) (define-key view-mode-map "5" (quote digit-argument)) (define-key view-mode-map "6" (quote digit-argument)) (define-key view-mode-map "7" (quote digit-argument)) (define-key view-mode-map "8" (quote digit-argument)) (define-key view-mode-map "9" (quote digit-argument)) (define-key view-mode-map "<" (quote beginning-of-buffer)) (define-key view-mode-map ">" (quote end-of-buffer)) (define-key view-mode-map "v" (quote View-scroll-lines-backward)) (define-key view-mode-map "" (quote View-scroll-lines-forward)) (define-key view-mode-map " " (quote View-scroll-lines-forward)) (define-key view-mode-map "" (quote View-scroll-lines-backward)) (define-key view-mode-map "
" (quote View-scroll-one-more-line)) (define-key view-mode-map "
" (quote View-scroll-one-more-line)) (define-key view-mode-map "" (quote recenter)) (define-key view-mode-map "z" (quote View-scroll-lines-forward-set-scroll-size)) (define-key view-mode-map "g" (quote View-goto-line)) (define-key view-mode-map "=" (quote what-line)) (define-key view-mode-map "." (quote set-mark-command)) (define-key view-mode-map "" (quote set-mark-command)) (define-key view-mode-map "'" (quote View-back-to-mark)) (define-key view-mode-map "@" (quote View-back-to-mark)) (define-key view-mode-map "x" (quote exchange-point-and-mark)) (define-key view-mode-map "h" (quote Helper-describe-bindings)) (define-key view-mode-map "?" (quote Helper-describe-bindings)) (define-key view-mode-map "" (quote Helper-help)) (define-key view-mode-map "" (quote next-line)) (define-key view-mode-map "" (quote previous-line)) (define-key view-mode-map "" (quote isearch-forward)) (define-key view-mode-map "" (quote isearch-backward)) (define-key view-mode-map "s" (quote isearch-forward)) (define-key view-mode-map "r" (quote isearch-backward)) (define-key view-mode-map "/" (quote View-search-regexp-forward)) (define-key view-mode-map "\\" (quote View-search-regexp-backward)) (define-key view-mode-map "" (quote View-search-regexp-forward)) (define-key view-mode-map "" (quote View-search-regexp-backward)) (define-key view-mode-map "n" (quote View-search-last-regexp-forward)) (define-key view-mode-map "p" (quote View-search-last-regexp-backward)))

(defun view-file (file-name) "\
View FILE in View mode, returning to previous buffer when done.
The usual Emacs commands are not available; instead,
a special set of commands (mostly letters and punctuation)
are defined for moving around in the buffer.
Space scrolls forward, Delete scrolls backward.
For list of all View commands, type ? or h while viewing.

Calls the value of  view-hook  if that is non-nil." (interactive "fView file: ") (byte-code "È	!Ǝp	!\"!)*" [had-a-buf file-name buf-to-view nil t get-file-buffer ((byte-code "?		!?	!" [had-a-buf buf-to-view buffer-modified-p kill-buffer] 3)) view-mode switch-to-buffer find-file-noselect] 7))

(defun view-buffer (buffer-name) "\
View BUFFER in View mode, returning to previous buffer when done.
The usual Emacs commands are not available; instead,
a special set of commands (mostly letters and punctuation)
are defined for moving around in the buffer.
Space scrolls forward, Delete scrolls backward.
For list of all View commands, type ? or h while viewing.

Calls the value of  view-hook  if that is non-nil." (interactive "bView buffer: ") (byte-code "p!!" [buffer-name nil view-mode switch-to-buffer] 4))

(defun view-mode (&optional view-return-to-buffer) "\
Major mode for viewing text but not editing it.
Letters do not insert themselves.  Instead these commands are provided.
Most commands take prefix arguments.  Commands dealing with lines
default to \"scroll size\" lines (initially size of window).
Search commands default to a repeat count of one.
M-< or <	move to beginning of buffer.
M-> or >	move to end of buffer.
C-v or Space	scroll forward lines.
M-v or DEL	scroll backward lines.
CR or LF	scroll forward one line (backward with prefix argument).
z		like Space except set number of lines for further
		   scrolling commands to scroll by.
C-u and Digits	provide prefix arguments.  `-' denotes negative argument.
=		prints the current line number.
g		goes to line given by prefix argument.
/ or M-C-s	searches forward for regular expression
\\ or M-C-r	searches backward for regular expression.
n		searches forward for last regular expression.
p		searches backward for last regular expression.
C-@ or .	set the mark.
x		exchanges point and mark.
C-s or s	do forward incremental search.
C-r or r	do reverse incremental search.
@ or '		return to mark and pops mark ring.
		  Mark ring is pushed at start of every
		  successful search and when jump to line to occurs.
		  The mark is set on jump to buffer start or end.
? or h		provide help message (list of commands).
C-h		provides help (list of commands or description of a command).
C-n		moves down lines vertically.
C-p		moves upward lines vertically.
C-l		recenters the screen.
q or C-c	exit view-mode and return to previous buffer.

Entry to this mode calls the value of  view-hook  if non-nil.
\\{view-mode-map}" (byte-code " Ɏ ˂C Ѝ+)*" [view-buffer-window view-scroll-size nil buffer-read-only t mode-line-buffer-identification mode-name view-return-to-buffer selected-window ((byte-code "!" [view-return-to-buffer switch-to-buffer] 2)) buffer-file-name "Viewing %f" "Viewing %b" "View" beginning-of-line view-mode-exit (byte-code " " [view-mode-command-loop] 2)] 5))

(defun view-helpful-message nil (byte-code "!=!=!=Ȃ !!" [message key-binding "" Helper-help "?" Helper-describe-bindings "" exit-recursive-edit "Type C-h for help, ? for commands, C-c to quit" substitute-command-keys "Type \\[Helper-help] for help, \\[Helper-describe-bindings] for commands, \\[exit-recursive-edit] to quit."] 6))

(defun View-undefined nil (interactive) (byte-code "  " [nil ding view-helpful-message] 3))

(defun view-window-size nil (byte-code "!S" [view-buffer-window window-height] 2))

(defun view-scroll-size nil (byte-code "  ^" [view-scroll-size view-window-size] 4))

(defvar view-hook nil "\
If non-nil, its value is called when viewing buffer or file.")

(defun view-mode-command-loop nil (byte-code "    ! \" Ў!!  ). " [old-local-map mark-ring nil view-last-regexp Helper-return-blurb goal-column view-buffer view-mode-map push-mark current-local-map format "continue viewing %s" buffer-file-name file-name-nondirectory buffer-name 0 ((byte-code "q	!)" [view-buffer old-local-map use-local-map] 2)) use-local-map run-hooks view-hook view-helpful-message recursive-edit pop-mark] 14))

(defun View-goto-line (&optional line) "\
Move to LINE in View mode.
Display is centered at LINE.  Sets mark at starting position and pushes
mark ring." (interactive "p") (byte-code " ! \"!" [line nil push-mark goto-line 1 recenter / view-window-size 2] 7))

(defun View-scroll-lines-forward (&optional lines) "\
Scroll forward in View mode, or exit if end of text is visible.
No arg means whole window full, or number of lines set by \\[View-scroll-lines-forward-set-scroll-size].
Arg is number of lines to scroll." (interactive "P") (byte-code "d!
 !  Y'!8[ Y5!8!d!Kdb!!!! " [lines nil pos-visible-in-window-p exit-recursive-edit prefix-numeric-value view-scroll-size view-window-size scroll-up scroll-down recenter -1 message substitute-command-keys "End.  Type \\[exit-recursive-edit] to quit viewing." move-to-window-line beginning-of-line] 16))

(defun View-scroll-lines-forward-set-scroll-size (&optional lines) "\
Scroll forward LINES lines in View mode, setting the \"scroll size\".
This is the number of lines which \\[View-scroll-lines-forward] and \\[View-scroll-lines-backward] scroll by default.
The absolute value of LINES is used, so this command can be used to scroll
backwards (but \"scroll size\" is always positive).  If LINES is greater than
window height or omitted, then window height is assumed.  If LINES is less
than window height then scrolling context is provided from previous screen." (interactive "P") (byte-code "ˆ? %!V [ ^!" [lines view-scroll-size nil view-window-size prefix-numeric-value 0 View-scroll-lines-forward] 5))

(defun View-scroll-one-more-line (&optional arg) "\
Scroll one more line up in View mode.
With ARG scroll one line down." (interactive "P") (byte-code "?Â
!" [arg nil View-scroll-lines-forward 1 -1] 2))

(defun View-scroll-lines-backward (&optional lines) "\
Scroll backward in View mode.
No arg means whole window full, or number of lines set by \\[View-scroll-lines-forward-set-scroll-size].
Arg is number of lines to scroll." (interactive "P") (byte-code "![ [!" [lines nil View-scroll-lines-forward prefix-numeric-value view-scroll-size] 4))

(defun View-search-regexp-forward (times regexp) "\
Search forward for NTH occurrence of REGEXP in View mode.
Displays line found at center of window.  REGEXP is remembered for
searching with \\[View-search-last-regexp-forward] and \\[View-search-last-regexp-backward].  Sets mark at starting position and pushes mark ring." (interactive "p
sSearch forward (regexp): ") (byte-code "ˆGV
	\"" [regexp times nil 0 view-search] 3))

(defun View-search-regexp-backward (times regexp) "\
Search backward from window start for NTH instance of REGEXP in View mode.
Displays line found at center of window.  REGEXP is remembered for
searching with \\[View-search-last-regexp-forward] and \\[View-search-last-regexp-backward].  Sets mark at starting position and pushes mark ring." (interactive "p
sSearch backward (regexp): ") (byte-code "ˆ[	\"" [times regexp nil View-search-regexp-forward] 3))

(defun View-search-last-regexp-forward (times) "\
Search forward from window end for NTH instance of last regexp in View mode.
Displays line found at center of window.  Sets mark at starting position
and pushes mark ring." (interactive "p") (byte-code "ˆ	\"" [times view-last-regexp nil View-search-regexp-forward] 3))

(defun View-search-last-regexp-backward (times) "\
Search backward from window start for NTH instance of last regexp in View mode.
Displays line found at center of window.  Sets mark at starting position and
pushes mark ring." (interactive "p") (byte-code "ˆ	\"" [times view-last-regexp nil View-search-regexp-backward] 3))

(defun View-back-to-mark (&optional ignore) "\
Return to last mark set in View mode, else beginning of file.
Displays line at center of window.  Pops mark ring so successive
invocations return to earlier marks." (interactive) (byte-code " eb  \"!" [nil mark pop-mark recenter / view-window-size 2] 7))

(defun view-search (times regexp) (byte-code "	Wǂ!	$!`)
: 
b  \"!C	#!)" [view-last-regexp regexp where times nil t move-to-window-line 0 -1 re-search-forward push-mark beginning-of-line recenter / view-window-size 2 message "Can't find occurrence %d of %s" sit-for 4] 11))