[SVN] Re: Indentation issues (Allan Odgaard)

Paulo Moura pmoura at di.ubi.pt
Thu Mar 22 00:11:35 UTC 2012


On 21/03/2012, at 12:00, textmate-dev-request at lists.macromates.com wrote:

> Message: 1
> Date: Wed, 21 Mar 2012 10:27:30 +0700
> From: Allan Odgaard <mailinglist at textmate.org>
> To: Bundle developers <textmate-dev at lists.macromates.com>
> Subject: [SVN] Re: Indentation issues
> Message-ID: <657B9C2F-2787-4F15-A239-D1923115D7C1 at textmate.org>
> Content-Type: text/plain; charset=windows-1252
> 
> On 02/03/2012, at 22.27, Paulo Moura wrote:
> 
>> TM have a "indentNextLinePattern" but not "unindentNextLinePattern". Is there a way to define a pattern such that the next line is unindented but not the current line? I tried "decreaseIndentPattern" but this setting insist on acting on the current line (while "increaseIndentPattern" acts on the next line; why the apparent lack of symmetry?).
> 
> The indentNextLinePattern affects only next line, although it ?stacks up? the indent, incase next line is also matched by this pattern. E.g.
> 
>   1. if true
>   2.    while false
>   3.       /* loop */;
>   4. /* back to normal indent */;
> 
> Here line 1 is matched and so, line 2 is indented. Line 2 is also matched, so line 3 gets double indent. Line 3 is _not_ matched, so line 4 is back to the indent of line 1.
> 
> So you don?t want full symmetry here wrt. decrease next line.

Hopefully, the example that follows will make it clear.

> Can you provide a complete Logtalk example?

A typical code example, valid for both Logtalk and Prolog:

	append([], []).
	append([List| Lists], Concatenation) :-
		append(List, Tail, Concatenation),
		append(Lists, Tail).

	append([], List, List).
	append([Head| Tail], List, [Head| Tail2]) :-
		append(Tail, List, Tail2).

This code defines two predicates, append/2 and append/3. Each predicate definition is made of two clauses. Clauses end with a dot, ".". For both predicates, the first clause is a fact and the second clause is a rule. When typing a rule, the code after the ":-"  operator is indented. This indentation is easy to automate in TM. Ideally, after typing a dot followed by a return, the indent level would be automatically decreased, getting the cursor positioned for typing the next clause. Is this second indentation rule that I have not been able to define for TM.

>> The only indentation rule I have (for the Logtalk language) is:
>> [?] But I cannot find a way to get this behavior using "decreaseIndentPattern", which results in the line ending with a "." getting unindented instead of the next line.
> 
> Right, the rules were made pretty much for C-style languages where the token that indicates ?end of block? is itself de-indented.

I understand. The issue here is really that the token that ends a clause (a Logtalk/Prolog program is made essentially of clauses for predicates), ".", is not itself de-indented as it's not written in its own line.

>> On TM2, using the same settings that work fine on TM1, indentation is driving me crazy and preventing me to switch to TM2 for everyday programming tasks. Specifically, on TM1, when you insert one of more black lines, TM1 wants to start at the same indent level as the last non-empty line. That's not usually want I want so I just hit backspace, start typing, and everything is fine. But, on TM2, after hitting backspace, the cursor just jumps to the last indent level as soon as I type the first character, forcing me to go back, again, and correct the indentation.
> 
> The new auto-correction behavior can be disabled, see http://wiki.macromates.com/FAQ/TextMate2


Thanks for the FAQ. It would be nice if the solution for disabling the auto correction behavior would be syntactically valid (even if not operative) for TM 1.x (so that the same language bundle could work on both TM 1.x and TM 2.x), however.

Cheers,

Paulo


-----------------------------------------------------------------
Paulo Jorge Lopes de Moura, PhD
Assistant Professor
Dep. of Computer Science, University of Beira Interior
6201-001 Covilhã, Portugal

Office 3.18  Ext. 3276
Phone: +351 275 242081 Fax: +351 275 319899
Email: <mailto:pmoura at di.ubi.pt>

Home page: <http://www.di.ubi.pt/~pmoura>
Research:  <http://logtalk.org/> Blog: <http://blog.logtalk.org/>
-----------------------------------------------------------------










More information about the textmate-dev mailing list