Beautiful Code [335]
(calendar-date-string (calendar-cursor-to-date t))
The emacspeak-calendar-speak-date function is called from advice definitions attached to all calendar navigation functions. Here is the advice definition for function calendar-forward-week:
(defadvice calendar-forward-week (after emacspeak pre act)
"Speak the date. "
(when (interactive-p) (emacspeak-speak-calendar-date )
(emacspeak-auditory-icon 'large-movement)))
This is an after advice, because we want the spoken feedback to be produced after the original navigation command has done its work.
The body of the advice definition first calls the function emacspeak-calendar-speak-date to speak the date under the cursor; next, it calls emacspeak-auditory-icon to produce a short sound indicating that we have successfully moved.
Emacspeak: The Complete Audio Desktop > Painless Access to Online Information
31.3. Painless Access to Online Information
With all the necessary affordances to generate rich auditory output in place, speech-enabling Emacs applications using Emacs Lisp's advice facility requires surprisingly small amounts of specialized code. With the TTS layer and the Emacspeak core handling the complex details of producing good quality output, the speech-enabling extensions focus purely on the specialized semantics of individual applications; this leads to simple and consequently beautiful code. This section illustrates the concept with a few choice examples taken from Emacspeak's rich suite of information access tools.
Right around the time I started Emacspeak, a far more profound revolution was taking place in the world of computing: the World Wide Web went from being a tool for academic research to a mainstream forum for everyday tasks. This was 1994, when writing a browser was still a comparatively easy task. The complexity that has been progressively added to the Web in the subsequent 12 years often tends to obscure the fact that the Web is still a fundamentally simple design where:
Content creators publish web resources addressable via URIs.
URI-addressable content is retrievable via open protocols.
Retrieved content is in HTML, a well-understood markup language.
Notice that the basic architecture just sketched out says little to nothing about how the content is made available to the end user. The mid-1990s saw the Web move toward increasingly complex visual interaction. The commercial Web with its penchant for flashy visual interaction increasingly moved away from the simple data-oriented interaction that had characterized early web sites. By 1998, I found that the Web had a lot of useful interactive sites; to my dismay, I also found that I was using progressively fewer of these sites because of the time it took to complete tasks when using spoken output.
This led me to create a suite of web-oriented tools within Emacspeak that went back to the basics of web interaction. Emacs was already capable of rendering simple HTML into interactive hypertext documents. As the Web became complex, Emacspeak acquired a collection of interaction wizards built on top of Emacs' HTML rendering capability that progressively factored out the complexity of web interaction to create an auditory interface that allowed the user to quickly and painlessly listen to desired information.
31.3.1. Basic HTML with Emacs W3 and Aural CSS
Emacs W3 is a bare-bones web browser first implemented in the mid-1990s. Emacs W3 implemented CSS (Cascading Style Sheets) early on, and this was the basis of the first Aural CSS implementation, which was released at the time I wrote the Aural CSS draft in February 1996. Emacspeak speech-enables Emacs W3 via the emacspeak-w3 module, which implements the following extensions:
An aural media section in the default stylesheet for Aural CSS.
advice added to all interactive commands to produce auditory feedback.
Special patterns to recognize and silence decorative images on web pages.
Aural rendering of HTML