PageRenderTime 40ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/emacspeak-29.0/lisp/emacspeak-flyspell.el

#
Emacs Lisp | 115 lines | 43 code | 18 blank | 54 comment | 1 complexity | 5fe7258f0dccc4d75a92101d802bdadf MD5 | raw file
Possible License(s): MIT
  1. ;;; emacspeak-ispell.el --- Speech enable Ispell -- Emacs' interactive spell checker
  2. ;;; $Id: emacspeak-flyspell.el 5798 2008-08-22 17:35:01Z tv.raman.tv $
  3. ;;; $Author: tv.raman.tv $
  4. ;;; Description: Emacspeak extension to speech enable flyspell
  5. ;;; Keywords: Emacspeak, Ispell, Spoken Output, fly spell checking
  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: 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. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  37. ;;{{{ Introduction:
  38. ;;; Commentary:
  39. ;;; This module speech enables flyspell.
  40. ;;}}}
  41. ;;{{{ Requires
  42. (require 'emacspeak-preamble)
  43. ;;}}}
  44. ;;{{{ define personalities
  45. (defgroup emacspeak-flyspell nil
  46. "Emacspeak support for on the fly spell checking."
  47. :group 'emacspeak
  48. :group 'flyspell
  49. :prefix "emacspeak-flyspell-")
  50. (voice-setup-add-map
  51. '(
  52. (flyspell-incorrect-face voice-bolden)
  53. ))
  54. ;;}}}
  55. ;;{{{ advice
  56. (declaim (special flyspell-delayed-commands))
  57. (push 'emacspeak-self-insert-command flyspell-delayed-commands)
  58. (defadvice flyspell-auto-correct-word (around emacspeak pre act comp)
  59. "Speak the correction we inserted"
  60. (cond
  61. ((interactive-p)
  62. ad-do-it
  63. (dtk-speak (car (flyspell-get-word nil)))
  64. (emacspeak-auditory-icon 'select-object))
  65. (t ad-do-it))
  66. ad-return-value)
  67. (defadvice flyspell-unhighlight-at (before debug pre act comp)
  68. (let ((overlay-list (overlays-at pos))
  69. (o nil))
  70. (while overlay-list
  71. (setq o (car overlay-list))
  72. (when (flyspell-overlay-p o)
  73. (put-text-property (overlay-start o)
  74. (overlay-end o)
  75. 'personality nil))
  76. (setq overlay-list (cdr overlay-list)))))
  77. ;;}}}
  78. ;;{{{ Highlighting the error
  79. (defun emacspeak-flyspell-highlight-incorrect-word (beg end ignore)
  80. "Put property personality with value
  81. `voice-animate' from beg to end"
  82. (declare (special voice-animate))
  83. (ems-modify-buffer-safely
  84. (put-text-property beg end 'personality
  85. voice-animate))
  86. (emacspeak-speak-region beg end)
  87. nil)
  88. (add-hook 'flyspell-incorrect-hook 'emacspeak-flyspell-highlight-incorrect-word)
  89. ;;}}}
  90. (provide 'emacspeak-flyspell)
  91. ;;{{{ emacs local variables
  92. ;;; local variables:
  93. ;;; folded-file: t
  94. ;;; byte-compile-dynamic: t
  95. ;;; end:
  96. ;;}}}