     [file docstyle.texi not included]

EWW
***

This file documents the GNU Emacs Web Wowser (EWW) package.

Copyright © 2014--2024 Free Software Foundation, Inc.

     Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, with the Front-Cover Texts being ``A GNU Manual,'' and with the Back-Cover Texts as in (a) below.  A copy of the license is included in the section entitled ``GNU Free Documentation License.''

     (a) The FSF's Back-Cover Text is: ``You have the freedom to copy and modify this GNU manual.''

Overview
********

EWW, the Emacs Web Wowser, is a web browser for GNU Emacs that provides a simple, no-frills experience that focuses on readability. It loads, parses, and displays web pages using shr.el.  It can display images inline, if Emacs was built with image support, but there is no support for CSS or JavaScript.

To use EWW, you need to use an Emacs built with libxml2 support.

Basic Usage
***********

You can open a URL or search the web with the command M-x eww. If the input doesn't look like a URL or domain name the web will be searched via eww-search-prefix.  The default search engine is DuckDuckGo (https://duckduckgo.com).  If you want to open a file either prefix the file name with file:// or use the command M-x eww-open-file.

If you invoke eww with a prefix argument, as in C-u M-x eww, it will create a new EWW buffer instead of reusing the default one, which is normally called *eww*.

If loading the URL was successful the buffer *eww* is opened and the web page is rendered in it.  You can leave EWW by pressing q or exit the browser by calling eww-quit.  To reload the web page hit g (eww-reload).

Pressing w when point is on a link will call shr-maybe-probe-and-copy-url, which copies this link's URL to the kill ring.  If point is not on a link, pressing w calls eww-copy-page-url, which will copy the current page's URL to the kill ring instead.

The M-RET command (eww-open-in-new-buffer) opens the URL at point in a new EWW buffer, akin to opening a link in a new ``tab'' in other browsers.  When global-tab-line-mode is enabled, this buffer is displayed in the tab on the window tab line. When tab-bar-mode is enabled, a new tab is created on the frame tab bar.

The R command (eww-readable) will attempt to determine which part of the document contains the ``readable'' text, and will only display this part.  This usually gets rid of menus and the like.

The F command (eww-toggle-fonts) toggles whether to use variable-pitch fonts or not.  This sets the shr-use-fonts variable.

The M-C command (eww-toggle-colors) toggles whether to use HTML-specified colors or not.  This sets the shr-use-colors variable.

The M-I command (eww-toggle-images, capital letter i) toggles whether to display images or not.  This also sets the shr-inhibit-images variable.

A URL can be downloaded with d (eww-download).  This will download the link under point if there is one, or else the URL of the current page.  The file will be written to the directory specified by eww-download-directory (default: ~/Downloads/, if it exists; otherwise as specified by the DOWNLOAD XDG directory)).

EWW remembers the URLs you have visited to allow you to go back and forth between them.  By pressing l (eww-back-url) you go to the previous URL.  You can go forward again with r (eww-forward-url).  If you want an overview of your browsing history press H (eww-list-histories) to open the history buffer *eww history*.  The history is lost when EWW is quit. If you want to remember websites you can use bookmarks.

Along with the URLs visited, EWW also remembers both the rendered page (as it appears in the buffer) and its source.  This can take a considerable amount of memory, so EWW discards the history entries to keep their number within a set limit, as specified by eww-history-limit; the default being 50.  This variable could also be set to nil to allow for the history list to grow indefinitely.

PDFs are viewed inline, by default, with doc-view-mode, but this can be customized by using the mailcap (see mailcap (Emacs MIME Manual)) mechanism, in particular mailcap-mime-data.

EWW allows you to bookmark URLs.  Simply hit b (eww-add-bookmark) to store a bookmark for the current website. You can view stored bookmarks with B (eww-list-bookmarks).  This will open the bookmark buffer *eww bookmarks*.

To get summary of currently opened EWW buffers, press S (eww-list-buffers).  The *eww buffers* buffer allows you to quickly kill, flip through and switch to specific EWW buffer.  To switch EWW buffers through a minibuffer prompt, press s (eww-switch-to-buffer).

Although EWW and shr.el do their best to render webpages in GNU Emacs some websites use features which can not be properly represented or are not implemented (e.g., JavaScript).  If you have trouble viewing a website with EWW then hit & (eww-browse-with-external-browser) inside the EWW buffer to open the website in the external browser specified by browse-url-secondary-browser-function.  Some content types, such as video or audio content, do not make sense to display in GNU Emacs at all.  You can tell EWW to open specific content automatically in an external browser by customizing eww-use-external-browser-for-content-type.

Advanced
********

EWW normally uses url-retrieve to fetch the HTML before rendering it, and url-retrieve-synchronously when the value of eww-retrieve-command is sync.  It can sometimes be convenient to use an external program to do this, and eww-retrieve-command should then be a list that specifies a command and the parameters.  For instance, to use the Chromium browser, you could say something like this:

     (setq eww-retrieve-command
           '("chromium" "--headless" "--dump-dom"))

The command should return the HTML on standard output, and the data should use UTF-8 as the charset.

You can view the source of a website with v (eww-view-source).  This will open a new buffer *eww-source* and insert the source.  The buffer will be set to html-mode if available.

EWW handles cookies through the url package (url) package.  You can list existing cookies with C (url-cookie-list).  For details about the Cookie handling see Cookies (url).

Many HTML pages have images embedded in them, and EWW will download most of these by default.  When fetching images, cookies can be sent and received, and these can be used to track users.  To control when to send cookies when retrieving these images, the shr-cookie-policy variable can be used.  The default value, same-origin, means that EWW will only send cookies when fetching images that originate from the same source as the HTML page.  nil means ``never send cookies when retrieving these images'' and t means ``always send cookies when retrieving these images''.

When following links in EWW, URLs that match the eww-use-browse-url regexp will be passed to browse-url instead of EWW handling them itself.  The action can be further customized by altering browse-url-handlers.

The header line of the EWW buffer can be changed by customizing eww-header-line-format.  The format replaces %t with the title of the website and %u with the URL.

The D command (eww-toggle-paragraph-direction) toggles the paragraphs direction between left-to-right and right-to-left text.  This can be useful on web pages that display right-to-left test (like Arabic and Hebrew), but where the web pages don't explicitly state the directionality.

Loading random images from the web can be problematic due to their size or content.  By customizing shr-max-image-proportion you can set the maximal image proportion in relation to the window they are displayed in.  E.g., 0.7 means an image is allowed to take up 70% of the width and height.  If Emacs supports image scaling, then larger images are scaled down.  You can block specific images completely by customizing shr-blocked-images.

You can control image display by customizing shr-inhibit-images.  If this variable is nil, display the ``ALT'' text of images instead.

EWW (or rather its HTML renderer shr) uses the colors declared in the HTML page, but adjusts them if needed to keep a certain minimum contrast.  If that is still too low for you, you can customize the variables shr-color-visible-distance-min and shr-color-visible-luminance-min to get a better contrast.

By default, the max width used when rendering is 120 characters, but this can be adjusted by changing the shr-max-width variable. If a specified width is preferred no matter what the width of the window is, shr-width can be set.  If both variables are nil, the window width will always be used.

The HTML attribute aria-hidden is meant to tell screen readers to ignore a tag's contents.  You can customize the variable shr-discard-aria-hidden to tell shr to ignore such tags. This can be useful when using a screen reader on the output of shr (e.g., on EWW buffer text).  It can be useful even when not using a screen reader, since web authors often put this attribute on non-essential decorative elements.

In addition to maintaining the history at run-time, EWW will also save the partial state of its buffers (the URIs and the titles of the pages visited) in the desktop file if one is used.  See Saving Emacs Sessions (The GNU Emacs Manual).

EWW history may sensibly contain multiple entries for the same page URI.  At run-time, these entries may still have different associated point positions or the actual Web page contents. The latter, however, tend to be overly large to preserve in the desktop file, so they get omitted, thus rendering the respective entries entirely equivalent.  By default, such duplicate entries are not saved.  Setting eww-desktop-remove-duplicates to nil will force EWW to save them anyway.

Restoring EWW buffers' contents may prove to take too long to finish.  When the eww-restore-desktop variable is set to nil (the default), EWW will not try to reload the last visited Web page when the buffer is restored from the desktop file, thus allowing for faster Emacs start-up times.  When set to t, restoring the buffers will also initiate the reloading of such pages.

The EWW buffer restored from the desktop file but not yet reloaded will contain a prompt, as specified by the eww-restore-reload-prompt variable.  The value of this variable will be passed through substitute-command-keys upon each use, thus allowing for the use of the usual substitutions, such as \[eww-reload] for the current key binding of the eww-reload command.

If the eww-auto-rename-buffer user option is non-nil, EWW buffers will be renamed after rendering a document.  If this is title, rename based on the title of the document.  If this is url, rename based on the URL of the document.  This can also be a user-defined function, which is called with no parameters in the EWW buffer, and should return a string.

EWW runs the URLs through eww-url-transformers before using them.  This user option is a list of functions, where each function is called with the URL as the parameter, and should return the (possibly) transformed URL.  By default, this variable contains eww-remove-tracking, which removes the common utm_ trackers from links.

If Emacs has been built with xwidget support, EWW can use that to display <video> elements.  However, this support is still experimental, and on some systems doesn't work (and even worse) may crash your Emacs, so this feature is off by default.  If you wish to switch it on, set shr-use-xwidgets-for-media to a non-nil value.

Command Line Usage
******************

It can be convenient to start eww directly from the command line.  The eww-browse function can be used for that:

     emacs -f eww-browse https://gnu.org

This also allows registering Emacs as a MIME handler for the "text/x-uri" media type.  How to do that varies between systems, but typically you'd register the handler to call "emacs -f eww-browse %u".

History and Acknowledgments
***************************

EWW was originally written by Lars Ingebrigtsen, known for his work on Gnus.  He started writing an Emacs HTML rendering library, shr.el, to read blogs in Gnus.  He eventually added a web browser front end and HTML form support.  Which resulted in EWW, the Emacs Web Wowser.  EWW was announced on 16 June 2013: https://lars.ingebrigtsen.no/2013/06/16/eww/.

EWW was then moved from the Gnus repository to GNU Emacs and several developers started contributing to it as well.

GNU Free Documentation License
******************************

     [file doclicense.texi not included]

Variable Index
**************

After eww has rendered the data in the buffer, eww-after-render-hook is called.  It can be used to alter the contents, for instance.