Skip to content

Commit

Permalink
Tools: formating script
Browse files Browse the repository at this point in the history
formating scritp

fix script

fix script
  • Loading branch information
hhugo committed Mar 8, 2014
1 parent 90e06eb commit 05a0542
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .ocp-indent
@@ -0,0 +1,2 @@
normal
syntax=lwt mll
30 changes: 30 additions & 0 deletions tools/emacs-format-js.el
@@ -0,0 +1,30 @@
;;; File: emacs-format-file
;;; Stan Warford
;;; 17 May 2006

(setq js-indent-level 2)
(custom-set-variables
'(indent-tabs-mode nil)
'(tab-width 2))

(defun emacs-format-js ()
"Format the whole buffer."
(js-mode)
(indent-region (point-min) (point-max) nil)
(delete-trailing-whitespace)
(save-buffer)
)

(defun emacs-format-js-ident ()
"Format the whole buffer."
(js-mode)
(indent-region (point-min) (point-max) nil)
(save-buffer)
)

(defun emacs-format-js-clean ()
"Format the whole buffer."
(js-mode)
(delete-trailing-whitespace)
(save-buffer)
)
24 changes: 24 additions & 0 deletions tools/emacs-format-ocaml.el
@@ -0,0 +1,24 @@
;;; File: emacs-format-file
;;; Stan Warford
;;; 17 May 2006

(defun emacs-format-function ()
"Format the whole buffer."
(tuareg-mode)
(indent-region (point-min) (point-max) nil)
(delete-trailing-whitespace)
(save-buffer)
)

(defun emacs-format-function-ident ()
"Format the whole buffer."
(tuareg-mode)
(indent-region (point-min) (point-max) nil)
(save-buffer)
)

(defun emacs-format-function-clean ()
"Format the whole buffer."
(delete-trailing-whitespace)
(save-buffer)
)
9 changes: 9 additions & 0 deletions tools/format-js.sh
@@ -0,0 +1,9 @@
#!/bin/bash

echo "# Removing tabs"
find ./ -regex "^\.\(/[a-zA-Z0-9_-.]*\)*.js" -exec sed -i 's/ //g' {} \;

echo "# Indent files"
SCRIPT=$(readlink -f $0)
SCRIPTPATH=`dirname $SCRIPT`
find ./ -regex "^\.\(/[a-zA-Z0-9_-.]*\)*.js" -exec emacs -batch {} -l ${SCRIPTPATH}/emacs-format-js.el -f emacs-format-js \;
12 changes: 12 additions & 0 deletions tools/format-ocaml.sh
@@ -0,0 +1,12 @@
#!/bin/bash

echo "# Removing tabs"
find ./ -regex "^\.\(/[a-zA-Z0-9_-.]*\)*\.ml[il]?" -exec sed -i 's/ //g' {} \;

echo "# Whitespace"
SCRIPT=$(readlink -f $0)
SCRIPTPATH=`dirname $SCRIPT`
find ./ -regex "^\.\(/[a-zA-Z0-9_-.]*\)*\.ml[il]?" -exec emacs -batch {} -l ${SCRIPTPATH}/emacs-format-ocaml.el -f emacs-format-function-clean \;

echo "# Indent files"
find ./ -regex "^\.\(/[a-zA-Z0-9_-.]*\)*\.ml[il]?" -exec ocp-indent -i {} \;

0 comments on commit 05a0542

Please sign in to comment.