Commits

camlspotter committed 2fc21e6

first simple elisp interface

Comments (0)

Files changed (1)

+(defconst ocaml-indent-process-buffer "*ocaml-indent-process*"
+  "The name of ocaml-indent communication buffer")
+
+(defun ocaml-indent-run ()
+  (interactive)
+  (let ((start
+	 (save-excursion 
+	   (goto-char (region-beginning))
+	   (line-beginning-position)))
+	(end 
+	 (save-excursion 
+	   (goto-char (region-end))
+	   (line-end-position))))
+
+    (save-excursion 
+      (let ((start-lnum (line-number-at-pos start))
+	    (end-lnum (line-number-at-pos end)))
+
+	(with-current-buffer (get-buffer-create ocaml-indent-process-buffer)
+	  (erase-buffer))
+
+	(call-process-region 1 end
+			     "/home/jun/.share/projects/ocaml-indent/indent" 
+			     nil ; delete
+			     ocaml-indent-process-buffer ; buffer
+			     t ;display
+			     "-lines" (format "%d-%d" start-lnum end-lnum)
+			     )
+	(display-buffer ocaml-indent-process-buffer))
+      )))