emacs/w3 is a web browser (now obsolete and replaced by EWW) written completely in emacs lisp. It has some really nice features applicable to the emacspeak community such as the ability to navigate tables and support for the w3c’s aural cascading stylesheets.
As mentioned above, the ability to navigate tables is a super help. emacs/w3 also has support for cascading stylesheets. This allows incredible control of voices used for what would normally be visual attributes of the text such as bold, italics, preformatted text and the like.
Another advantage of emacs/w3 is that it is written completely in emacs lisp. With some effort, emacs/w3 is very customizable and quite extendable.
Rendering can be slow. Sometimes it can be painfully,
excruciatingly slow. That might be a slight exaggeration, but
slow it is. This is because it is written in lisp... something
I mentioned just above as a strength. It is a trade-off, but
one that some see as worth it. There are, however, some things
that can be done to speed up the browsing process. See See
emacspeak-w3-xsl-transform
, for more
information.
Another disadvantage is that emacs/w3 chokes on some pages. Sometimes it gives error messages and doesn’t display anything. Sometimes it does this to some people and doesn’t do it to others as we saw on the emacspeak mailing list a short time ago. Sometimes it gives error messages and renders the page anyway.
One other major annoyance of emacs/w3 is that sometimes it simply stops doing anything while rendering a page. There is a way I have found to get around this. I hit C-g. I usually wait five to ten seconds and then simply quit, using C-g. Not always, but usually, the page has already completed downloading and is being rendered and it therefore is not a problem.
emacs/w3 also has no bookmark functionality. This can be remedied in several ways. One simple way, mentioned below, is to use the emacs package bmk-mgr. Another way is to use org mode with remember which is the method used by Dr. Raman, the author of emacspeak. See See bmk-mgr, later in this manual, for more information.
History back and next in the browser also seem to be broken but this is not generally a problem for me as I never look back.
Many functions for efficient navigation of the internet are native to emacs/w3. Some of the most useful functions are listed below
Unlike emacs-w3m, the information presented by describe-mode
is very complete, but a little
terse. All the function names are listed and asking for help on
particular functions works well. That being said, use this list
to augment, not replace, the built-in help that is available in
emacs.
C-f will open a new buffer containing the cell point is in. In most instances, this works very well. Imagine you are looking at a page that is divided into 4 distinct areas: a cell at the top of the page that contains a banner and some navigation, and a “body” area that is divided into three sections consisting of more navigation, an article, and advertisement. If point is in the main article cell, using C-f will open another buffer that contains only the text of that cell, the article you are interested in.
One caveat is that this does not always work as advertised. Sometimes the leftmost character of each line is missing. At least it makes for interesting reading. Usually when I have this problem I simply exit that buffer and linearize the tables in the original page.
The m key executes a very useful command. It will complete a link on the page. Imagine that you are reading through a document and you hear a link that you need to visit. You could tab through all the links until you hear the one you want or you could hit the m key and enter the link text at the prompt. Completion is available and it is not case-sensitive. Efficient, no?
The period in a cell will speak the contents of that particular cell. This command is, in my opinion, most useful when navigating tables with cells that have only one paragraph or less. I tend to not read whole articles in this manner because, inevitably, someone will interrupt me and I will lose my place.
The equals key, while in a table cell will give you the cell information. It tells you the row and column position, the size of the table, and at what nesting level the table is.
The pipe key, is used to read the table column. As this command seems to read the rectangle the column is in, this command is most useful when used in a table where there is no column spanning, i.e. all rows and columns are uniform.
Here is a list of table navigation commands:
As you can see, table navigation in w3 can be easy and fun.
An incredible amount of work has been done by the emacspeak community to make emacs/w3 accessible to those with visual impairments. Here is an explanation of some of those functions.
The command C-t will toggle the visibility of table borders. This command might be useful where you want to hear all punctuation symbols on a page but the table characters get in the way.
The quote key will execute a command that allows you to skim the contents of the buffer. it will read the page, paragraph-by-paragraph, pausing between paragraphs to prompt you to move on by pressing SPACE. If you hit SPACE in the middle of a paragraph, it skips to the next paragraph.
Another skimming command is bound to the z key. This will allow you to zip through web pages by logical blocks such as div, paragraph, and table tags.
Using the imenu facilities is another way of skimming the document and getting to the information you desire. imenu works especially well for well-structured documents. The first thing that need be done is to copy the w3-imenu.el file from the contrib directory of the w3 directory to somewhere in your load path. I am using the cvs version of w3 and my w3 directory is under /home/rdc/sourceforge. The easiest thing to do is probably to do an M-x locate and search for w3-imenu.el to see where it is. After locating the file, move it into your load path. In my case I have it under /home/rdc/share/emacs/site-lisp/.
There are two ways to use the imenu facilities: automatically and manually. Since I do not use imenu on every site, I prefer to invoke it manually to save the time required to build the index.
Once things are in place, invoke imenu with the j key. This will ask you for an index position. Hitting TAB will give you a list of the possible index positions. Another way of navigating the document would now be to use the keys M-n and M-p to go to the next and previous index positions. Note that you have to build an index for a page before you can use these commands.
Cap A and cap R serve the same function. Cap A browses the Atom feed at point and cap R browses the rss feed at point. This is useful to sample the feed, so to speak, before going through the trouble of configuring your feed reader to fetch the feed. It might also be useful to grab the headlines from a page and present them in a more concise, readable format. If using the sort-tables xsl transform, there will be a link at the top of the page if there is an rss feed available. See See emacspeak atom and emacspeak rss, for more information.
Google provides many useful tools for web surfers. The following commands are useful to access much google goodness.
Cap C extracts the current page from the google cache. With a prefix argument it will extract the link under point. This is useful for those times when a particular site is down... maybe it is in the cache... maybe it is not. It can also be used for when particular pages are removed from a site like in the case of a government conspiracy. Are we at war with Eurasia or East Asia?
The slash key will search google for pages similar to the current page.
The command g will do a google search restricted to the site of the document.
The l command googles for who links to this page.
The command t runs the url under point through the google transcoder. This is useful for sites that are heavy on the use of tables and the xsl transforms are not helpful. It also works on some sites that use javascript to go to the next page in the story, such as Reuters. Using a prefix argument with this command will untranscode the url under point for pages that are currently transcoded.
Cap T will jump to the first occurrence of the title in the document. Multiple consecutive executions of this command will jump to further occurrences. This command is probably one of the most useful timesavers while web browsing.
M-s jumps to the “submit” button for the form you are editing.
M-r plays the media stream at point with the default media player.
The y command will rewrite the url of the url under point. This is useful for those sites you frequent. Often, sites that have printer friendly content have a specific way in which the url is written. For The first time you run this command in a particular buffer you are prompted for a pattern to use. The pattern is in the form of
‘("from string" "to string")’
The opening paren is supplied. Remember to quote the strings or you will get an error. From this point on, until you kill the buffer in which you wrote the rule, hitting y on a link will use this rewrite rule to visit the page. If you mistyped the rule, providing a numeric argument will allow you to rewrite the rewrite rule. I love alliteration.
Saving the best for last, e is the xsl map prefix. As I mentioned in the section on emacs-w3m, xsl transforms are some powerful magic that takes a web page and transforms it in some way. Linearizing tables is a good example, and the one I use most often.
The keystroke e a prompts for an xsl transform to apply to the current page. If you know the name of the particular transform you want you can use tab completion to select it. Otherwise, you can hit TAB to get a buffer that contains the list of choices.
If you know that you want a particular transform done automatically you can use the command e s to select a transform and then e o to turn xslt on (the same command will turn xslt off). Then, every page opened from that point on will have the transform applied.
There is the variable emacspeak-w3-xsl-transform
that can be set via
the usual methods. This variable specifies a transform to use
before displaying a web page. There is an advantage to turning
on xsl transforms all the time. If you use the identity.xsl, the linearize-tables.xsl or the sort-tables.xsl it can actually speed up
rendering of the page. This is because the transforms provide
clean and balanced html to the renderer. Additionally, using
sort-tables.xsl or linearize-tables.xsl will provide a little more
boost as rendering nested tables is particularly difficult for
a web browser.
Sometimes it is just easier to read the printer friendly version of a story instead of having to linearize the tables and search for the content. Also, some sites, like the New York Times, I believe, make you navigate several pages to read the whole story, but if you select a “Print this story” link you can read the entire story on one page formatted without a lot of the cruft on the normal page. This is where the e Cap P command comes in. It will extract all the print streams from the current document.
Closely associated commands are e r and e Cap R which extract the media streams from the current page and from the link under point, respectively.
The command e y is another command that is useful for frequented sites. It does the same as the y command above in that it rewrites the url at point and follows it. In addition, it filters the output by a particular CSS class.
The command e e does more magic to the url at point. It processes the url using a specific function. For example, it can be used in retrieving radio content from the BBC. If you execute C-e u and type in BBC Channel On Demand or use tab completion to get the same, and then type in radio4 you will be presented with a page containing a plethora of links to other pages containing information about particular shows. On these pages there is, somewhere, a link that will play the program. If you hit enter on one of the links on the first page, you will be taken to one of these description pages. By using the e e command on a link you cut out this middle step and proceed directly to playing the program you are interested in.
If there is no executor defined for a current buffer,
hitting TAB after e
e will give you a list of possibilities to choose from.
One nice feature of this function is that it can be used for
any function. If you cannot remember the keystroke that will
play the url under point in emacspeak-m-player
, but you know what it is
called, you can hit e e and then enter
the name of the function. Nice.
The e f command will run the current page through an XPath filter and return the results. For more information on XPath, see http://en.wikipedia.org/wiki/XPath. If you wanted to see only the links on a page, when prompted enter //a and you will be returned every link on the page. If you wanted to see only the contents of “p” tags, you would enter //p. This can be useful for many things, form elements included. Giving this command a prefix argument will reverse the filter, giving you everything but the content of the specified tag.
A related command can be invoked with the e p keystroke. This command does the same as the filter above but works on the url under point.
As I mentioned above, using C-g when it seems the browser is not responding will often display the page with no ill effects. Your mileage may vary. Taxes, tags and title are extra.
Also mentioned above is the use of sort-tables or identity as an xsl transform to speed up the rendering of pages. Every little bit helps.
Another useful tip is the use of the k key. This key will place the current url in the kill-ring for later yanking. If a page will not render correctly, using k will get the url and allow me to pass it to emacs-w3m. The counterpart to this command, cap K puts the url under point in the kill-ring.