Function: view-mode-exit

view-mode-exit is a byte-compiled function defined in view.el.gz.

Signature

(view-mode-exit &optional EXIT-ONLY EXIT-ACTION ALL-WINDOWS)

Documentation

Exit View mode in various ways.

If all arguments are nil, remove the current buffer from the selected window using the quit-restore information associated with the selected window. If optional argument ALL-WINDOWS or view-exits-all-viewing-windows are non-nil, remove the current buffer from all windows showing it.

Optional argument EXIT-ONLY non-nil means just exit view-mode(var)/view-mode(fun)
(unless view-no-disable-on-exit is non-nil) but do not change
the associations of any windows with the current buffer.

EXIT-ACTION, if non-nil, must specify a function that is called with the current buffer as argument and is called after disabling view-mode(var)/view-mode(fun) and removing any associations of windows with the current buffer.

Probably introduced at or before Emacs version 20.1.

Source Code

;; Defined in /usr/src/emacs/lisp/view.el.gz
;; This is awful because it assumes that the selected window shows the
;; current buffer when this is called.
(defun view-mode-exit (&optional exit-only exit-action all-windows)
  "Exit View mode in various ways.
If all arguments are nil, remove the current buffer from the
selected window using the `quit-restore' information associated
with the selected window.  If optional argument ALL-WINDOWS or
`view-exits-all-viewing-windows' are non-nil, remove the current
buffer from all windows showing it.

Optional argument EXIT-ONLY non-nil means just exit `view-mode'
\(unless `view-no-disable-on-exit' is non-nil) but do not change
the associations of any windows with the current buffer.

EXIT-ACTION, if non-nil, must specify a function that is called
with the current buffer as argument and is called after disabling
`view-mode' and removing any associations of windows with the
current buffer."
  (when view-mode
    (let ((buffer (window-buffer)))
      (unless view-no-disable-on-exit
	(view-mode -1))

      (unless exit-only
	(cond
	 ((or all-windows view-exits-all-viewing-windows)
	  (dolist (window (get-buffer-window-list))
	    (quit-window nil window)))
	 ((eq (window-buffer) (current-buffer))
	  (quit-window)))

	(when exit-action
	  (funcall exit-action buffer))))))