Peter Szilagyi avatar Peter Szilagyi committed 677d8e0

Added an environment parameter, TUAREG_INDENT_USE_USER_DOT_EMACS, to
support finding Tuareg in a non-standard location.

Comments (0)

Files changed (1)

ocaml/contrib/ocp-indent/tools/tuareg-indent

 tuareg-indent() {
     local f=$1; shift
     local config=$(ocp-config-to-tuareg $*)
-    local tuareg=$(ls /usr/share/emacs*/site-lisp/tuareg-mode/tuareg.elc 2>/dev/null \
-                || ls /usr/share/emacs/site-lisp/tuareg-mode/tuareg.el)
-    emacs $f -Q -batch --eval '(progn (load-file "'"$tuareg"'") (tuareg-mode) '"$config"' (setq indent-tabs-mode nil) (indent-region (point-min) (point-max)) (set-visited-file-name "'/dev/stdout'") (save-buffer 0))' 2>/dev/null || true
+    # At Jane Street, and perhaps other sites, Tuareg is found via the
+    # user's ~/.emacs, rather than in a standard location in /usr.  We
+    # may also wish to compare against standard or custom user config.
+    if [ -n "${TUAREG_INDENT_USE_USER_DOT_EMACS}" ]; then
+        local tuareg=tuareg
+        local quick=
+    else
+        local tuareg=$(
+            ls /usr/share/emacs*/site-lisp/tuareg-mode/tuareg.elc 2>/dev/null \
+                || ls /usr/share/emacs/site-lisp/tuareg-mode/tuareg.el
+        )
+        local quick=-Q
+    fi
+    emacs $f $quick -batch --eval '
+      (progn
+        (load-file "'"$tuareg"'")
+        (tuareg-mode)
+        '"$config"'
+        (setq indent-tabs-mode nil)
+        (indent-region (point-min) (point-max))
+        (set-visited-file-name "/dev/stdout")
+        (save-buffer 0))
+    ' 2>/dev/null || true
 }
 
+# CR pszilagyi: This will whitespace-split individual arguments.
 args=
 while [ $# -gt 1 ]; do args="$args $1"; shift; done
 file=$1
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.