Function: view-buffer
view-buffer is an autoloaded, interactive and byte-compiled function
defined in view.el.gz.
Signature
(view-buffer BUFFER &optional EXIT-ACTION)
Documentation
View BUFFER in View mode, returning to previous buffer when done.
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 a 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.
Do not set EXIT-ACTION to kill-buffer when BUFFER visits a
file: Users may suspend viewing in order to modify the buffer.
Exiting View mode will then discard the user's edits. Setting
EXIT-ACTION to kill-buffer-if-not-modified avoids this.
This function does not enable View mode if the buffer's major mode
has a special mode-class, because such modes usually have their
own View-like bindings.
Probably introduced at or before Emacs version 16.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/view.el.gz
;;;###autoload
(defun view-buffer (buffer &optional exit-action)
"View BUFFER in View mode, returning to previous buffer when done.
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 a 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'.
Do not set EXIT-ACTION to `kill-buffer' when BUFFER visits a
file: Users may suspend viewing in order to modify the buffer.
Exiting View mode will then discard the user's edits. Setting
EXIT-ACTION to `kill-buffer-if-not-modified' avoids this.
This function does not enable View mode if the buffer's major mode
has a `special' mode-class, because such modes usually have their
own View-like bindings."
(interactive "bView buffer: ")
(switch-to-buffer buffer)
(if (eq (get major-mode 'mode-class) 'special)
(message "Not using View mode because the major mode is special")
(view-mode-enter nil exit-action)))