annotate lisp/w3/w3-speak.el @ 14:9ee227acff29 r19-15b90

Import from CVS: tag r19-15b90
author cvs
date Mon, 13 Aug 2007 08:48:42 +0200
parents ac2d302a0011
children 0293115a14e9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
1 ;;; w3-speak.el,v --- Emacs-W3 speech interface
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
2 ;; Author: wmperry
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
3 ;; Original author: William Perry --<wmperry@cs.indiana.edu>
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
4 ;; Cloned from emacspeak-w3.el
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
5 ;; Created: 1996/10/16 20:56:40
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
6 ;; Version: 1.14
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 ;; Keywords: hypermedia, speech
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
8
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
9 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
10 ;;; Copyright (c) 1996 by T.V. Raman (raman@adobe.com)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
11 ;;; Copyright (c) 1996 by William M. Perry (wmperry@spry.com)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;;; This file is not part of GNU Emacs, but the same permissions apply.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;;; GNU Emacs is free software; you can redistribute it and/or modify
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;;; it under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;;; the Free Software Foundation; either version 2, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 ;;; any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 ;;; GNU Emacs is distributed in the hope that it will be useful,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 ;;; GNU General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 ;;; You should have received a copy of the GNU General Public License
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
26 ;;; along with GNU Emacs; see the file COPYING. If not, write to the
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
27 ;;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
28 ;;; Boston, MA 02111-1307, USA.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 ;;; A replacement module for emacspeak-w3 that uses all the new functionality
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 ;;; of Emacs-W3 3.0.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 ;;; This file would not be possible without the help of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 ;;; T.V. Raman (raman@adobe.com) and his continued efforts to make Emacs-W3
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 ;;; even remotely useful. :)
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
38 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
39
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
40 ;;; This conforms to http://www4.inria.fr/speech2.html
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 (require 'widget)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 (require 'w3-forms)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 (require 'advice)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 ;; This condition-case needs to be here or it completely chokes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 ;; byte-compilation for people who do not have Emacspeak installed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 ;; *sigh*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 (condition-case ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 (require 'emacspeak)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 (require 'dtk-voices)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 (require 'emacspeak-speak)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 (require 'emacspeak-sounds)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 (eval-when (compile)
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
55 (require 'emacspeak-fix-interactive)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 (error (message "Emacspeak not found - speech will not work.")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 ;;; How to get information summarizing a form field, so it can be spoken in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 ;;; a sane manner.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 ;;{{{ putting and getting form field summarizer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 (defsubst w3-speak-define-field-summarizer (type &optional function-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 "Associate the name of a function that describes this type of form field."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 (put type 'w3-speak-summarizer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 (or function-name (intern
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 (format "w3-speak-summarize-%s-field" type)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 (defsubst w3-speak-get-field-summarizer (type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 "Retrieve function-name string for this voice"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 (get type 'w3-speak-summarizer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 ;;}}}
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
76 ;;{{{ Associate summarizer functions for form fields
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
77
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
78 (w3-speak-define-field-summarizer 'text)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
79 (w3-speak-define-field-summarizer 'option)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
80 (w3-speak-define-field-summarizer 'checkbox)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
81 (w3-speak-define-field-summarizer 'reset)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
82 (w3-speak-define-field-summarizer 'submit)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
83 (w3-speak-define-field-summarizer 'button)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
84 (w3-speak-define-field-summarizer 'radio)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
85 (w3-speak-define-field-summarizer 'multiline)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
86 (w3-speak-define-field-summarizer 'image)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
87
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
88 ;;}}}
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
89
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
90
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 ;;{{{ define the form field summarizer functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 ;;; Now actually define the summarizers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 (defsubst w3-speak-extract-form-field-label (data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 ;;; FIXXX!!! Need to reimplement using the new forms implementation!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 (declare (special w3-form-labels))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 (defun w3-speak-summarize-text-field (data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 "Summarize a text field given the field data."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 (let (
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 (label (w3-speak-extract-form-field-label data))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 (name (w3-form-element-name data))
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
107 (value (widget-get (w3-form-element-widget data) :value)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 (dtk-speak
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 (format "Text field %s %s " (or label (concat "called " name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 (concat "set to " value)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
112 (defun w3-speak-summarize-multiline-field (data)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
113 "Summarize a text field given the field data."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 (let (
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 (name (w3-form-element-name data))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 (label (w3-speak-extract-form-field-label data))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 (value (w3-form-element-value data)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 (dtk-speak
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 (format "Multiline text input %s %s" (or label (concat "called " name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 (concat "set to " value)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 (defun w3-speak-summarize-checkbox-field (data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 "Summarize a checkbox field given the field data."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 (let (
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 (name (w3-form-element-name data))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 (label (w3-speak-extract-form-field-label data))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 (checked (widget-value (w3-form-element-widget data))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 (dtk-speak
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 (format "Checkbox %s is %s" (or label name) (if checked "on" "off")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 (defun w3-speak-summarize-option-field (data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 "Summarize a options field given the field data."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 (let (
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 (name (w3-form-element-name data))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 (label (w3-speak-extract-form-field-label data))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 (default (w3-form-element-default-value data)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 (dtk-speak
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 (format "Choose an option %s %s" (or label name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 (if (string= "" default)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 ""
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 (format "default is %s" default))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 ;;; to handle brain dead nynex forms
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 (defun w3-speak-summarize-image-field (data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 "Summarize a image field given the field data.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 Currently, only the NYNEX server uses this."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 (let (
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 (name (w3-form-element-name data))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 (label (w3-speak-extract-form-field-label data)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 (dtk-speak
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 (substring name 1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 (defun w3-speak-summarize-submit-field (data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 "Summarize a submit field given the field data."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 (let (
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 (type (w3-form-element-type data))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 (label (w3-speak-extract-form-field-label data))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 (button-text (widget-value (w3-form-element-widget data))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 (message "%s" (or label button-text
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 (case type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 (submit "Submit Form")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 (reset "Reset Form")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 (button "A Button"))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
165 (defalias 'w3-speak-summarize-reset-field 'w3-speak-summarize-submit-field)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 (defalias 'w3-speak-summarize-button-field 'w3-speak-summarize-submit-field)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 (defun w3-speak-summarize-radio-field (data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 "Summarize a radio field given the field data."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 (let (
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 (name (w3-form-element-name data))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 (label (w3-speak-extract-form-field-label data))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 (checked (widget-value (w3-form-element-widget data))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 (dtk-speak
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 (format "Radio button %s is %s" (or label name) (if checked
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 "pressed"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 "not pressed")))))
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
178
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
179 ;;}}}
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
181 ;;{{{ speaking form fields
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 ;;; Now for the guts
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 (defun w3-speak-extract-form-field-information ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 (let* ((widget (widget-at (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 (data (and widget (widget-get widget 'w3-form-data))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 data))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 (defun w3-speak-summarize-form-field ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 "Summarizes field under point if any."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 (let* ((data (w3-speak-extract-form-field-information))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 (type (and data (w3-form-element-type data)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 (summarizer (and type (w3-speak-get-field-summarizer type))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 (cond
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
197 ((and data
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
198 summarizer
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
199 (fboundp summarizer))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 (funcall summarizer data))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 (data
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 (message "Please define a summarizer function for %s" type))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 (t nil))))
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
204
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 ;;}}}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 ;;; Movement notification
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 (defadvice w3-scroll-up (after emacspeak pre act comp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 "Provide auditory feedback"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 (when (interactive-p)
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
213 (let ((start (point )))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
214 (emacspeak-auditory-icon 'scroll)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
215 (save-excursion
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
216 (forward-line (window-height))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
217 (emacspeak-speak-region start (point ))))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 (defadvice w3-follow-link (around emacspeak pre act)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 "Provide feedback on what you did. "
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
221 (let ((data (emacspeak-w3-extract-form-field-information))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
222 (form-field-p nil)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
223 (this-zone nil)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
224 (opoint nil))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 (if data
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
226 (setq form-field-p t
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
227 opoint (point)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 ad-do-it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 (when form-field-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 (w3-speak-summarize-form-field)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 (case (w3-form-element-type data)
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
232 ((radio checkbox)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 (emacspeak-auditory-icon 'button))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 ;; fill in any others here
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 (otherwise
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 nil)))
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
237 ad-return-value))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 (defadvice w3-revert-form (after emacspeak pre act)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 "Announce that you cleared the form. "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 (dtk-speak "Cleared the form. "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 (defadvice w3-finish-text-entry (after emacspeak pre act )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 "Announce what the field was set to."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 (when (interactive-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 (w3-speak-summarize-form-field)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 (defadvice w3-start-of-document (after emacspeak pre act)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 "Produce an auditory icon. Also speak the first line. "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 (when (interactive-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 (emacspeak-speak-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 (emacspeak-auditory-icon 'large-movement)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 (defadvice w3-end-of-document (after emacspeak pre act)
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
255 "Produce an auditory icon. Also speak the first line."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 (when (interactive-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 (emacspeak-speak-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 (emacspeak-auditory-icon 'large-movement)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 (defadvice w3-goto-last-buffer (after emacspeak pre act)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 "Speak the modeline so I know where I am."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 (when (interactive-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 (emacspeak-auditory-icon 'select-object)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 (emacspeak-speak-mode-line)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 (defadvice w3-quit (after emacspeak pre act)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 "Speak the mode line of the new buffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 (when (interactive-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 (emacspeak-auditory-icon 'close-object)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 (emacspeak-speak-mode-line)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 (defadvice w3-fetch (around emacspeak act comp )
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
273 "First produce an auditory icon to indicate retrieval.
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
274 After retrieval,
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
275 set voice-lock-mode to t after displaying the buffer,
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
276 and then speak the mode-line. "
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 (declare (special dtk-punctuation-mode))
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
278 (emacspeak-auditory-icon 'select-object)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
279 ad-do-it)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 (defun w3-speak-mode-hook ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 (set (make-local-variable 'voice-lock-mode) t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 (setq dtk-punctuation-mode "some")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 (emacspeak-auditory-icon 'open-object)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 (emacspeak-speak-mode-line))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 ;;; This is really the only function you should need to call unless
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 ;;; you are adding functionality.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 (defun w3-speak-use-voice-locking (&optional arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 "Tells w3 to start using voice locking.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 This is done by setting the w3 variables so that anchors etc are not marked by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 delimiters. We then turn on voice-lock-mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 Interactive prefix arg does the opposite. "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 (declare (special w3-delimit-links w3-delimit-emphasis w3-echo-link))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 (setq w3-echo-link 'text)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 (if arg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 (setq w3-delimit-links 'guess
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 w3-delimit-emphasis 'guess)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 (remove-hook 'w3-mode-hook 'w3-speak-mode-hook))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 (setq w3-delimit-links nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 w3-delimit-emphasis nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 (add-hook 'w3-mode-hook 'w3-speak-mode-hook)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
306 (defun w3-speak-browse-page ()
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
307 "Browse a WWW page"
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
308 (interactive)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
309 (emacspeak-audio-annotate-paragraphs)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
310 (emacspeak-execute-repeatedly 'forward-paragraph))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
311
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
312 (declaim (special w3-mode-map))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
313 (define-key w3-mode-map "." 'w3-speak-browse-page)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
314
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
315 (defvar url-speak-last-progress-indication 0
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
316 "Caches when we last produced a progress auditory icon")
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
317
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
318 (defadvice url-lazy-message (around emacspeak pre act)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
319 "Provide pleasant auditory feedback about progress"
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
320 (declare (special url-speak-last-progress-indication ))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
321 (let ((now (nth 1 (current-time))))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
322 (when (> now
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
323 (+ 3 url-speak-last-progress-indication))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
324 (setq url-speak-last-progress-indication now)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
325 (emacspeak-auditory-icon 'progress))))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
326
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 (provide 'w3-speak)