Function: view-file

view-file is an autoloaded, interactive and byte-compiled function defined in view.el.gz.

Signature

(view-file FILE)

Documentation

View FILE 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.

View in manual

Probably introduced at or before Emacs version 16.

Key Bindings

Aliases

id-browse-file

Source Code

;; Defined in /usr/src/emacs/lisp/view.el.gz
;;;###autoload
(defun view-file (file)
  "View FILE 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'."
  (interactive "fView file: ")
  (unless (file-exists-p file) (error "%s does not exist" file))
  (let ((had-a-buf (get-file-buffer file))
	(buffer (find-file-noselect file)))
    (view-buffer buffer (and (not had-a-buf) 'kill-buffer-if-not-modified))))