2 " Maintainer : Gergely Kontra <kgergely@mcl.hu>
3 " Revised on : 2002.02.18. 23:34:05
7 " checking with respect to syntax highlighting
8 " ignoring multiline comments
9 " detecting multiline strings
11 " Only load this indent file when no other was loaded.
12 if exists("b:did_indent")
18 setlocal indentexpr=GetPrologIndent()
19 setlocal indentkeys-=:,0#
20 setlocal indentkeys+=0%,-,0;,>,0)
22 " Only define the function once.
23 "if exists("*GetPrologIndent")
27 function! GetPrologIndent()
28 " Find a non-blank line above the current line.
29 let pnum = prevnonblank(v:lnum - 1)
30 " Hit the start of the file, use zero indent.
34 let line = getline(v:lnum)
35 let pline = getline(pnum)
37 let ind = indent(pnum)
38 " Previous line was comment -> use previous line's indent
42 " Check for clause head on previous line
43 if pline =~ ':-\s*\(%.*\)\?$'
45 " Check for end of clause on previous line
46 elseif pline =~ '\.\s*\(%.*\)\?$'
49 " Check for opening conditional on previous line
50 if pline =~ '^\s*\([(;]\|->\)'
53 " Check for closing an unclosed paren, or middle ; or ->
54 if line =~ '^\s*\([);]\|->\)'