Mercurial > hg > xemacs-beta
comparison lisp/w3/w3-speak.el @ 2:ac2d302a0011 r19-15b2
Import from CVS: tag r19-15b2
author | cvs |
---|---|
date | Mon, 13 Aug 2007 08:46:35 +0200 |
parents | 376386a54a3c |
children | 9ee227acff29 |
comparison
equal
deleted
inserted
replaced
1:c0c6a60d29db | 2:ac2d302a0011 |
---|---|
1 ;;; w3-speak.el,v --- Emacs-W3 speech interface | 1 ;;; w3-speak.el --- Emacs-W3 speech interface |
2 ;; Author: wmperry | 2 ;; Authors: wmperry and Raman |
3 ;; Created: 1996/06/03 15:53:35 | 3 ;; Created: 1996/07/09 14:08:09 |
4 ;; Version: 1.6 | 4 ;; Version: 1.4 |
5 ;; Keywords: hypermedia, speech | 5 ;; Keywords: hypermedia, speech |
6 | 6 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
7 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 7 ;;{{{ Copyright |
8 ;;; Copyright (c) 1996 by William M. Perry (wmperry@spry.com) | 8 |
9 ;;; Copyright (c) 1996 by William M. Perry (wmperry@cs.indiana.edu) | |
9 ;;; | 10 ;;; |
10 ;;; This file is not part of GNU Emacs, but the same permissions apply. | 11 ;;; This file is not part of GNU Emacs, but the same permissions apply. |
11 ;;; | 12 ;;; |
12 ;;; GNU Emacs is free software; you can redistribute it and/or modify | 13 ;;; GNU Emacs is free software; you can redistribute it and/or modify |
13 ;;; it under the terms of the GNU General Public License as published by | 14 ;;; it under the terms of the GNU General Public License as published by |
29 ;;; of Emacs-W3 3.0. | 30 ;;; of Emacs-W3 3.0. |
30 ;;; | 31 ;;; |
31 ;;; This file would not be possible without the help of | 32 ;;; This file would not be possible without the help of |
32 ;;; T.V. Raman (raman@adobe.com) and his continued efforts to make Emacs-W3 | 33 ;;; T.V. Raman (raman@adobe.com) and his continued efforts to make Emacs-W3 |
33 ;;; even remotely useful. :) | 34 ;;; even remotely useful. :) |
34 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 35 |
36 ;;}}} | |
37 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
38 ;;{{{ Required modules | |
35 | 39 |
36 (require 'widget) | 40 (require 'widget) |
37 (require 'w3-forms) | 41 (require 'w3-forms) |
38 (require 'advice) | 42 (require 'advice) |
39 | 43 |
43 | 47 |
44 (condition-case () | 48 (condition-case () |
45 (progn | 49 (progn |
46 (require 'emacspeak) | 50 (require 'emacspeak) |
47 (require 'dtk-voices) | 51 (require 'dtk-voices) |
52 (require 'dtk-css-speech) | |
48 (require 'emacspeak-speak) | 53 (require 'emacspeak-speak) |
49 (require 'emacspeak-sounds) | 54 (require 'emacspeak-sounds) |
50 (eval-when (compile) | 55 (eval-when (compile) |
51 (require 'emacspeak-fix-interactive))) | 56 (require 'emacspeak-fix-interactive))) |
52 (error (message "Emacspeak not found - speech will not work."))) | 57 (error (message "Emacspeak not found - speech will not work."))) |
53 | 58 |
59 ;;}}} | |
60 | |
54 | 61 |
55 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 62 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
56 ;;; How to get information summarizing a form field, so it can be spoken in | 63 ;;; How to get information summarizing a form field, so it can be spoken in |
57 ;;; a sane manner. | 64 ;;; a sane manner. |
58 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 65 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
67 (defsubst w3-speak-get-field-summarizer (type) | 74 (defsubst w3-speak-get-field-summarizer (type) |
68 "Retrieve function-name string for this voice" | 75 "Retrieve function-name string for this voice" |
69 (get type 'w3-speak-summarizer)) | 76 (get type 'w3-speak-summarizer)) |
70 | 77 |
71 ;;}}} | 78 ;;}}} |
72 ;;{{{ Associate summarizer functions for form fields | |
73 | |
74 (w3-speak-define-field-summarizer 'text) | |
75 (w3-speak-define-field-summarizer 'option) | |
76 (w3-speak-define-field-summarizer 'checkbox) | |
77 (w3-speak-define-field-summarizer 'reset) | |
78 (w3-speak-define-field-summarizer 'submit) | |
79 (w3-speak-define-field-summarizer 'button) | |
80 (w3-speak-define-field-summarizer 'radio) | |
81 (w3-speak-define-field-summarizer 'multiline) | |
82 (w3-speak-define-field-summarizer 'image) | |
83 | |
84 ;;}}} | |
85 | |
86 ;;{{{ define the form field summarizer functions | 79 ;;{{{ define the form field summarizer functions |
87 | 80 |
88 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 81 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
89 ;;; Now actually define the summarizers | 82 ;;; Now actually define the summarizers |
90 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 83 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
97 (defun w3-speak-summarize-text-field (data) | 90 (defun w3-speak-summarize-text-field (data) |
98 "Summarize a text field given the field data." | 91 "Summarize a text field given the field data." |
99 (let ( | 92 (let ( |
100 (label (w3-speak-extract-form-field-label data)) | 93 (label (w3-speak-extract-form-field-label data)) |
101 (name (w3-form-element-name data)) | 94 (name (w3-form-element-name data)) |
102 (value (widget-get (w3-form-element-widget data)))) | 95 (value (widget-value (w3-form-element-widget data)))) |
103 (dtk-speak | 96 (dtk-speak |
104 (format "Text field %s %s " (or label (concat "called " name)) | 97 (format "Text field %s %s " (or label (concat "called " name)) |
105 (concat "set to " value))))) | 98 (concat "set to " value))))) |
106 | 99 |
100 (defun w3-speak-summarize-file-field (data) | |
101 "Summarize a f field of type file given the field data." | |
102 (let ( | |
103 (label (w3-speak-extract-form-field-label data)) | |
104 (name (w3-form-element-name data)) | |
105 (value (widget-value (w3-form-element-widget data)))) | |
106 (dtk-speak | |
107 (format "File field %s %s " (or label (concat "called " name)) | |
108 (concat "set to " value))))) | |
109 | |
107 (defun w3-speak-summarize-textarea-field (data) | 110 (defun w3-speak-summarize-textarea-field (data) |
108 "Summarize a text field given the field data." | 111 "Summarize a textarea field given the field data." |
109 (let ( | 112 (let ( |
110 (name (w3-form-element-name data)) | 113 (name (w3-form-element-name data)) |
111 (label (w3-speak-extract-form-field-label data)) | 114 (label (w3-speak-extract-form-field-label data)) |
112 (value (w3-form-element-value data))) | 115 (value (w3-form-element-value data))) |
113 (dtk-speak | 116 (dtk-speak |
168 (checked (widget-value (w3-form-element-widget data)))) | 171 (checked (widget-value (w3-form-element-widget data)))) |
169 (dtk-speak | 172 (dtk-speak |
170 (format "Radio button %s is %s" (or label name) (if checked | 173 (format "Radio button %s is %s" (or label name) (if checked |
171 "pressed" | 174 "pressed" |
172 "not pressed"))))) | 175 "not pressed"))))) |
176 | |
177 ;;}}} | |
178 ;;{{{ Associate summarizer functions for form fields | |
179 | |
180 (w3-speak-define-field-summarizer 'text) | |
181 (w3-speak-define-field-summarizer 'option) | |
182 (w3-speak-define-field-summarizer 'checkbox) | |
183 (w3-speak-define-field-summarizer 'reset) | |
184 (w3-speak-define-field-summarizer 'submit) | |
185 (w3-speak-define-field-summarizer 'button) | |
186 (w3-speak-define-field-summarizer 'radio) | |
187 (w3-speak-define-field-summarizer 'multiline) | |
188 (w3-speak-define-field-summarizer 'image) | |
189 (w3-speak-define-field-summarizer 'file) | |
190 | |
173 ;;}}} | 191 ;;}}} |
174 | 192 |
175 ;;{{{ speaking form fields | 193 ;;{{{ speaking form fields |
176 | 194 |
177 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 195 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
191 ((and data summarizer (fboundp summarizer)) | 209 ((and data summarizer (fboundp summarizer)) |
192 (funcall summarizer data)) | 210 (funcall summarizer data)) |
193 (data | 211 (data |
194 (message "Please define a summarizer function for %s" type)) | 212 (message "Please define a summarizer function for %s" type)) |
195 (t nil)))) | 213 (t nil)))) |
214 | |
196 ;;}}} | 215 ;;}}} |
197 | 216 |
198 ;;{{{ Movement notification | 217 ;;{{{ Movement notification |
199 | 218 |
200 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 219 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
210 (emacspeak-speak-region start (point )))))) | 229 (emacspeak-speak-region start (point )))))) |
211 | 230 |
212 (defadvice w3-follow-link (around emacspeak pre act) | 231 (defadvice w3-follow-link (around emacspeak pre act) |
213 "Provide feedback on what you did. " | 232 "Provide feedback on what you did. " |
214 (let ((data (w3-speak-extract-form-field-information)) | 233 (let ((data (w3-speak-extract-form-field-information)) |
215 (form-field-p nil) | 234 (form-field-p nil)) |
216 (this-zone nil) | |
217 (opoint nil)) | |
218 (if data | 235 (if data |
219 (setq form-field-p t | 236 (setq form-field-p t)) |
220 opoint (point))) | |
221 ad-do-it | 237 ad-do-it |
222 (when form-field-p | 238 (when form-field-p |
223 (w3-speak-summarize-form-field) | 239 (w3-speak-summarize-form-field) |
224 (case (w3-form-element-type data) | 240 (case (w3-form-element-type data) |
225 ((radio checkbox) | 241 ((radio checkbox button) |
226 (emacspeak-auditory-icon 'button)) | 242 (emacspeak-auditory-icon 'button)) |
243 ((text textarea) | |
244 (emacspeak-auditory-icon 'close-object) | |
227 ;; fill in any others here | 245 ;; fill in any others here |
228 (otherwise | 246 (otherwise |
229 nil))) | 247 nil))) |
230 ad-return-value)) | 248 ad-return-value))) |
231 | 249 |
232 (defadvice w3-revert-form (after emacspeak pre act) | 250 (defadvice w3-revert-form (after emacspeak pre act) |
233 "Announce that you cleared the form. " | 251 "Announce that you cleared the form. " |
234 (dtk-speak "Cleared the form. ")) | 252 (dtk-speak "Cleared the form. ")) |
235 | 253 |
239 (w3-speak-summarize-form-field))) | 257 (w3-speak-summarize-form-field))) |
240 | 258 |
241 (defadvice widget-forward (after emacspeak pre act) | 259 (defadvice widget-forward (after emacspeak pre act) |
242 "Produce an auditory icon when moving forward. | 260 "Produce an auditory icon when moving forward. |
243 If on a form field, then summarize it." | 261 If on a form field, then summarize it." |
244 (when (interactive-p) | 262 (declare (special emacspeak-lazy-message-time)) |
245 (w3-speak-summarize-form-field) | 263 (when (interactive-p) |
246 (emacspeak-auditory-icon 'large-movement))) | 264 (let ((emacspeak-lazy-message-time 0)) |
265 (w3-speak-summarize-form-field) | |
266 (emacspeak-auditory-icon 'large-movement)))) | |
247 | 267 |
248 (defadvice widget-backward (after emacspeak pre act) | 268 (defadvice widget-backward (after emacspeak pre act) |
249 "Produce an auditory icon when moving backward. | 269 "Produce an auditory icon when moving backward. |
250 If on a form field, then summarize it." | 270 If on a form field, then summarize it." |
271 (declare (special emacspeak-lazy-message-time)) | |
251 (when (interactive-p ) | 272 (when (interactive-p ) |
273 (let ((emacspeak-lazy-message-time 0)) | |
252 (w3-speak-summarize-form-field) | 274 (w3-speak-summarize-form-field) |
253 (emacspeak-auditory-icon 'large-movement))) | 275 (emacspeak-auditory-icon 'large-movement)))) |
254 | 276 |
255 (defadvice w3-start-of-document (after emacspeak pre act) | 277 (defadvice w3-start-of-document (after emacspeak pre act) |
256 "Produce an auditory icon. Also speak the first line. " | 278 "Produce an auditory icon. Also speak the first line. " |
257 (when (interactive-p) | 279 (when (interactive-p) |
258 (emacspeak-speak-line) | 280 (emacspeak-speak-line) |
259 (emacspeak-auditory-icon 'large-movement))) | 281 (emacspeak-auditory-icon 'large-movement))) |
260 | 282 |
261 (defadvice w3-end-of-document (after emacspeak pre act) | 283 (defadvice w3-end-of-document (after emacspeak pre act) |
262 "Produce an auditory icon. Also speak the first line." | 284 "Produce an auditory icon. " |
263 (when (interactive-p) | 285 (when (interactive-p) |
264 (emacspeak-speak-line) | 286 (emacspeak-speak-line) |
265 (emacspeak-auditory-icon 'large-movement))) | 287 (emacspeak-auditory-icon 'large-movement))) |
266 | 288 |
267 (defadvice w3-goto-last-buffer (after emacspeak pre act) | 289 (defadvice w3-goto-last-buffer (after emacspeak pre act) |
275 (when (interactive-p) | 297 (when (interactive-p) |
276 (emacspeak-auditory-icon 'close-object) | 298 (emacspeak-auditory-icon 'close-object) |
277 (emacspeak-speak-mode-line))) | 299 (emacspeak-speak-mode-line))) |
278 | 300 |
279 (defadvice w3-fetch (around emacspeak act comp ) | 301 (defadvice w3-fetch (around emacspeak act comp ) |
280 "First produce an auditory icon to indicate retrieval. | 302 "First produce an auditory icon to indicate retrieval. After |
281 After retrieval, | 303 retrieval, set voice-lock-mode to t after displaying the buffer, and |
282 set voice-lock-mode to t after displaying the buffer, | 304 then speak the mode-line. " |
283 and then speak the mode-line. " | |
284 (declare (special dtk-punctuation-mode)) | 305 (declare (special dtk-punctuation-mode)) |
285 (emacspeak-auditory-icon 'select-object) | 306 (when (interactive-p) |
286 ad-do-it) | 307 (emacspeak-auditory-icon 'select-object) |
308 ad-do-it | |
309 (set (make-local-variable 'voice-lock-mode) t) | |
310 (setq dtk-punctuation-mode "some") | |
311 (modify-syntax-entry 10 " ") | |
312 (emacspeak-auditory-icon 'open-object) | |
313 (emacspeak-speak-mode-line ))) | |
314 | |
315 ;;}}} | |
316 ;;{{{ top level | |
287 | 317 |
288 (defun w3-speak-mode-hook () | 318 (defun w3-speak-mode-hook () |
289 (set (make-local-variable 'voice-lock-mode) t) | 319 (set (make-local-variable 'voice-lock-mode) t) |
290 (setq dtk-punctuation-mode "some") | 320 (setq dtk-punctuation-mode "some") |
291 (emacspeak-auditory-icon 'open-object) | 321 (emacspeak-auditory-icon 'open-object) |
308 (remove-hook 'w3-mode-hook 'w3-speak-mode-hook)) | 338 (remove-hook 'w3-mode-hook 'w3-speak-mode-hook)) |
309 (setq w3-delimit-links nil | 339 (setq w3-delimit-links nil |
310 w3-delimit-emphasis nil) | 340 w3-delimit-emphasis nil) |
311 (add-hook 'w3-mode-hook 'w3-speak-mode-hook))) | 341 (add-hook 'w3-mode-hook 'w3-speak-mode-hook))) |
312 | 342 |
343 ;;}}} | |
344 ;;{{{ make-local-hook | |
345 | |
346 ;;; hope this is correct: | |
347 (unless (fboundp 'make-local-hook) | |
348 (defun make-local-hook (var) | |
349 (make-variable-buffer-local var)) | |
350 ) | |
351 | |
352 ;;}}} | |
313 (provide 'w3-speak) | 353 (provide 'w3-speak) |