 (defun ems-stop ()
   (ems-teardown-bridge))
 
+
+(defun ems-test ()
+  (ems-start)
+  (ems-start-walker "\\\\frac{x}{y}")
+  ;; That does not seem to actually wait!
+  (sleep-for 2)
+  (ems-repeat)
+  (ems-down)
+  (ems-right)
+  )

             (with-current-buffer (get-buffer "*ems-output*")
               (let ((result (ems-parse-output output)))
                 (when result 
                   (insert result)
                   (insert "\n"))
                 output))))))




;; Number: The full buffer output.
;; Return: Cons with call number and result.
(defun ems-parse-output (output &optional acc)
  (let* ((start (string-match "BEGINOUTPUT[0-9]+: .* :ENDOUTPUT" output)))
    (if start
      (let* ((rest (subseq output (+ start 11)))
             (colon (string-match ": " rest))
             (number (subseq rest 0 colon))
             (rest (subseq rest (+ colon 2)))
             (end (string-match " :ENDOUTPUT" rest))
             (result (subseq rest 0 end))
             )
        ;;(push (cons (car (read-from-string number)) result) ems-results)
        (ems-parse-output (subseq rest end) 
                          (cons (cons (car (read-from-string number)) result) acc)))
      acc)))


;;; API
