Function: browse-url-emacs

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

Signature

(browse-url-emacs URL &optional SAME-WINDOW)

Documentation

Ask Emacs to load URL into a buffer and show it in another window.

Optional argument SAME-WINDOW non-nil means show the URL in the currently selected window instead.

Probably introduced at or before Emacs version 22.2.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/net/browse-url.el.gz
;;;###autoload
(defun browse-url-emacs (url &optional same-window)
  "Ask Emacs to load URL into a buffer and show it in another window.
Optional argument SAME-WINDOW non-nil means show the URL in the
currently selected window instead."
  (interactive (browse-url-interactive-arg "URL: "))
  (require 'url-handlers)
  (let ((parsed (url-generic-parse-url url))
        (func (if same-window 'find-file 'find-file-other-window)))
    (if (equal (url-type parsed) "file")
        ;; It's a file; just open it.
        (let ((file (url-unhex-string (url-filename parsed))))
          (when-let ((coding (browse-url--file-name-coding-system)))
            (setq file (decode-coding-string file 'utf-8)))
          ;; The local-part of file: URLs on Windows is supposed to
          ;; start with an extra slash.
          (when (eq system-type 'windows-nt)
            (setq file (replace-regexp-in-string
                        "\\`/\\([a-z]:\\)" "\\1" file)))
          (funcall func file))
      (let ((file-name-handler-alist
             (cons (cons url-handler-regexp 'url-file-handler)
                   file-name-handler-alist)))
        (funcall func url)))))