Function: browse-url-of-file
browse-url-of-file is an autoloaded, interactive and byte-compiled
function defined in browse-url.el.gz.
Signature
(browse-url-of-file &optional FILE)
Documentation
Use a web browser to display FILE.
Display the current buffer's file if FILE is nil or if called
interactively. Turn the filename into a URL with function
browse-url-file-url. Pass the URL to a browser using the
browse-url function then run browse-url-of-file-hook.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/net/browse-url.el.gz
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Browse current buffer
;;;###autoload
(defun browse-url-of-file (&optional file)
"Use a web browser to display FILE.
Display the current buffer's file if FILE is nil or if called
interactively. Turn the filename into a URL with function
`browse-url-file-url'. Pass the URL to a browser using the
`browse-url' function then run `browse-url-of-file-hook'."
(interactive)
(or file
(setq file (buffer-file-name))
(error "Current buffer has no file"))
(let ((buf (get-file-buffer file)))
(if buf
(with-current-buffer buf
(cond ((not (buffer-modified-p)))
(browse-url-save-file (save-buffer))
(t (message "%s modified since last save" file))))))
(when (and (file-remote-p file)
(not browse-url-temp-file-name))
(setq browse-url-temp-file-name (file-local-copy file)
file browse-url-temp-file-name))
(browse-url (browse-url-file-url file))
(run-hooks 'browse-url-of-file-hook))