[ale] indent script problems

Allan Neal allanneal at bellsouth.net
Mon Dec 6 15:07:41 EST 2004


I got some help after a long wait on the vim list and was able to solve me
problem.  Thanks

On Sun, Dec 05, 2004 at 07:52:40PM -0500, Allan Neal wrote:
> Disclaimer:  I have sent this question to the vim list as well, but received
> no responses.
> 
> I am tring to write an indent script for my ledger files.  Here is an example:
> 
> ; Globals
> ; Year
> Y2004
> 
> ; Begin Register
> 12/2 Paycheck
>     Assets:Bank1:Checking   $100.00
>     Assets:Bank2:Savings    $100.00
>     Salary:Work
> 
> The indenting is really simple.  the indent is 0 unless the previous line is a
> line starting with a date.  Then continue to indent by &sw until a blank line
> and a date string line for the next transaction.
> 
> I am getting the indent set to 0 on the date string line, but no indenting is
> happening on the next line.  
> 
> What am I doing wrone?
> 
> Here is the script:
> 
> 
> " File Name: ledger.vim (indent file)
> " Maintainer: Allan Neal
> " Original Date: 04/12/04 10:55:20 
> " Last Update: 04/12/04 10:55:12 
> " Description: Indent the ledger file the in compliance with the ledger syntax
> " highlighting file.  Entry is flush left and all accounts are indented one ts
> 
> " Only define the funtion once
> if exists("*LedgerIndent")
> 	finish
> endif
> 
> let b:did_indent = 1
> 
> setlocal indentexpr=LedgerIndent()
> 
> function LedgerIndent()
> 	let cline = getline(v:lnum)
> 	let ind = 0
> 	if (cline =~ "^\d+")
> 		return 0
> 	endif
> 	if cline =~ "\<.*:\<.*"
> 		let ind = ind + &sw
> 	endif
> 	if cline =~ "^$"
> 		return 0
> 	endif
> 	let lnum = prevnonblank(v:lnum - 1)
> 	if lnum == 0
> 		return 0
> 	endif
> 	let pline = getline(lnum)
> 	if (indent(v:lnum - 1) != 0 && pline !~ "^$")
> 		return -1
> 	endif
> 	if ( pline =~ "^\d+" )
> 		let ind = ind + &sw
> 	endif
> 	return ind
> endfunction
> 
> " vim:sw=4
> 
> -- 
>  __^__                                          __^__
> ( ___ )----------------------------------------( ___ )
>  | / | "Engineers aren't boring people,         | \ |
>  | / | we just get excited about boring things" | \ |
>  |___|                 --Anon                   |___|
> (_____)----------------------------------------(_____)



> _______________________________________________
> Ale mailing list
> Ale at ale.org
> http://www.ale.org/mailman/listinfo/ale

-- 
 __^__                                          __^__
( ___ )----------------------------------------( ___ )
 | / | "Engineers aren't boring people,         | \ |
 | / | we just get excited about boring things" | \ |
 |___|                 --Anon                   |___|
(_____)----------------------------------------(_____)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available




More information about the Ale mailing list