[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Search]

emacspeak mozrepl fixes



Hi,

I've fixed some bugs in emacspeak-moz.el, emacspeak.js and adom.js to
get emacspeak-moz working.  I'm using mozrepl v1.0.0.2009.041717 and
firefox 3.0.6.  Here's a description of what problems i had and what i
changed and i've attached the outputs of svn diff for the three files.

BUG: emacspeak-moz-goto-url() and emacspeak-moz-goto-url-at-point() killed repl
FIX: In lisp/emacspeak-moz.el lines 169, 183
window.location.href changed to content.location.href

BUG: adom.js not loading properly
FIX: In js/adom.js line 487
changed repl.prototype.updateADom to repl.updateADom

BUG: ADom not auto updating
INFO: Depending on when mozrepl is started, window may or may not yet have
loaded, if it hasn't, need to listen for window load event before
setting browser load event up to run updateADom. (This is what it was
doing). But if the window has already loaded, there won't be a window
load event so mustn't wait for it.
FIX: In js/emacspeak.js line 40ish
Modified to try to do both but makes sure it only sets the browser
load listener once.  Is there a nicer way to fix this?

BUG: repl.emacspeak.init() is ran more than once
INFO: in lisp/emacspeak-moz.el, emacspeak-moz-init is added as hook on
inferior-moz-mode-hook.  It's also added in defadvice for
inferior-moz-start-process.
FIX: commented out the defadvice (Was this the correct one to get rid of?)

BUG: repl.emacspeak.say() causes error from tts and doesn't speak
INFO: Trys to do a get, looks like only post works at the moment.
(do_GET in servers/python/HTTPSpeaker.py is broken, doesn't assign
anything to cmd or arg.  Probably a simple fix for someone else).
FIX: changed repl.emacspeak.say() 108ish to use post method instead of get.

BUG: emacspeak-moz-eval-expression-and-browse browsing wrong buffer
INFO: emacspeak-moz.el line 112, browse-url-of-buffer was somehow picking
up *MozRepl* instead of *moz output* as current buffer.  Worked fine
if single stepped.  weird.  Probably worth someone that knows what
they're doing looking at this, might be hiding something else.
FIX: added explicit buffer argument.

Sean

Index: js/adom.js
===================================================================
--- js/adom.js	(revision 6157)
+++ js/adom.js	(working copy)
@@ -484,7 +484,7 @@
  * Update adom pointer in repl to point to current document.
  * @return {ADom}
  */
-repl.prototype.updateADom = function ()  {
+repl.updateADom = function ()  {
     if (content.document.adom == undefined) {
         // constructor caches adom in content.document
         repl.adom = new ADom(content.document);
Index: js/emacspeak.js
===================================================================
--- js/emacspeak.js	(revision 6157)
+++ js/emacspeak.js	(working copy)
@@ -37,17 +37,23 @@
  */
 
 Emacspeak.prototype.init = function() {
+  function setupUpdateADom(){
+    if (repl.setupUpdateADomRan) return;
+    if(window.gBrowser){
+      gBrowser.addEventListener('load', repl.updateADom, true);
+      repl.setupUpdateADomRan = true;
+    }
+  }
   try {
     var js = 'file://localhost' + this.path_ + 'js/';
     repl.load(js + 'di.js');
     repl.load(js + 'adom.js');
-    window.addEventListener(
-                        "load",
-                        function () {
-                                     gBrowser.addEventListener('load', repl.updateADom, true);
-                                     },
-                        false);
 
+    // for if the window hasn't loaded yet:
+    window.addEventListener("load", setupUpdateADom, false);
+    // for if the window has already loaded:
+    setupUpdateADom();
+
     this.say('Emacspeak Enabled Firefox');
   } catch (err) {
     repl.print('Error during init ' + err);
@@ -80,12 +86,22 @@
  @param {string} text to speak.
  * @return void
  */
+//Emacspeak.prototype.say = function(text) {
+//  var url = this.url_ + 'say?' +encodeURIComponent(text);
+//  var xhr  = new XMLHttpRequest();
+//  xhr.open('GET', url,true);
+//  // xhr.onreadystatechange = function (data) {repl.print(data);};
+//  xhr.send(null);
+//};
+
+// Get method in HTTPSpeaker.py is currently broken, use post instead
 Emacspeak.prototype.say = function(text) {
-  var url = this.url_ + 'say?' +encodeURIComponent(text);
-  var xhr  = new XMLHttpRequest();
-  xhr.open('GET', url,true);
+  var url = this.url_;
+  var xhr = new XMLHttpRequest();
+  xhr.open('POST', url, true);
+  xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
   // xhr.onreadystatechange = function (data) {repl.print(data);};
-  xhr.send(null);
+  xhr.send('speak:' + text);
 };
 
 repl.print('Loaded emacspeak.js');
Index: lisp/emacspeak-moz.el
===================================================================
--- lisp/emacspeak-moz.el	(revision 6157)
+++ lisp/emacspeak-moz.el	(working copy)
@@ -149,7 +149,7 @@
                   (eq browse-url-browser-function 'browse-url-w3)
                   (eq browse-url-browser-function 'w3m-browse-url))
         (emacspeak-webutils-autospeak))
-      (browse-url-of-buffer ))))
+      (browse-url-of-buffer emacspeak-moz-output-buffer))))
 ;;;###autoload
 (defun emacspeak-moz-close-tab-or-browser ()
   "Close tab, or browser when one tab left."
@@ -166,7 +166,7 @@
                            (browse-url-url-at-point)
                            "http://";))))
   (emacspeak-moz-eval-expression
-   (format "window.location.href='%s'\n"
+   (format "content.location.href='%s'\n"
            url)))
 
 ;;;###autoload
@@ -180,7 +180,7 @@
     (cond
      (url
       (emacspeak-moz-eval-expression
-       (format "window.location.href=\"%s\";\n"
+       (format "content.location.href=\"%s\";\n"
                url))
       (message "Sent url at point to firefox."))
      (t (error "No url under point.")))))
@@ -364,10 +364,11 @@
 (add-hook 'inferior-moz-mode-hook
           'emacspeak-moz-init)
 
-(defadvice inferior-moz-start-process (after emacspeak pre act
-                                             comp)
-  "Init emacspeak ADom bits."
-  (emacspeak-moz-init))
+;(defadvice inferior-moz-start-process (after emacspeak pre act
+;                                             comp)
+;  "Init emacspeak ADom bits."
+;  (emacspeak-moz-init))
+
 (add-hook 'javascript-mode-hook
           'emacspeak-setup-programming-mode)
 ;;}}}


If you have questions about this archive or had problems using it, please send mail to:

priestdo@xxxxxxxxxxx No Soliciting!

Emacspeak List Archive | 2007 | 2006 | 2005 | 2004 | 2003 | 2002 | 2001 | 2000 | 1999 | 1998 | Pre 1998

Emacspeak Files | Emacspeak Blog