PageRenderTime 64ms CodeModel.GetById 20ms RepoModel.GetById 1ms app.codeStats 0ms

/utilities/emacspeak/lisp/emacspeak-tcl.el

https://github.com/jamesnvc/emacs.d
Lisp | 210 lines | 115 code | 33 blank | 62 comment | 4 complexity | 7fd2ebb56290d1f7194df559e66306b3 MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1, LGPL-2.0, MIT, BSD-3-Clause, GPL-3.0
  1. ;;; emacspeak-tcl.el --- Speech enable TCL development environment
  2. ;;; $Id: emacspeak-tcl.el 5798 2008-08-22 17:35:01Z tv.raman.tv $
  3. ;;; $Author: tv.raman.tv $
  4. ;;; DescriptionEmacspeak extensions for tcl-mode
  5. ;;; Keywords:emacspeak, audio interface to emacs tcl
  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. ;;{{{ Introduction:
  37. ;;; Provide additional advice to tcl-mode
  38. ;;}}}
  39. ;;{{{ requires
  40. (require 'emacspeak-preamble)
  41. ;;}}}
  42. ;;{{{ voice locking:
  43. ;;; Snarfed from tcl.el /usr/local/lib/emacs/site-lisp/tcl.el
  44. (defvar tcl-proc-list
  45. '("proc" "method" "itcl_class" "public" "protected")
  46. "List of commands whose first argument defines something.
  47. This exists because some people (eg, me) use \"defvar\" et al. ")
  48. (defvar tcl-proc-regexp
  49. (concat "^\\("
  50. (mapconcat 'identity tcl-proc-list "\\|")
  51. "\\)[ \t]+")
  52. "Regexp to use when matching proc headers.")
  53. (defvar tcl-typeword-list
  54. '("global" "upvar")
  55. "List of Tcl keywords denoting \"type\". Used only for highlighting. ")
  56. ;; Generally I've picked control operators to be keywords.
  57. (defvar tcl-keyword-list
  58. '("if" "then" "else" "elseif" "for" "foreach" "break" "continue" "while"
  59. "set" "eval" "case" "in" "switch" "default" "exit" "error" "proc" "return"
  60. "uplevel" "loop" "for_array_keys" "for_recursive_glob" "for_file"
  61. "unwind_protect"
  62. ;; itcl
  63. "method" "itcl_class" )
  64. "List of Tcl keywords. Used only for highlighting.
  65. Default list includes some TclX keywords. ")
  66. ;; FIXME need some way to recognize variables because array refs look
  67. ;; like 2 sexps.
  68. (defvar tcl-type-alist
  69. '(
  70. ("expr" tcl-expr)
  71. ("catch" tcl-commands)
  72. ("set" tcl-expr)
  73. ("if" tcl-expr "then" tcl-commands)
  74. ("elseif" tcl-expr "then" tcl-commands)
  75. ("elseif" tcl-expr tcl-commands)
  76. ("if" tcl-expr tcl-commands)
  77. ("while" tcl-expr tcl-commands)
  78. ("for" tcl-commands tcl-expr tcl-commands tcl-commands)
  79. ("foreach" nil nil tcl-commands)
  80. ("for_file" nil nil tcl-commands)
  81. ("for_array_keys" nil nil tcl-commands)
  82. ("for_recursive_glob" nil nil nil tcl-commands)
  83. ;; Loop handling is not perfect, because the third argument can be
  84. ;; either a command or an expr, and there is no real way to look
  85. ;; forward.
  86. ("loop" nil tcl-expr tcl-expr tcl-commands)
  87. ("loop" nil tcl-expr tcl-commands)
  88. )
  89. "Alist that controls indentation.
  90. \(Actually, this really only controls what happens on continuation lines).
  91. Each entry looks like `(KEYWORD TYPE ...)'.
  92. Each type entry describes a sexp after the keyword, and can be one of:
  93. * nil, meaning that this sexp has no particular type.
  94. * tcl-expr, meaning that this sexp is an arithmetic expression.
  95. * tcl-commands, meaning that this sexp holds Tcl commands.
  96. * a string, which must exactly match the string at the corresponding
  97. position for a match to be made.
  98. For example, the entry for the \"loop\" command is:
  99. (\"loop\" nil tcl-expr tcl-commands)
  100. This means that the \"loop\" command has three arguments. The first
  101. argument is ignored (for indentation purposes). The second argument
  102. is a Tcl expression, and the last argument is Tcl commands.")
  103. ;;}}}
  104. ;;{{{ Advice electric insertion to talk:
  105. (defadvice tcl-electric-hash (after emacspeak pre act comp )
  106. "Speak what you inserted."
  107. (when (interactive-p)
  108. (emacspeak-speak-this-char last-input-char)))
  109. (defadvice tcl-electric-char (after emacspeak pre act comp )
  110. "Speak what you inserted."
  111. (when (interactive-p)
  112. (emacspeak-speak-this-char last-input-char)))
  113. (defadvice tcl-electric-brace (after emacspeak pre act comp )
  114. "Speak what you inserted."
  115. (when (interactive-p)
  116. (emacspeak-speak-this-char last-input-char)))
  117. ;;}}}
  118. ;;{{{ Actions in the tcl mode buffer:
  119. (defadvice switch-to-tcl (before emacspeak pre act comp)
  120. "Announce yourself."
  121. (when (interactive-p)
  122. (message "Switching to the Inferior TCL buffer")))
  123. (defadvice tcl-eval-region (after emacspeak pre act comp)
  124. "Announce what you did."
  125. (when (interactive-p)
  126. (message "Evaluating contents of region")))
  127. (defadvice tcl-eval-defun (after emacspeak pre act comp )
  128. "Announce what you did"
  129. (when (interactive-p)
  130. (let* ((start nil)
  131. (proc-line
  132. (save-excursion
  133. (tcl-beginning-of-defun)
  134. (setq start (point))
  135. (end-of-line)
  136. (buffer-substring start (point)))))
  137. (message "Evaluated %s" proc-line ))))
  138. (defadvice tcl-help-on-word (after emacspeak pre act comp)
  139. "Speak the help."
  140. (when (interactive-p)
  141. (emacspeak-auditory-icon 'help)
  142. (save-excursion
  143. (set-buffer "*Tcl help*")
  144. (emacspeak-speak-buffer ))))
  145. ;;}}}
  146. ;;{{{ Program structure:
  147. (defadvice tcl-mark-defun (after emacspeak pre act comp)
  148. "Provide auditory feedback"
  149. (when (interactive-p)
  150. (emacspeak-auditory-icon 'mark-object)
  151. (message "Marked procedure")))
  152. (defadvice tcl-beginning-of-defun (after emacspeak pre act comp)
  153. "Provide auditory feedback."
  154. (when (interactive-p)
  155. (emacspeak-auditory-icon 'large-movement)
  156. (emacspeak-speak-line )))
  157. (defadvice tcl-end-of-defun (after emacspeak pre act comp)
  158. "Provide auditory feedback."
  159. (when (interactive-p)
  160. (emacspeak-auditory-icon 'large-movement)))
  161. (defadvice indent-tcl-exp (after emacspeak pre act )
  162. "Produce an auditory icon"
  163. (when (interactive-p)
  164. (emacspeak-auditory-icon 'fill-object)))
  165. (defadvice tcl-indent-line (after emacspeak pre act)
  166. "Speak the line"
  167. (when (interactive-p)
  168. (emacspeak-speak-line)))
  169. ;;}}}
  170. (provide 'emacspeak-tcl)
  171. ;;{{{ emacs local variables
  172. ;;; local variables:
  173. ;;; folded-file: t
  174. ;;; byte-compile-dynamic: t
  175. ;;; end:
  176. ;;}}}