PageRenderTime 45ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/emacspeak-29.0/lisp/emacspeak-auctex.el

#
Emacs Lisp | 252 lines | 150 code | 38 blank | 64 comment | 2 complexity | 54c7acb50d5bce432c9ad2c1fc226a38 MD5 | raw file
Possible License(s): MIT
  1. ;;; emacspeak-auctex.el --- Speech enable AucTeX -- a powerful TeX/LaTeX authoring environment
  2. ;;; $Id: emacspeak-auctex.el 5798 2008-08-22 17:35:01Z tv.raman.tv $
  3. ;;; $Author: tv.raman.tv $
  4. ;;; DescriptionEmacspeak extensions for auctex-mode
  5. ;;; Keywords:emacspeak, audio interface to emacs AUCTEX
  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-09-27 09:14:42 -0700 (Thu, 27 Sep 2007) $ |
  11. ;;; $Revision: 4532 $ |
  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. ;;{{{ Required modules
  37. (require 'emacspeak-preamble)
  38. ;;}}}
  39. ;;{{{ Introduction:
  40. ;;; Provide additional advice to auctex
  41. ;;}}}
  42. ;;{{{ voice locking:
  43. ;;; faces from AUCTeX 11
  44. (voice-setup-add-map
  45. '(
  46. (font-latex-bold-face voice-bolden)
  47. (font-latex-doctex-documentation-face voice-monotone-medium)
  48. (font-latex-doctex-preprocessor-face voice-brighten-medium)
  49. (font-latex-italic-face voice-animate)
  50. (font-latex-math-face voice-brighten-extra)
  51. (font-latex-sedate-face voice-smoothen)
  52. (font-latex-string-face voice-lighten)
  53. (font-latex-subscript-face voice-smoothen)
  54. (font-latex-superscript-face voice-brighten)
  55. (font-latex-title-1-face voice-bolden-extra)
  56. (font-latex-title-2-face voice-bolden-medium)
  57. (font-latex-title-3-face voice-bolden)
  58. (font-latex-title-4-face voice-smoothen-extra)
  59. (font-latex-verbatim-face voice-monotone)
  60. (font-latex-warning-face voice-bolden-and-animate)
  61. ))
  62. ;;}}}
  63. ;;{{{ Marking structured objects:
  64. (defadvice LaTeX-fill-paragraph (after emacspeak pre act comp)
  65. "Provide auditory feedback."
  66. (when (interactive-p)
  67. (emacspeak-auditory-icon 'fill-object)))
  68. (defadvice LaTeX-mark-section (after emacspeak pre act)
  69. "Speak the first line.
  70. Also provide an auditory icon. "
  71. (when (interactive-p)
  72. (emacspeak-speak-line)
  73. (emacspeak-auditory-icon 'mark-object)))
  74. (defadvice LaTeX-mark-environment (after emacspeak pre act)
  75. "Speak the first line.
  76. Also provide an auditory icon. "
  77. (when (interactive-p)
  78. (emacspeak-speak-line)
  79. (emacspeak-auditory-icon 'mark-object)))
  80. (defadvice LaTeX-format-paragraph (after emacspeak pre act )
  81. "Provide auditory feedback"
  82. (when (interactive-p)
  83. (emacspeak-auditory-icon 'fill-object)
  84. (message "Filled current paragraph")))
  85. (defadvice LaTeX-format-region (around emacspeak pre act )
  86. "Ask for confirmation.
  87. Provide auditory feedback after formatting region"
  88. (cond
  89. ((and (interactive-p)
  90. (y-or-n-p "Really format region? "))
  91. ad-do-it
  92. (emacspeak-auditory-icon 'fill-object)
  93. (message "Reformatted region"))
  94. ((not (interactive-p)) ad-do-it))
  95. ad-return-value)
  96. ;;}}}
  97. ;;{{{ delimiter matching:
  98. (defadvice LaTeX-find-matching-begin (after emacspeak pre act)
  99. "Provide auditory feedback. "
  100. (when (interactive-p)
  101. (emacspeak-speak-line)))
  102. (defadvice LaTeX-find-matching-end (after emacspeak pre act)
  103. "Provide auditory feedback. "
  104. (when (interactive-p)
  105. (emacspeak-speak-line)))
  106. (defadvice LaTeX-close-environment (after emacspeak pre act)
  107. "Speak the inserted line. "
  108. (when (interactive-p)
  109. (emacspeak-auditory-icon 'close-object)
  110. (emacspeak-read-previous-line)))
  111. (defadvice TeX-insert-quote(around emacspeak pre act com)
  112. "Speak quotes that were inserted."
  113. (cond
  114. ((interactive-p)
  115. (let ((orig (point)))
  116. ad-do-it
  117. (emacspeak-speak-region orig (point))))
  118. (t ad-do-it))
  119. ad-return-value)
  120. (loop for f in
  121. '(TeX-insert-dollar TeX-insert-backslash
  122. LaTeX-babel-insert-hyphen)
  123. do
  124. (eval
  125. `(defadvice ,f (after emacspeak pre act comp)
  126. "Speak what you inserted"
  127. (when (interactive-p)
  128. (emacspeak-speak-this-char (preceding-char ))))))
  129. ;;}}}
  130. ;;{{{ Inserting structures
  131. (defadvice TeX-newline (after emacspeak pre act comp)
  132. "Provide auditory feedback to indicate indentation."
  133. (when (interactive-p)
  134. (emacspeak-speak-line)))
  135. (defadvice LaTeX-insert-item (after emacspeak pre act)
  136. "Provide auditory feedback. "
  137. (when (interactive-p)
  138. (emacspeak-speak-line )))
  139. (defadvice LaTeX-environment (after emacspeak pre act)
  140. "Provide auditory feedback, by speaking
  141. the opening line of the newly inserted environment. "
  142. (when (interactive-p)
  143. (emacspeak-auditory-icon 'open-object)
  144. (emacspeak-read-previous-line)))
  145. (defadvice TeX-insert-macro (around emacspeak pre act)
  146. "Provide spoken feedback."
  147. (let ((opoint (point )))
  148. ad-do-it
  149. (emacspeak-speak-region opoint (point))))
  150. ;;}}}
  151. ;;{{{ Commenting chunks:
  152. (defadvice TeX-comment-region (after emacspeak pre act)
  153. "Provide spoken and auditory feedback. "
  154. (when (interactive-p)
  155. (emacspeak-speak-line)
  156. (emacspeak-auditory-icon 'select-object)))
  157. (defadvice TeX-un-comment (after emacspeak pre act)
  158. "Provide spoken and auditory feedback. "
  159. (when (interactive-p)
  160. (emacspeak-speak-line)
  161. (emacspeak-auditory-icon 'select-object)))
  162. (defadvice TeX-un-comment-region (after emacspeak pre act)
  163. "Provide spoken and auditory feedback. "
  164. (when (interactive-p)
  165. (emacspeak-speak-line)
  166. (emacspeak-auditory-icon 'select-object)))
  167. (defadvice TeX-comment-paragraph (after emacspeak pre act)
  168. "Provide spoken and auditory feedback. "
  169. (when (interactive-p)
  170. (emacspeak-speak-line)
  171. (emacspeak-auditory-icon 'select-object)))
  172. ;;}}}
  173. ;;{{{ Debugging tex
  174. (defadvice TeX-next-error (after emacspeak pre act)
  175. "Speak the error line. "
  176. (when (interactive-p)
  177. (emacspeak-auditory-icon 'select-object)
  178. (emacspeak-speak-line )))
  179. ;;}}}
  180. ;;{{{ Hooks
  181. ;;; We add imenu settings to LaTeX-mode-hook
  182. (add-hook 'LaTeX-mode-hook
  183. (function
  184. (lambda ()
  185. (declare (special imenu-generic-expression
  186. imenu-create-index-function))
  187. (require 'imenu)
  188. (setq imenu-create-index-function 'imenu-default-create-index-function)
  189. (setq imenu-generic-expression
  190. '(
  191. (nil
  192. "^ *\\\\\\(sub\\)*section{\\([^}]+\\)"
  193. 2))))))
  194. ;;}}}
  195. ;;{{{ advice font changes
  196. (defadvice TeX-font (around emacspeak pre act comp)
  197. "Speak the font we inserted"
  198. (cond
  199. ((interactive-p)
  200. (let ((orig (point)))
  201. ad-do-it
  202. (if (ad-get-arg 0)
  203. (emacspeak-speak-line)
  204. (emacspeak-speak-region orig (point)))))
  205. (t ad-do-it))
  206. ad-return-value)
  207. ;;}}}
  208. (provide 'emacspeak-auctex)
  209. ;;{{{ emacs local variables
  210. ;;; local variables:
  211. ;;; folded-file: t
  212. ;;; byte-compile-dynamic: t
  213. ;;; end:
  214. ;;}}}