Source

ocaml-indent / ocaml-indent.el

The default branch has multiple heads

Full commit
(defconst ocaml-indent-process-buffer "*ocaml-indent-process*"
  "The name of ocaml-indent communication buffer")

(defun ocaml-indent-run ()
  (interactive)
  (let ((region-active (and transient-mark-mode mark-active)))
    (let* 
	((start-lnum
	  (save-excursion 
	    (line-number-at-pos (progn
				  (if region-active (goto-char (region-beginning)))
				  (point)))))
	 (end-lnum 
	  (save-excursion 
	    (line-number-at-pos (progn
				  (if region-active (progn
						      (goto-char (region-end))
						      (forward-char -1)))
				  (point)))))

	 (end-char
	  (save-excursion
	    (goto-char (point-min)) (forward-line end-lnum) ; to line (end-lnum + 1)
	    (point))))

      (save-excursion 

	(with-current-buffer (get-buffer-create ocaml-indent-process-buffer)
	  (erase-buffer))

	(call-process-region 1 end-char
			     "/home/jfuruse/.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)
	))))