Function: browse-url-of-buffer

browse-url-of-buffer is an autoloaded, interactive and byte-compiled function defined in browse-url.el.gz.

Signature

(browse-url-of-buffer &optional BUFFER)

Documentation

Use a web browser to display BUFFER.

See browse-url for details.

Display the current buffer if BUFFER is nil. Display only the currently visible part of BUFFER (from a temporary file) if buffer is narrowed.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/net/browse-url.el.gz
;;;###autoload
(defun browse-url-of-buffer (&optional buffer)
  "Use a web browser to display BUFFER.
See `browse-url' for details.

Display the current buffer if BUFFER is nil.  Display only the
currently visible part of BUFFER (from a temporary file) if buffer is
narrowed."
  (interactive)
  (save-excursion
    (and buffer (set-buffer buffer))
    (let ((file-name
	   ;; Ignore real name if restricted
	   (and (not (buffer-narrowed-p))
		(or buffer-file-name
		    (and (boundp 'dired-directory) dired-directory)))))
      (when (or (not file-name)
                ;; This can happen when we're looking at a file from a
                ;; zip file buffer, for instance.
                (not (file-exists-p file-name)))
        (browse-url--temp-file-setup
          (unless browse-url-temp-file-name
            (setq browse-url-temp-file-name
                  (convert-standard-filename
                   (make-temp-file
                    (expand-file-name "burl" browse-url-temp-dir)
                    nil ".html"))))
          (setq file-name browse-url-temp-file-name)
          (write-region (point-min) (point-max) file-name nil 'no-message)))
      (browse-url-of-file file-name))))