Indenting style in snippets (was: [SVN] Bundle commit 576)

Chris Thomas chris at cjack.com
Mon Apr 11 07:13:02 UTC 2005


On Apr 10, 2005, at 3:21 AM, Allan Odgaard wrote:

> Another approach is to introduce placeholders in the snippets, but  
> since not only the indenting style differs [1]; giving the user  
> full control over reformatting is probably necessary.
>
> Comments?
>
> [1] e.g. space before the terminating ;, if the pointer/reference  
> specifier character (*/&) binds to the type or the name etc.

I'd actually been thinking placeholders-in-the-snippets, because it  
would handle the most jarring style issue. But piping through indent  
might be really nice. Some issues that occur to me, none of which are  
showstoppers:

1. Mac OS X's version of indent does not seem to have an option to  
output tabs instead of spaces.

2. There are lots of args to indent to specify preferred styles.  
Ultimately need a prefs panel to simplify this task, probably with a  
popup containing common option sets.

3. Users might want to use different styles in different files. For  
example, if I'm working on FSF source code, the style has to be  
<strike>atrocious</strike> GNU-compliant, but I would normally use  
BSD-style.

There are also "style" issues which indent does not handle, but might  
be handled automagically in a perfect world:

• C++, Objective-C, and Java language constructs.
• C99/C++ for-loop scope rules (declaring the variable in the  
initializer vs. not doing that)
• converting C++/C99-style line comments to /*block*/ comments.
• Switching C's dangerous increment ++/decrement -- operators with +=  
1/-= 1.
• Compound statements with only one line: remove curlybrackets (also  
vice versa)?

  if(x)
  {
      y();
  }
  <->
  if(x)
      y();

Chris




More information about the textmate-dev mailing list