PageRenderTime 47ms CodeModel.GetById 13ms RepoModel.GetById 1ms app.codeStats 0ms

/emacspeak-29.0/lisp/emacspeak-piglets.el

#
Emacs Lisp | 186 lines | 91 code | 23 blank | 72 comment | 5 complexity | 8ba668c8ea48e34626ec4e44c9abfd7b MD5 | raw file
Possible License(s): MIT
  1. ;;; emacspeak-piglets.el.el --- Result of large pigs connecting over a socket
  2. ;;; $Id: emacspeak-piglets.el 5798 2008-08-22 17:35:01Z tv.raman.tv $
  3. ;;; $Author: tv.raman.tv $
  4. ;;; Description: Result of connecting Emacs and Firefox
  5. ;;; Keywords: Emacspeak, Audio Desktop Firefox, Piglets
  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: 2008-07-02 16:44:27 -0700 (Wed, 02 Jul 2008) $ |
  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. ;;; MozRepl provides a read-eval-print loop into Firefox
  40. ;;; Module emacspeak-moz provides convenient functions for driving MozRepl
  41. ;;; Consequently, Emacs and Firefox connect over a socket 4242
  42. ;;; See http://repo.hyperstruct.net/mozlab
  43. ;;; Using that module, you can connect two large pigs ---
  44. ;;; Emacs and Firefox via a socket ---
  45. ;;; the result as you can expect is to produce piglets.
  46. ;;; This module provides the needed Emacs plumbing
  47. ;;; To drive Firefox from Emacs.
  48. ;;; Install Firefox extension Fire-Vox to provide spoken output from the Firefox side.
  49. ;;; Use commands provided by emacspeak-moz.el
  50. ;;; to render the Firefox DOM using Emacs/W3 or Emacs/W3M
  51. ;;; Code:
  52. ;;}}}
  53. ;;{{{ Required modules
  54. (require 'cl)
  55. (declaim (optimize (safety 0) (speed 3)))
  56. (require 'emacspeak-preamble)
  57. (require 'derived)
  58. (require 'emacspeak-moz)
  59. ;;}}}
  60. ;;{{{ Constants
  61. ;;}}}
  62. ;;{{{ Define our mode:
  63. (defcustom emacspeak-piglets-tts-rate 75
  64. "Speech rate for HTTP TTS server."
  65. :type 'number
  66. :group 'emacspeak-piglets)
  67. ;;;###autoload
  68. (defun emacspeak-piglets-tts-init ()
  69. "Start TTS engine for Piglets."
  70. (interactive)
  71. (declare (special emacspeak-piglets-tts-rate
  72. dtk-program emacspeak-servers-directory))
  73. (start-process
  74. "HTTP-TTS"
  75. "* HTTP TTS *"
  76. "python"
  77. (expand-file-name
  78. "python/HTTPSpeaker.py"
  79. emacspeak-servers-directory)
  80. dtk-program
  81. "2222"
  82. (format "%d" emacspeak-piglets-tts-rate)))
  83. (define-derived-mode emacspeak-piglets-mode inferior-moz-mode
  84. "Piglets Interaction"
  85. "Major mode for Piglets interaction.
  86. Keystrokes are sent to a connected Firefox."
  87. (progn
  88. (emacspeak-piglets-tts-init)
  89. (comint-send-string
  90. (inferior-moz-process)
  91. ";\n;\nrepl.setenv('printPrompt', false)\n")
  92. (emacspeak-piglets-forward-keys)))
  93. ;;}}}
  94. ;;{{{ Interactive Commands And Keybindings:
  95. (defvar emacspeak-piglets-edit-commands
  96. (list 'emacspeak-self-insert-command
  97. 'completion-separator-self-insert-autofilling
  98. 'completion-separator-self-insert-command
  99. 'self-insert-command
  100. 'delete-char
  101. 'backward-delete-char
  102. 'backward-delete-char-untabify
  103. 'completion-kill-region)
  104. "Editting commands that emacspeak should rebind in Piglets mode")
  105. (defun emacspeak-piglets-forward-keys ()
  106. "Set up Piglets mode to forward keys to Firefox."
  107. (declare (special emacspeak-piglets-edit-commands
  108. emacspeak-piglets-mode-map))
  109. (loop for edit-command in emacspeak-piglets-edit-commands
  110. do
  111. (let ((edit-keys (where-is-internal edit-command emacspeak-piglets-mode-map)))
  112. (loop for key in edit-keys
  113. do
  114. (define-key emacspeak-piglets-mode-map key 'emacspeak-piglets-key)))))
  115. ;;;###autoload
  116. (defun emacspeak-piglets-tab ()
  117. "Send TAB to Firefox."
  118. (interactive)
  119. (comint-send-string
  120. (inferior-moz-process)
  121. (format "CLC_SR_StopSpeaking();repl.adom.keyPress(repl.adom.root(),'TAB')\n" )))
  122. ;;;###autoload
  123. (defun emacspeak-piglets-enter ()
  124. "Send enter to Firefox."
  125. (interactive)
  126. (comint-send-string
  127. (inferior-moz-process)
  128. (format "repl.adom.keyPress(repl.adom.target(),'ENTER')\n" )))
  129. ;;;###autoload
  130. (defun emacspeak-piglets-keypress (c)
  131. "Send keypress to Firefox."
  132. (interactive "%c")
  133. (comint-send-string (inferior-moz-process)
  134. (format "CLC_SR_StopSpeaking();repl.adom.keyPress(repl.adom.target(),'%c', false, false, %s)\n"
  135. c
  136. (if (and (<= 65 c)
  137. (<= c 90))
  138. "true"
  139. "false"))))
  140. ;;;###autoload
  141. (defun emacspeak-piglets-key ()
  142. "Send last keypress to Firefox."
  143. (interactive)
  144. (declare (special last-input-char))
  145. (when (interactive-p)
  146. (emacspeak-piglets-silence))
  147. (emacspeak-piglets-keypress last-input-char))
  148. ;;;###autoload
  149. (defun emacspeak-piglets-silence()
  150. "Stop speech output from FireVox."
  151. (interactive)
  152. (comint-send-string
  153. (inferior-moz-process)
  154. "CLC_SR_StopSpeaking() \n"))
  155. ;;}}}
  156. (provide 'emacspeak-piglets)
  157. ;;{{{ end of file
  158. ;;; local variables:
  159. ;;; folded-file: t
  160. ;;; byte-compile-dynamic: t
  161. ;;; end:
  162. ;;}}}