PageRenderTime 23ms CodeModel.GetById 32ms RepoModel.GetById 1ms app.codeStats 0ms

/utilities/emacspeak/lisp/emacspeak-info.el

https://github.com/jamesnvc/emacs.d
Lisp | 215 lines | 126 code | 26 blank | 63 comment | 4 complexity | 4571251e6e285c4d51505d35ff498961 MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1, LGPL-2.0, MIT, BSD-3-Clause, GPL-3.0
  1. ;;; emacspeak-info.el --- Speech enable Info -- Emacs' online documentation viewer
  2. ;;; $Id: emacspeak-info.el 5798 2008-08-22 17:35:01Z tv.raman.tv $
  3. ;;; $Author: tv.raman.tv $
  4. ;;; Description: Module for customizing Emacs info
  5. ;;; Keywords:emacspeak, audio interface to emacs
  6. ;;{{{ LCD Archive entry:
  7. ;;; LCD Archive Entry:
  8. ;;; emacspeak| T. V. Raman |raman@cs.cornell.edu
  9. ;;; A speech interface to Emacs |
  10. ;;; $Date: 2007-08-25 18:28:19 -0700 (Sat, 25 Aug 2007) $ |
  11. ;;; $Revision: 4558 $ |
  12. ;;; Location undetermined
  13. ;;;
  14. ;;}}}
  15. ;;{{{ Copyright:
  16. ;;;Copyright (C) 1995 -- 2007, T. V. Raman
  17. ;;; Copyright (c) 1994, 1995 by Digital Equipment Corporation.
  18. ;;; All Rights Reserved.
  19. ;;;
  20. ;;; This file is not part of GNU Emacs, but the same permissions apply.
  21. ;;;
  22. ;;; GNU Emacs is free software; you can redistribute it and/or modify
  23. ;;; it under the terms of the GNU General Public License as published by
  24. ;;; the Free Software Foundation; either version 2, or (at your option)
  25. ;;; any later version.
  26. ;;;
  27. ;;; GNU Emacs is distributed in the hope that it will be useful,
  28. ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  29. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  30. ;;; GNU General Public License for more details.
  31. ;;;
  32. ;;; You should have received a copy of the GNU General Public License
  33. ;;; along with GNU Emacs; see the file COPYING. If not, write to
  34. ;;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  35. ;;}}}
  36. ;;{{{ Introduction:
  37. ;;; This module extends and customizes the Emacs info reader.
  38. ;;}}}
  39. ;;{{{ requires
  40. (require 'emacspeak-preamble)
  41. (eval-when-compile (require 'info))
  42. ;;}}}
  43. ;;{{{ Variables:
  44. (defvar Info-voiceify t
  45. "*Non-nil enables highlighting and voices in Info nodes.")
  46. (defvar Info-voiceify-maximum-menu-size 30000
  47. "*Maximum size of menu to voiceify if `Info-voiceify' is non-nil.")
  48. ;;}}}
  49. ;;{{{ Voices
  50. (voice-setup-add-map
  51. '(
  52. (info-title-1 voice-bolden-extra)
  53. (info-title-2 voice-bolden-medium)
  54. (info-title-3 voice-bolden)
  55. (info-title-4 voice-lighten)
  56. (info-header-node voice-smoothen)
  57. (info-header-xref voice-brighten)
  58. (info-menu-5 voice-lighten)
  59. (info-menu-header voice-bolden-medium)
  60. (info-node voice-monotone)
  61. (info-xref voice-animate-extra)
  62. (info-menu-star voice-brighten)
  63. (info-xref-visited voice-animate-medium)
  64. ))
  65. ;;}}}
  66. ;;{{{ advice
  67. (defcustom emacspeak-info-select-node-speak-chunk 'screenfull
  68. "*Specifies how much of the selected node gets spoken.
  69. Possible values are:
  70. screenfull -- speak the displayed screen
  71. node -- speak the entire node."
  72. :type '(menu-choice
  73. (const :tag "First screenfull" screenfull)
  74. (const :tag "Entire node" node))
  75. :group 'emacspeak-info)
  76. (defsubst emacspeak-info-speak-current-window ()
  77. "Speak current window in info buffer."
  78. (let ((start (point ))
  79. (window (get-buffer-window (current-buffer ))))
  80. (save-excursion
  81. (forward-line (window-height window))
  82. (emacspeak-speak-region start (point )))))
  83. (defun emacspeak-info-visit-node()
  84. "Apply requested action upon visiting a node."
  85. (declare (special emacspeak-info-select-node-speak-chunk))
  86. (let ((dtk-stop-immediately t ))
  87. (emacspeak-auditory-icon 'select-object)
  88. (cond
  89. ((eq emacspeak-info-select-node-speak-chunk
  90. 'screenfull)
  91. (emacspeak-info-speak-current-window))
  92. ((eq emacspeak-info-select-node-speak-chunk 'node)
  93. (emacspeak-speak-buffer ))
  94. (t (emacspeak-speak-line)))))
  95. (defadvice Info-select-node (after emacspeak pre act)
  96. "Voiceify the Info node if requested.
  97. Speak the selected node based on setting of
  98. emacspeak-info-select-node-speak-chunk"
  99. (emacspeak-info-visit-node))
  100. (defadvice info (after emacspeak pre act)
  101. "Cue user that info is up."
  102. (when (interactive-p)
  103. (emacspeak-auditory-icon 'help)
  104. (emacspeak-speak-line)))
  105. (defadvice Info-scroll-up (after emacspeak pre act)
  106. "Speak the screenful."
  107. (when (interactive-p)
  108. (emacspeak-auditory-icon 'scroll)
  109. (let ((start (point ))
  110. (window (get-buffer-window (current-buffer ))))
  111. (save-excursion
  112. (forward-line (window-height window))
  113. (emacspeak-speak-region start (point ))))))
  114. (defadvice Info-scroll-down (after emacspeak pre act)
  115. "Speak the screenful."
  116. (when (interactive-p)
  117. (emacspeak-auditory-icon 'scroll)
  118. (let ((start (point ))
  119. (window (get-buffer-window (current-buffer ))))
  120. (save-excursion
  121. (forward-line (window-height window))
  122. (emacspeak-speak-region start (point ))))))
  123. (defadvice Info-exit (after emacspeak pre act)
  124. "Play an auditory icon to close info,
  125. and then cue the next selected buffer."
  126. (when (interactive-p )
  127. (dtk-stop)
  128. (emacspeak-auditory-icon 'close-object)
  129. (emacspeak-speak-mode-line)))
  130. (defadvice Info-next-reference (after emacspeak pre act)
  131. "Speak the line. "
  132. (when (interactive-p)
  133. (emacspeak-speak-line)))
  134. (defadvice Info-prev-reference (after emacspeak pre act)
  135. "Speak the line. "
  136. (when (interactive-p)
  137. (emacspeak-speak-line)))
  138. ;;}}}
  139. ;;{{{ Speak header line if hidden
  140. (defun emacspeak-info-speak-header ()
  141. "Speak info header line."
  142. (interactive)
  143. (declare (special Info-use-header-line
  144. Info-header-line))
  145. (let ((voice-lock-mode t))
  146. (cond
  147. ((and (boundp 'Info-use-header-line)
  148. (boundp 'Info-header-line)
  149. Info-header-line)
  150. (dtk-speak Info-header-line))
  151. (t (save-excursion
  152. (goto-char (point-min))
  153. (emacspeak-speak-line))))))
  154. ;;}}}
  155. ;;{{{ Emacs 21
  156. ;;; There is a bug in Emacs 21 that causes info-extract-pointer to be
  157. ;;; called erroneously.
  158. (defadvice Info-extract-pointer (around emacspeak pre act comp)
  159. "Silence emacspeak during call."
  160. (let ((emacspeak-speak-messages nil)
  161. (emacspeak-use-auditory-icons nil))
  162. ad-do-it))
  163. ;;}}}
  164. ;;{{{ keymaps
  165. (declaim (special Info-mode-map))
  166. (define-key Info-mode-map "T" 'emacspeak-info-speak-header)
  167. (define-key Info-mode-map "'" 'emacspeak-speak-rest-of-buffer)
  168. ;;}}}
  169. ;;{{{ info wizard
  170. ;;;###autoload
  171. (defun emacspeak-info-wizard (node-spec )
  172. "Read a node spec from the minibuffer and launch
  173. Info-goto-node.
  174. See documentation for command `Info-goto-node' for details on
  175. node-spec."
  176. (interactive
  177. (list
  178. (read-from-minibuffer "Node: "
  179. "(")))
  180. (Info-goto-node node-spec)
  181. (emacspeak-info-visit-node))
  182. ;;}}}
  183. (provide 'emacspeak-info)
  184. ;;{{{ emacs local variables
  185. ;;; local variables:
  186. ;;; folded-file: t
  187. ;;; byte-compile-dynamic: t
  188. ;;; end:
  189. ;;}}}