14
|
1 ;;; w3-speak.el,v --- Emacs-W3 speech interface
|
|
2 ;; Author: wmperry
|
|
3 ;; Original author: William Perry --<wmperry@cs.indiana.edu>
|
|
4 ;; Cloned from emacspeak-w3.el
|
|
5 ;; Created: 1996/10/16 20:56:40
|
|
6 ;; Version: 1.14
|
0
|
7 ;; Keywords: hypermedia, speech
|
14
|
8
|
2
|
9 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
14
|
10 ;;; Copyright (c) 1996 by T.V. Raman (raman@adobe.com)
|
16
|
11 ;;; Copyright (c) 1996, 1997 by William M. Perry (wmperry@spry.com)
|
|
12 ;;; Copyright (c) 1997 Free Software Foundation, Inc.
|
0
|
13 ;;;
|
|
14 ;;; This file is not part of GNU Emacs, but the same permissions apply.
|
|
15 ;;;
|
|
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.
|
|
20 ;;;
|
|
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.
|
|
25 ;;;
|
|
26 ;;; You should have received a copy of the GNU General Public License
|
14
|
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.
|
0
|
30 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
31
|
|
32 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
33 ;;; A replacement module for emacspeak-w3 that uses all the new functionality
|
|
34 ;;; of Emacs-W3 3.0.
|
|
35 ;;;
|
|
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. :)
|
14
|
39 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
2
|
40
|
14
|
41 ;;; This conforms to http://www4.inria.fr/speech2.html
|
0
|
42
|
|
43 (require 'widget)
|
|
44 (require 'w3-forms)
|
|
45 (require 'advice)
|
|
46 ;; This condition-case needs to be here or it completely chokes
|
|
47 ;; byte-compilation for people who do not have Emacspeak installed.
|
|
48 ;; *sigh*
|
|
49 (condition-case ()
|
|
50 (progn
|
|
51 (require 'emacspeak)
|
|
52 (require 'dtk-voices)
|
|
53 (require 'emacspeak-speak)
|
|
54 (require 'emacspeak-sounds)
|
|
55 (eval-when (compile)
|
14
|
56 (require 'emacspeak-fix-interactive)))
|
0
|
57 (error (message "Emacspeak not found - speech will not work.")))
|
|
58
|
|
59
|
14
|
60 ;;{{{ speaking form fields
|
0
|
61
|
|
62 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
63 ;;; Now for the guts
|
|
64 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
65 (defun w3-speak-summarize-form-field ()
|
|
66 "Summarizes field under point if any."
|
16
|
67 (let ((widget (widget-at (point))))
|
|
68 (and widget (w3-form-summarize-field widget))))
|
2
|
69
|
0
|
70 ;;}}}
|
|
71
|
|
72 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
73 ;;; Movement notification
|
|
74 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
16
|
75 (defadvice w3-widget-forward (after emacspeak pre act comp)
|
|
76 (when (interactive-p)
|
|
77 (emacspeak-auditory-icon 'large-movement)
|
|
78 (emacspeak-widget-summarize (emacspeak-widget-at (point )))))
|
|
79
|
|
80
|
|
81 (defadvice w3-widget-backward (after emacspeak pre act comp)
|
|
82 (when (interactive-p)
|
|
83 (emacspeak-auditory-icon 'large-movement)
|
|
84 (emacspeak-widget-summarize (emacspeak-widget-at (point )))))
|
|
85
|
0
|
86 (defadvice w3-scroll-up (after emacspeak pre act comp)
|
|
87 "Provide auditory feedback"
|
|
88 (when (interactive-p)
|
14
|
89 (let ((start (point )))
|
|
90 (emacspeak-auditory-icon 'scroll)
|
|
91 (save-excursion
|
|
92 (forward-line (window-height))
|
|
93 (emacspeak-speak-region start (point ))))))
|
0
|
94
|
|
95 (defadvice w3-follow-link (around emacspeak pre act)
|
|
96 "Provide feedback on what you did. "
|
14
|
97 (let ((data (emacspeak-w3-extract-form-field-information))
|
|
98 (form-field-p nil)
|
|
99 (this-zone nil)
|
|
100 (opoint nil))
|
0
|
101 (if data
|
14
|
102 (setq form-field-p t
|
|
103 opoint (point)))
|
0
|
104 ad-do-it
|
|
105 (when form-field-p
|
|
106 (w3-speak-summarize-form-field)
|
|
107 (case (w3-form-element-type data)
|
14
|
108 ((radio checkbox)
|
0
|
109 (emacspeak-auditory-icon 'button))
|
|
110 ;; fill in any others here
|
|
111 (otherwise
|
|
112 nil)))
|
14
|
113 ad-return-value))
|
0
|
114
|
|
115 (defadvice w3-revert-form (after emacspeak pre act)
|
|
116 "Announce that you cleared the form. "
|
|
117 (dtk-speak "Cleared the form. "))
|
|
118
|
|
119 (defadvice w3-finish-text-entry (after emacspeak pre act )
|
|
120 "Announce what the field was set to."
|
|
121 (when (interactive-p)
|
|
122 (w3-speak-summarize-form-field)))
|
|
123
|
|
124 (defadvice w3-start-of-document (after emacspeak pre act)
|
|
125 "Produce an auditory icon. Also speak the first line. "
|
|
126 (when (interactive-p)
|
|
127 (emacspeak-speak-line)
|
|
128 (emacspeak-auditory-icon 'large-movement)))
|
|
129
|
|
130 (defadvice w3-end-of-document (after emacspeak pre act)
|
14
|
131 "Produce an auditory icon. Also speak the first line."
|
0
|
132 (when (interactive-p)
|
|
133 (emacspeak-speak-line)
|
|
134 (emacspeak-auditory-icon 'large-movement)))
|
|
135
|
|
136 (defadvice w3-goto-last-buffer (after emacspeak pre act)
|
|
137 "Speak the modeline so I know where I am."
|
|
138 (when (interactive-p)
|
|
139 (emacspeak-auditory-icon 'select-object)
|
|
140 (emacspeak-speak-mode-line)))
|
|
141
|
|
142 (defadvice w3-quit (after emacspeak pre act)
|
|
143 "Speak the mode line of the new buffer."
|
|
144 (when (interactive-p)
|
|
145 (emacspeak-auditory-icon 'close-object)
|
|
146 (emacspeak-speak-mode-line)))
|
|
147
|
|
148 (defadvice w3-fetch (around emacspeak act comp )
|
14
|
149 "First produce an auditory icon to indicate retrieval.
|
|
150 After retrieval,
|
|
151 set voice-lock-mode to t after displaying the buffer,
|
|
152 and then speak the mode-line. "
|
0
|
153 (declare (special dtk-punctuation-mode))
|
14
|
154 (emacspeak-auditory-icon 'select-object)
|
|
155 ad-do-it)
|
0
|
156
|
|
157 (defun w3-speak-mode-hook ()
|
|
158 (set (make-local-variable 'voice-lock-mode) t)
|
|
159 (setq dtk-punctuation-mode "some")
|
|
160 (emacspeak-auditory-icon 'open-object)
|
|
161 (emacspeak-speak-mode-line))
|
|
162
|
|
163 ;;; This is really the only function you should need to call unless
|
|
164 ;;; you are adding functionality.
|
|
165 (defun w3-speak-use-voice-locking (&optional arg)
|
|
166 "Tells w3 to start using voice locking.
|
|
167 This is done by setting the w3 variables so that anchors etc are not marked by
|
|
168 delimiters. We then turn on voice-lock-mode.
|
|
169 Interactive prefix arg does the opposite. "
|
|
170 (interactive "P")
|
22
|
171 (declare (special w3-echo-link))
|
0
|
172 (setq w3-echo-link 'text)
|
|
173 (if arg
|
22
|
174 (remove-hook 'w3-mode-hook 'w3-speak-mode-hook)
|
0
|
175 (add-hook 'w3-mode-hook 'w3-speak-mode-hook)))
|
|
176
|
14
|
177 (defun w3-speak-browse-page ()
|
|
178 "Browse a WWW page"
|
|
179 (interactive)
|
|
180 (emacspeak-audio-annotate-paragraphs)
|
|
181 (emacspeak-execute-repeatedly 'forward-paragraph))
|
|
182
|
|
183 (declaim (special w3-mode-map))
|
|
184 (define-key w3-mode-map "." 'w3-speak-browse-page)
|
2
|
185
|
14
|
186 (defvar url-speak-last-progress-indication 0
|
|
187 "Caches when we last produced a progress auditory icon")
|
2
|
188
|
14
|
189 (defadvice url-lazy-message (around emacspeak pre act)
|
|
190 "Provide pleasant auditory feedback about progress"
|
|
191 (declare (special url-speak-last-progress-indication ))
|
|
192 (let ((now (nth 1 (current-time))))
|
|
193 (when (> now
|
|
194 (+ 3 url-speak-last-progress-indication))
|
|
195 (setq url-speak-last-progress-indication now)
|
|
196 (emacspeak-auditory-icon 'progress))))
|
|
197
|
0
|
198 (provide 'w3-speak)
|