1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313
|
;;; emacspeak-outline.el --- Speech enable Outline -- Browsing Structured Documents
;;; $Id: emacspeak-outline.el 5798 2008-08-22 17:35:01Z tv.raman.tv $
;;; $Author: tv.raman.tv $
;;; DescriptionEmacspeak extensions for outline-mode
;;; Keywords:emacspeak, audio interface to emacs Outlines
;;{{{ LCD Archive entry:
;;; LCD Archive Entry:
;;; emacspeak| T. V. Raman |raman@crl.dec.com
;;; A speech interface to Emacs |
;;; $date: $ |
;;; $Revision: 4532 $ |
;;; Location undetermined
;;;
;;}}}
;;{{{ Copyright:
;;;Copyright (C) 1995 -- 2007, T. V. Raman
;;; Copyright (c) 1994, 1995 by Digital Equipment Corporation.
;;; All Rights Reserved.
;;;
;;; This file is not part of GNU Emacs, but the same permissions apply.
;;;
;;; GNU Emacs is free software; you can redistribute it and/or modify
;;; it under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 2, or (at your option)
;;; any later version.
;;;
;;; GNU Emacs is distributed in the hope that it will be useful,
;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with GNU Emacs; see the file COPYING. If not, write to
;;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
;;}}}
;;{{{ Introduction:
;;; Commentary:
;;; Provide additional advice to outline-mode
;;; Code:
;;}}}
;;{{{ requires
(require 'emacspeak-preamble)
(require 'outline)
;;}}}
;;{{{ Navigating through an outline:
(defadvice outline-next-heading (after emacspeak pre act comp)
"Speak the line."
(when (interactive-p)
(emacspeak-auditory-icon 'large-movement)
(emacspeak-speak-line )))
(defadvice outline-back-to-heading (after emacspeak pre act comp)
"Speak the line."
(when (interactive-p)
(emacspeak-auditory-icon 'large-movement)
(emacspeak-speak-line )))
(defadvice outline-next-visible-heading (after emacspeak pre act comp)
"Speak the line."
(when (interactive-p)
(emacspeak-auditory-icon 'large-movement)
(and (looking-at "^$")
(skip-syntax-backward " "))
(emacspeak-speak-line )))
(defadvice outline-previous-visible-heading (after emacspeak pre act comp)
"Speak the line."
(when (interactive-p)
(emacspeak-auditory-icon 'large-movement)
(emacspeak-speak-line )))
(defadvice outline-up-heading (after emacspeak pre act comp)
"Provide auditory feedback."
(when (interactive-p)
(emacspeak-auditory-icon 'large-movement)
(emacspeak-speak-line )))
(defadvice outline-forward-same-level (after emacspeak pre act comp)
"Provide auditory feedback."
(when (interactive-p)
(emacspeak-auditory-icon 'large-movement)
(emacspeak-speak-line )))
(defadvice outline-backward-same-level (after emacspeak pre act comp)
"Provide auditory feedback."
(when (interactive-p)
(emacspeak-auditory-icon 'large-movement)
(emacspeak-speak-line )))
;;}}}
;;{{{ Hiding and showing subtrees
(defadvice hide-entry (after emacspeak pre act comp)
"Produce an auditory icon"
(when (interactive-p)
(emacspeak-auditory-icon 'close-object)
(message "Hid the body directly following this heading")))
(defadvice show-entry (after emacspeak pre act comp)
"Produce an auditory icon"
(when (interactive-p)
(emacspeak-auditory-icon 'open-object)
(message "Exposed body directly following current heading")))
(defadvice hide-body (after emacspeak pre act comp)
"Produce an auditory icon"
(when (interactive-p)
(emacspeak-auditory-icon 'close-object)
(message "Hid all of the buffer except for header lines")))
(defadvice show-all (after emacspeak pre act comp)
"Produce an auditory icon"
(when (interactive-p)
(emacspeak-auditory-icon 'open-object)
(message "Exposed all text in the buffer")))
(defadvice hide-subtree (after emacspeak pre act comp)
"Produce an auditory icon"
(when (interactive-p)
(emacspeak-auditory-icon 'close-object)
(message "Hid everything at deeper levels from current heading")))
(defadvice hide-leaves (after emacspeak pre act comp)
"Produce an auditory icon"
(when (interactive-p)
(emacspeak-auditory-icon 'close-object)
(message "Hid all of the body at deeper levels")))
(defadvice show-subtree (after emacspeak pre act comp)
"Produce an auditory icon"
(when (interactive-p)
(emacspeak-auditory-icon 'open-object)
(message "Exposed everything after current heading at deeper levels")))
(defadvice hide-sublevels (after emacspeak pre act comp)
"Produce an auditory icon"
(when (interactive-p)
(emacspeak-auditory-icon 'close-object)
(message "Hid everything except the top %s levels"
(ad-get-arg 0))))
(defadvice hide-other (after emacspeak pre act comp)
"Produce an auditory icon"
(when (interactive-p)
(emacspeak-auditory-icon 'close-object)
(message "Hid everything except current body and parent headings")))
(defadvice show-branches (after emacspeak pre act comp)
"Produce an auditory icon"
(when (interactive-p)
(emacspeak-auditory-icon 'open-object)
(message "Exposed all subheadings while leaving their bodies hidden")))
(defadvice show-children (after emacspeak pre act comp)
"Produce an auditory icon"
(when (interactive-p)
(emacspeak-auditory-icon 'open-object)
(message "Exposed subheadings below current level")))
;;}}}
;;{{{ Interactive speaking of sections
(defcustom emacspeak-outline-dont-query-before-speaking t
"*Option to control prompts when speaking outline
sections."
:group 'emacspeak-outline
:type 'boolean)
(defun emacspeak-outline-speak-heading (what direction)
"Function used by all interactive section speaking
commands. "
(declare (special emacspeak-outline-query-before-speaking))
(let ((start nil)
(end nil))
(funcall what direction)
(setq start (point))
(save-excursion
(condition-case nil
(progn
(forward-line 1)
(funcall what 1)
(setq end (point)))
(error (setq end (point-max)))))
(when (or emacspeak-outline-dont-query-before-speaking
(y-or-n-p
(format "Speak %s lines from section %s"
(count-lines start end )
(thing-at-point 'line))))
(emacspeak-speak-region start end ))))
(defun emacspeak-outline-speak-next-heading ()
"Analogous to outline-next-visible-heading,
except that the outline section is optionally spoken"
(interactive)
(emacspeak-outline-speak-heading 'outline-next-visible-heading 1))
(defun emacspeak-outline-speak-previous-heading ()
"Analogous to outline-previous-visible-heading,
except that the outline section is optionally spoken"
(interactive)
(emacspeak-outline-speak-heading 'outline-next-visible-heading -1))
(defun emacspeak-outline-speak-forward-heading ()
"Analogous to outline-forward-same-level,
except that the outline section is optionally spoken"
(interactive)
(emacspeak-outline-speak-heading 'outline-forward-same-level 1))
(defun emacspeak-outline-speak-backward-heading ()
"Analogous to outline-backward-same-level
except that the outline section is optionally spoken"
(interactive)
(forward-line -1)
(emacspeak-outline-speak-heading 'outline-forward-same-level -1))
(defun emacspeak-outline-speak-this-heading ()
"Speak current outline section starting from point"
(interactive)
(let ((start (point))
(end nil))
(save-excursion
(condition-case nil
(progn
(outline-next-visible-heading 1)
(setq end (point)))
(error (setq end (point-max)))))
(and
(or emacspeak-outline-dont-query-before-speaking
(y-or-n-p
(format "Speak %s lines from section %s"
(count-lines start end)
(thing-at-point 'line))))
(emacspeak-speak-region start end ))))
;;{{{ bind these in outline mode
(defun emacspeak-outline-setup-keys ()
"Bind keys in outline minor mode map"
(declare (special outline-mode-prefix-map))
(define-key outline-mode-prefix-map "p"
'emacspeak-outline-speak-previous-heading)
(define-key outline-mode-prefix-map "n"
'emacspeak-outline-speak-next-heading)
(define-key outline-mode-prefix-map "b"
'emacspeak-outline-speak-backward-heading)
(define-key outline-mode-prefix-map "f"
'emacspeak-outline-speak-forward-heading)
(define-key outline-mode-prefix-map " " 'emacspeak-outline-speak-this-heading))
(add-hook 'outline-mode-hook 'emacspeak-outline-setup-keys)
(add-hook 'outline-minor-mode-hook 'emacspeak-outline-setup-keys)
;;}}}
;;}}}
;;{{{ foldout specific advice
(and (locate-library "foldout")
(require 'foldout))
(defadvice foldout-zoom-subtree (after emacspeak pre act comp)
"Provide auditory feedback about the child we zoomed into"
(when (interactive-p)
(emacspeak-auditory-icon 'open-object)
(message "Zoomed into outline %s containing %s lines"
(thing-at-point 'line)
(count-lines (point-min) (point-max)))))
(defadvice foldout-exit-fold (after emacspeak pre act comp)
"Provide auditory feedback when exiting a fold"
(when (interactive-p)
(emacspeak-auditory-icon 'close-object)
(emacspeak-speak-line)))
;;}}}
;;{{{ Personalities (
(voice-setup-add-map
'(
(outline-1 voice-bolden-extra)
(outline-2 voice-bolden-medium)
(outline-3 voice-bolden)
(outline-4 voice-lighten)
(outline-5 voice-lighten-medium)
(outline-6 voice-lighten)
))
;;}}}
;;{{{ silence errors to help org-mode:
(defadvice outline-up-heading (around emacspeak pre act comp)
"Silence error messages."
(ems-with-errors-silenced
ad-do-it
ad-return-value))
;;}}}
(provide 'emacspeak-outline)
;;{{{ emacs local variables
;;; local variables:
;;; folded-file: t
;;; byte-compile-dynamic: t
;;; end:
;;}}}
|