[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[no subject]
- <!--x-content-type: text/plain -->
- <!--x-date: Mon Dec 6 15:07:41 2004 -->
- <!--x-from-r13: nyynaarny ng oryyfbhgu.arg (Oyyna @rny) -->
- <!--x-message-id: [email protected] -->
- <!--x-reference: [email protected] --> "http://www.w3.org/TR/html4/loose.dtd">
- <!--x-subject: [ale] indent script problems -->
- <li><em>date</em>: Mon Dec 6 15:07:41 2004</li>
- <li><em>from</em>: allanneal at bellsouth.net (Allan Neal)</li>
- <li><em>in-reply-to</em>: <<a href="msg00221.html">[email protected]</a>></li>
- <li><em>references</em>: <<a href="msg00221.html">[email protected]</a>></li>
- <li><em>subject</em>: [ale] indent script problems</li>
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
> <a rel="nofollow" href="http://www.ale.org/mailman/listinfo/ale">http://www.ale.org/mailman/listinfo/ale</a>
--
__^__ __^__
( ___ )----------------------------------------( ___ )
| / | "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
</pre>
<!--X-Body-of-Message-End-->
<!--X-MsgBody-End-->
<!--X-Follow-Ups-->
<hr>
<ul><li><strong>Follow-Ups</strong>:
<ul>
<li><strong><a name="00250" href="msg00250.html">[ale] indent script problems</a></strong>
<ul><li><em>From:</em> esoteric at 3times25.net (Geoffrey)</li></ul></li>
</ul></li></ul>
<!--X-Follow-Ups-End-->
<!--X-References-->
<ul><li><strong>References</strong>:
<ul>
<li><strong><a name="00221" href="msg00221.html">[ale] indent script problems</a></strong>
<ul><li><em>From:</em> allanneal at bellsouth.net (Allan Neal)</li></ul></li>
</ul></li></ul>
<!--X-References-End-->
<!--X-BotPNI-->
<ul>
<li>Prev by Date:
<strong><a href="msg00247.html">[ale] Debian 2.6.8/Plextor dvd help please</a></strong>
</li>
<li>Next by Date:
<strong><a href="msg00249.html">[ale] Firefox</a></strong>
</li>
<li>Previous by thread:
<strong><a href="msg00221.html">[ale] indent script problems</a></strong>
</li>
<li>Next by thread:
<strong><a href="msg00250.html">[ale] indent script problems</a></strong>
</li>
<li>Index(es):
<ul>
<li><a href="maillist.html#00248"><strong>Date</strong></a></li>
<li><a href="threads.html#00248"><strong>Thread</strong></a></li>
</ul>
</li>
</ul>
<!--X-BotPNI-End-->
<!--X-User-Footer-->
<!--X-User-Footer-End-->
</body>
</html>