-(defun view-mode (&optional prev-buffer action)
- "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).
-\\[Helper-help] 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}"
-; Not interactive because dangerous things happen
-; if you call it without passing a buffer as argument
-; and they are not easy to fix.
-; (interactive)
- (make-local-variable 'view-old-mode-line-buffer-identification)
- (setq view-old-mode-line-buffer-identification
- mode-line-buffer-identification)
- (make-local-variable 'view-old-buffer-read-only)
- (setq view-old-buffer-read-only buffer-read-only)
- (make-local-variable 'view-old-mode-name)
- (setq view-old-mode-name mode-name)
- (make-local-variable 'view-old-major-mode)
- (setq view-old-major-mode major-mode)
- (make-local-variable 'view-old-local-map)
- (setq view-old-local-map (current-local-map))
- (make-local-variable 'view-old-Helper-return-blurb)
- (setq view-old-Helper-return-blurb
- (and (boundp 'Helper-return-blurb) Helper-return-blurb))
-
- (setq buffer-read-only t)
- (setq mode-line-buffer-identification
- (list
- (if (buffer-file-name)
- "Viewing %f"
- "Viewing %b")))
- (setq mode-name "View")
- (setq major-mode 'view-mode)
- (setq Helper-return-blurb
+(defun view-buffer-other-frame (buffer &optional not-return exit-action)
+ "View BUFFER in View mode in another frame.
+Return to previous buffer when done, unless optional NOT-RETURN is non-nil.
+Emacs commands editing the buffer contents 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 H or h while viewing.
+
+This command runs the normal hook `view-mode-hook'.
+
+Optional argument EXIT-ACTION is either nil or a function with buffer as
+argument. This function is called when finished viewing buffer.
+Use this argument instead of explicitly setting `view-exit-action'."
+ (interactive "bView buffer in other frame: \nP")
+ (let ((return-to
+ (and (not not-return) (cons (selected-window) t)))) ; Old window.
+ (switch-to-buffer-other-frame buffer)
+ (view-mode-enter (and return-to (cons (selected-window) return-to))
+ exit-action)))
+\f
+;;;###autoload
+(defun view-mode (&optional arg)
+ ;; In the following documentation string we have to use some explicit key
+ ;; bindings instead of using the \\[] construction. The reason for this
+ ;; is that most commands have more than one key binding.
+ "Toggle View mode, a minor mode for viewing text but not editing it.
+With ARG, turn View mode on iff ARG is positive.
+
+Emacs commands that do not change the buffer contents are available as usual.
+Kill commands insert text in kill buffers but do not delete. Other commands
+\(among them most letters and punctuation) beep and tell that the buffer is
+read-only.
+\\<view-mode-map>
+The following additional commands are provided. Most commands take prefix
+arguments. Page commands default to \"page size\" lines which is almost a whole
+window full, or number of lines set by \\[View-scroll-page-forward-set-page-size] or \\[View-scroll-page-backward-set-page-size]. Half page commands default to
+and set \"half page size\" lines which initially is half a window full. Search
+commands default to a repeat count of one.
+
+H, h, ? This message.
+Digits provide prefix arguments.
+\\[negative-argument] negative prefix argument.
+\\[beginning-of-buffer] move to the beginning of buffer.
+> move to the end of buffer.
+\\[View-scroll-to-buffer-end] scroll so that buffer end is at last line of window.
+SPC scroll forward \"page size\" lines.
+ With prefix scroll forward prefix lines.
+DEL scroll backward \"page size\" lines.
+ With prefix scroll backward prefix lines.
+\\[View-scroll-page-forward-set-page-size] like \\[View-scroll-page-forward] but with prefix sets \"page size\" to prefix.
+\\[View-scroll-page-backward-set-page-size] like \\[View-scroll-page-backward] but with prefix sets \"page size\" to prefix.
+\\[View-scroll-half-page-forward] scroll forward \"half page size\" lines. With prefix, sets
+ \"half page size\" to prefix lines and scrolls forward that much.
+\\[View-scroll-half-page-backward] scroll backward \"half page size\" lines. With prefix, sets
+ \"half page size\" to prefix lines and scrolls backward that much.
+RET, LFD scroll forward one line. With prefix scroll forward prefix line(s).
+y scroll backward one line. With prefix scroll backward prefix line(s).
+\\[View-revert-buffer-scroll-page-forward] revert-buffer if necessary and scroll forward.
+ Use this to view a changing file.
+\\[what-line] prints the current line number.
+\\[View-goto-percent] goes prefix argument (default 100) percent into buffer.
+\\[View-goto-line] goes to line given by prefix argument (default first line).
+. set the mark.
+x exchanges point and mark.
+\\[View-back-to-mark] return to mark and pops mark ring.
+ Mark ring is pushed at start of every successful search and when
+ jump to line occurs. The mark is set on jump to buffer start or end.
+\\[point-to-register] save current position in character register.
+' go to position saved in character register.
+s do forward incremental search.
+r do reverse incremental search.
+\\[View-search-regexp-forward] searches forward for regular expression, starting after current page.
+ ! and @ have a special meaning at the beginning of the regexp.
+ ! means search for a line with no match for regexp. @ means start
+ search at beginning (end for backward search) of buffer.
+\\ searches backward for regular expression, starting before current page.
+\\[View-search-last-regexp-forward] searches forward for last regular expression.
+p searches backward for last regular expression.
+\\[View-quit] quit View mode, restoring this window and buffer to previous state.
+ \\[View-quit] is the normal way to leave view mode.
+\\[View-exit] exit View mode but stay in current buffer. Use this if you started
+ viewing a buffer (file) and find out you want to edit it.
+ This command restores the previous read-only status of the buffer.
+\\[View-exit-and-edit] exit View mode, and make the current buffer editable
+ even if it was not editable before entry to View mode.
+\\[View-quit-all] quit View mode, restoring all windows to previous state.
+\\[View-leave] quit View mode and maybe switch buffers, but don't kill this buffer.
+\\[View-kill-and-leave] quit View mode, kill current buffer and go back to other buffer.
+
+The effect of \\[View-leave] , \\[View-quit] and \\[View-kill-and-leave] depends on how view-mode was entered. If it was
+entered by view-file, view-file-other-window or view-file-other-frame
+\(\\[view-file], \\[view-file-other-window], \\[view-file-other-frame] or the dired mode v command), then \\[View-quit] will
+try to kill the current buffer. If view-mode was entered from another buffer
+as is done by View-buffer, View-buffer-other-window, View-buffer-other frame,
+View-file, View-file-other-window or View-file-other-frame then \\[View-leave] , \\[View-quit] and \\[View-kill-and-leave]
+will return to that buffer.
+
+Entry to view-mode runs the normal hook `view-mode-hook'."
+ (interactive "P")
+ (unless (and arg ; Do nothing if already OK.
+ (if (> (prefix-numeric-value arg) 0) view-mode (not view-mode)))
+ (if view-mode (view-mode-disable)
+ (view-mode-enable))))
+\f
+(defun view-mode-enable ()
+ "Turn on View mode."
+ ;; Always leave view mode before changing major mode.
+ ;; This is to guarantee that the buffer-read-only variable is restored.
+ (add-hook 'change-major-mode-hook 'view-mode-disable nil t)
+ (setq view-mode t
+ view-page-size nil
+ view-half-page-size nil
+ view-old-buffer-read-only buffer-read-only
+ buffer-read-only t
+ view-old-Helper-return-blurb (and (boundp 'Helper-return-blurb)
+ Helper-return-blurb)
+ Helper-return-blurb