1 ;;; w3-speak.el,v --- Emacs-W3 speech interface
3 ;; Original author: William Perry --<wmperry@cs.indiana.edu>
4 ;; Cloned from emacspeak-w3.el
5 ;; Created: 1996/10/16 20:56:40
7 ;; Keywords: hypermedia, speech
9 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
10 ;;; Copyright (c) 1996 by T.V. Raman (raman@adobe.com)
11 ;;; Copyright (c) 1996, 1997 by William M. Perry (wmperry@spry.com)
12 ;;; Copyright (c) 1997, 1998 Free Software Foundation, Inc.
14 ;;; This file is not part of GNU Emacs, but the same permissions apply.
16 ;;; GNU Emacs is free software; you can redistribute it and/or modify
17 ;;; it under the terms of the GNU General Public License as published by
18 ;;; the Free Software Foundation; either version 2, or (at your option)
19 ;;; any later version.
21 ;;; GNU Emacs is distributed in the hope that it will be useful,
22 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
23 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 ;;; GNU General Public License for more details.
26 ;;; You should have received a copy of the GNU General Public License
27 ;;; along with GNU Emacs; see the file COPYING. If not, write to the
28 ;;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
29 ;;; Boston, MA 02111-1307, USA.
30 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
32 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
33 ;;; A replacement module for emacspeak-w3 that uses all the new functionality
36 ;;; This file would not be possible without the help of
37 ;;; T.V. Raman (raman@adobe.com) and his continued efforts to make Emacs/W3
38 ;;; even remotely useful. :)
39 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
41 ;;; This conforms to http://www4.inria.fr/speech2.html
46 ;; This condition-case needs to be here or it completely chokes
47 ;; byte-compilation for people who do not have Emacspeak installed.
53 (require 'emacspeak-speak)
54 (require 'emacspeak-sounds)
56 (require 'emacspeak-fix-interactive)))
57 (error (message "Emacspeak not found - speech will not work.")))
60 ;;{{{ speaking form fields
62 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
64 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
65 (defun w3-speak-summarize-form-field ()
66 "Summarizes field under point if any."
67 (let ((widget (widget-at (point))))
68 (and widget (w3-form-summarize-field widget))))
72 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
73 ;;; Movement notification
74 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
75 (defadvice w3-widget-forward (after emacspeak pre act comp)
77 (emacspeak-auditory-icon 'large-movement)
78 (emacspeak-widget-summarize (widget-at (point )))))
80 (defadvice w3-widget-backward (after emacspeak pre act comp)
82 (emacspeak-auditory-icon 'large-movement)
83 (emacspeak-widget-summarize (widget-at (point )))))
85 (defadvice w3-scroll-up (after emacspeak pre act comp)
86 "Provide auditory feedback"
88 (let ((start (point )))
89 (emacspeak-auditory-icon 'scroll)
91 (forward-line (window-height))
92 (emacspeak-speak-region start (point ))))))
94 (defadvice w3-revert-form (after emacspeak pre act)
95 "Announce that you cleared the form. "
96 (dtk-speak "Cleared the form. "))
98 (defadvice w3-finish-text-entry (after emacspeak pre act )
99 "Announce what the field was set to."
100 (when (interactive-p)
101 (w3-speak-summarize-form-field)))
103 (defadvice w3-start-of-document (after emacspeak pre act)
104 "Produce an auditory icon. Also speak the first line. "
105 (when (interactive-p)
106 (emacspeak-speak-line)
107 (emacspeak-auditory-icon 'large-movement)))
109 (defadvice w3-end-of-document (after emacspeak pre act)
110 "Produce an auditory icon. Also speak the first line."
111 (when (interactive-p)
112 (emacspeak-speak-line)
113 (emacspeak-auditory-icon 'large-movement)))
115 (defadvice w3-goto-last-buffer (after emacspeak pre act)
116 "Speak the modeline so I know where I am."
117 (when (interactive-p)
118 (emacspeak-auditory-icon 'select-object)
119 (emacspeak-speak-mode-line)))
121 (defadvice w3-quit (after emacspeak pre act)
122 "Speak the mode line of the new buffer."
123 (when (interactive-p)
124 (emacspeak-auditory-icon 'close-object)
125 (emacspeak-speak-mode-line)))
127 (defadvice w3-fetch (around emacspeak act comp )
128 "First produce an auditory icon to indicate retrieval.
130 set voice-lock-mode to t after displaying the buffer,
131 and then speak the mode-line. "
132 (declare (special dtk-punctuation-mode))
133 (emacspeak-auditory-icon 'select-object)
136 (defun w3-speak-mode-hook ()
137 (set (make-local-variable 'voice-lock-mode) t)
138 (setq dtk-punctuation-mode "some")
139 (emacspeak-auditory-icon 'open-object)
140 (emacspeak-speak-mode-line))
142 ;;; This is really the only function you should need to call unless
143 ;;; you are adding functionality.
144 (defun w3-speak-use-voice-locking (&optional arg)
145 "Tells w3 to start using voice locking.
146 This is done by setting the w3 variables so that anchors etc are not marked by
147 delimiters. We then turn on voice-lock-mode.
148 Interactive prefix arg does the opposite. "
150 (declare (special w3-echo-link))
151 (setq w3-echo-link 'text)
153 (remove-hook 'w3-mode-hook 'w3-speak-mode-hook)
154 (add-hook 'w3-mode-hook 'w3-speak-mode-hook)))
156 (defun w3-speak-browse-page ()
159 (emacspeak-audio-annotate-paragraphs)
160 (emacspeak-execute-repeatedly 'forward-paragraph))
162 (declaim (special w3-mode-map))
163 (define-key w3-mode-map "." 'w3-speak-browse-page)
165 (defvar url-speak-last-progress-indication 0
166 "Caches when we last produced a progress auditory icon")
168 (defadvice url-lazy-message (around emacspeak pre act)
169 "Provide pleasant auditory feedback about progress"
170 (declare (special url-speak-last-progress-indication ))
171 (let ((now (nth 1 (current-time))))
173 (+ 3 url-speak-last-progress-indication))
174 (setq url-speak-last-progress-indication now)
175 (apply 'message (ad-get-args 0))
176 (emacspeak-auditory-icon 'progress))))