 	     *ojs-compilation-buffer-name*))
       (set-process-query-on-exit-flag (get-process buffer-name) nil))
     (set-process-filter proc 'ojs-compilation-filter)
+    (switch-to-buffer-other-window buffer-name t)
+    (erase-buffer)
     (process-send-string *ojs-compilation-buffer-name* (format "(javascript::check-js-syntax %S)\n" selection))))
-	 
+
+(defun compile-ojs-region (beg end)
+  (interactive (if (use-region-p)
+                   (list (region-beginning) (region-end))
+                 (list (point-min) (point-max))))
+  (let* ((selection (buffer-substring-no-properties beg end))
+	 (buffer-name *ojs-compilation-buffer-name*)
+	 (buffer (or (get-buffer buffer-name)
+		     (get-buffer-create buffer-name)))
+	 (proc (get-buffer-process buffer))
+	 (v2 (eq major-mode 'pjs-mode))
+	 )
+    (unless proc
+      (setq proc
+	    (fi:open-lisp-listener
+	     -1
+	     *ojs-compilation-buffer-name*))
+      (set-process-query-on-exit-flag (get-process buffer-name) nil))
+    (set-process-filter proc 'ojs-compilation-filter)
+    (switch-to-buffer-other-window buffer-name t)
+    (erase-buffer)
+    (process-send-string *ojs-compilation-buffer-name* (format "(jvs::emacs-check-and-compile-script %S %s)\n" selection v2))))
+
 
 (defun do-compile-and-sync-ojs-file (type)
   ;; find the script name
   (let* ((script-name      (file-name-base (buffer-file-name)))
-	 (script           (when (fi::lep-open-connection-p) (fi:eval-in-lisp (format "(when (fboundp 'jvs::find-script)(jvs::find-script \"%s\"))" script-name))))
+	 (script           (or (when (fi::lep-open-connection-p) (fi:eval-in-lisp (format "(when (fboundp 'jvs::find-script)(jvs::find-script \"%s\"))" script-name)))
+			       ;; try to get a comment //PLWSCRIPT :
+			       (save-excursion
+				 (goto-char (point-min))
+				 (when (re-search-forward "^//\\s-*PLWSCRIPT\\s-*:\\s-*\\(.*\\)\\s-*$" (point-max) t)
+				   (match-string 1)))))
 	 (buffer-name *ojs-compilation-buffer-name*)
 	 (buffer (or (get-buffer buffer-name)
 		     (get-buffer-create buffer-name)))

	   )
	  ((and (stringp string)
		(string-match ":EXIT-JS" string)) ;; exit when we read this, returned by the compilation functions
	   (fi::subprocess-filter proc (substring string 0 (string-match ":EXIT-JS" string)))
	   ;;(delete-process proc)
	   )	  
	  (t

;;;; (:require-patch "")
;;;; HISTORY :
;;;; $Log$
;;;; Revision 3.27  2015/12/10 14:50:40  troche
;;;; * C-cr to compile and run selected region
;;;;
;;;; Revision 3.26  2015/12/07 12:30:12  troche
;;;; * check-ojs-region new binding
;;;;
