(d-quote defadvice compile-goto-error (around dlisp activate)
  (save-excursion
    (beginning-of-line)
    (let (str file line)
      ;;(debug)
      (cond
       ((re-search-forward "\\.sjs:[0-9]*)" (point-at-eol) t)
        ;;(error "smeg")
        (setq str (sjs-current-line-as-string))
        ;;(debug)
        (setq i 0)
        (while (/= (aref str i) ?\( )
          (incf i))
        ;;(error "e")
        (setq str (substring str i))
        (assert (string-match "^(\\(.*\\):\\(.*\\))[\r\n]*" str))
        (setq file (substring str (match-beginning 1) (match-end 1)))
        (setq line (read (substring str (match-beginning 2) (match-end 2))))
        (find-file file)
        (goto-line line))
       ((re-search-forward "\\(^[^ ]*\\.sjs\\):\\([0-9]+\\):" (point-at-eol) t)
        ;;(debug)
        (setq file (buffer-substring-no-properties (match-beginning 1) (match-end 1)))
        (setq line (read (buffer-substring-no-properties (match-beginning 2) (match-end 2))))
        (if (string-match "^m4:" file)
            (setq file (substring file (match-end 0))))

        (find-file file)
        (goto-line line))
       (t
        ad-do-it)))))

(setq compilation-finish-functions 
      (cons 'sjs-compilation-finish-function compilation-finish-functions))
;;(setq compilation-finish-functions (reverse compilation-finish-functions))

(defun sjs-compilation-finish-function (buf msg)

  (d-quote if (get-buffer "*compilation*")
      (save-excursion
        (set-buffer "*compilation*")
        (read-only-mode 0)
        ;;(d-foo)
        (when (string-match "sjs-tutorials" default-directory)
          (sjs-splat-re "(\\([^() ]*\\)\\.java" "(\\1.sjs")
          (sjs-splat-re "\\(^[^()> ]*\\)\\.java" "\\1.sjs")
          )
        ))

  (redraw-display)

  (d-quote save-excursion
    ;;
    ;; COOL: cosmetic here it is!
    ;;
    (goto-char (point-min))
    (when (re-search-forward "^emacs --batch " nil t)
      (beginning-of-line)
      (forward-line 1)
      (setq p (point))
      (while (looking-at "^Fontifying ")
        (sjs-delete-line))
      (while (looking-at "^Loading /usr")
        (sjs-delete-line))
      (while (looking-at "^uim\\.el: ")
        (sjs-delete-line))
      (while (looking-at "^Loading /usr")
        (sjs-delete-line)))))
