branch: externals/caml
commit 02303eadd6ae9b92a19b4e220e096f29c8e4bce3
Author: Damien Doligez <damien.doligez-inria.fr>
Commit: Damien Doligez <damien.doligez-inria.fr>
PR#5727: emacs caml-mode indents shebang line in toplevel scripts
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@12974
f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
---
caml.el | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/caml.el b/caml.el
index a203584..5eda10b 100644
--- a/caml.el
+++ b/caml.el
@@ -1199,6 +1199,11 @@ Used to distinguish it from toplevel let construct.")
(defconst caml-kwop-regexps (make-vector 9 nil)
"Array of regexps representing caml keywords of different priorities.")
+(defun caml-in-shebang-line ()
+ (save-excursion
+ (beginning-of-line)
+ (and (= 1 (point)) (looking-at "#!"))))
+
(defun caml-in-expr-p ()
(let ((pos (point)) (in-expr t))
(caml-find-kwop
@@ -1206,6 +1211,8 @@ Used to distinguish it from toplevel let construct.")
caml-matching-kw-regexp "\\|"
(aref caml-kwop-regexps caml-max-indent-priority)))
(cond
+ ; special case for #! at beginning of file
+ ((caml-in-shebang-line) (setq in-expr nil))
; special case for ;;
((and (> (point) 1) (= (preceding-char) ?\;) (= (following-char) ?\;))
(setq in-expr nil))