Homepage: https://www.gnu.org/software/emacs
Author: Denis Howe
Pass a URL to a WWW browser
This package provides functions which read a URL (Uniform Resource Locator) from the minibuffer, defaulting to the URL around point, and ask a World-Wide Web browser to load it. It can also load the URL associated with the current buffer. Different browsers use different methods of remote control so there is one function for each supported browser. If the chosen browser is not running, it is started. Currently there is support for the following browsers, as well as some other obsolete ones: Function Browser Earliest version browse-url-mozilla Mozilla Don't know browse-url-firefox Firefox Don't know (tried with 1.0.1) browse-url-chrome Chrome 47.0.2526.111 browse-url-chromium Chromium 3.0 browse-url-epiphany GNOME Web (Epiphany) Don't know browse-url-w3 w3 0 browse-url-text-* Any text browser 0 browse-url-generic arbitrary browse-url-default-windows-browser MS-Windows browser browse-url-default-macosx-browser macOS browser browse-url-xdg-open freedesktop.org xdg-open browse-url-kde KDE konqueror (kfm) browse-url-elinks Elinks Don't know (tried with 0.12.GIT) eww-browse-url Emacs Web Wowser Browsers can cache Web pages so it may be necessary to tell them to reload the current page if it has changed (e.g., if you have edited it). There is currently no perfect automatic solution to this. This package generalizes function html-previewer-process in Marc Andreessen's html-mode (LCD modes/html-mode.el.Z). See also the ffap.el package. The huge hyperbole package also contains similar functions. Usage To display the URL at or before point: M-x browse-url-at-point RET or, similarly but with the opportunity to edit the URL extracted from the buffer, use: M-x browse-url To display a URL by shift-clicking on it, put this in your init file: (global-set-key [S-mouse-2] 'browse-url-at-mouse) (Note that using Shift-mouse-1 is not desirable because that event has a standard meaning in Emacs.) To display the current buffer in a web browser: M-x browse-url-of-buffer RET To display the current region in a web browser: M-x browse-url-of-region RET In Dired, to display the file named on the current line: M-x browse-url-of-dired-file RET Customization (~/.emacs) To see what variables are available for customization, type `M-x set-variable browse-url TAB'. Better, use `M-x customize-group browse-url'. Bind the browse-url commands to keys with the `C-c C-z' prefix (as used by html-helper-mode): (global-set-key "\C-c\C-z." 'browse-url-at-point) (global-set-key "\C-c\C-zb" 'browse-url-of-buffer) (global-set-key "\C-c\C-zr" 'browse-url-of-region) (global-set-key "\C-c\C-zu" 'browse-url) (global-set-key "\C-c\C-zv" 'browse-url-of-file) (add-hook 'dired-mode-hook (lambda () (local-set-key "\C-c\C-zf" 'browse-url-of-dired-file))) Browse URLs in mail messages under RMAIL by clicking mouse-2: (add-hook 'rmail-mode-hook (lambda () ; rmail-mode startup (define-key rmail-mode-map [mouse-2] 'browse-url-at-mouse))) Alternatively, add `goto-address' to `rmail-show-message-hook'. Gnus provides a standard feature to activate URLs in article buffers for invocation of browse-url. Use the Emacs w3 browser when not running under X11: (or (eq window-system 'x) (setq browse-url-browser-function 'browse-url-w3)) To always save modified buffers before displaying the file in a browser: (setq browse-url-save-file t) To invoke different browsers/tools for different URLs, customize `browse-url-handlers'. In earlier versions of Emacs, the same could be done by setting `browse-url-browser-function' to an alist but this usage is deprecated now. All browser functions provided by here have a `browse-url-browser-kind' symbol property set to either `internal' or `external' which determines if they browse the given URL inside Emacs or spawn an external application with it. Some parts of Emacs make use of that, e.g., when an URL is dragged into Emacs, it is not sensible to invoke an external browser with it, so here only internal browsers are considered. Therefore, it is advised to put that property also on custom browser functions. (function-put 'my-browse-url-in-emacs 'browse-url-browser-kind 'internal) (function-put 'my-browse-url-externally 'browse-url-browser-kind 'external)