Skip to content

Commit

Permalink
add c indent expression
Browse files Browse the repository at this point in the history
  • Loading branch information
martinh committed Oct 8, 2011
1 parent 4e69907 commit 38d8ae6
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions Preferences/Indentation Rules.plist
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,25 @@
</string>
<key>unIndentedLinePattern</key>
<string>^\s*((/\*|\*/|//|#|template\b.*?&gt;(?!\(.*\))|@protocol|@optional|@interface(?!.*\{)|@implementation|@end).*)?$</string>
<key>indentExpression</key>
<string>
;
; the code should return the absolute amount of whitespace to use for the current line
; return a negative number to use default indentation rules
;
(set text (current-text))
(set lineRange ((text textStorage) rangeOfLineAtLocation:(text caret)))
(set scope ((current-document) scopeAtLocation:(lineRange first)))
(cond
((scope match:"(source.c $ | source.c++ $ | source.objc $ | source.objc++ $ | meta.function.c - meta.block.c)")
0)
((/^\s*\{\}$/ findInString:(text line))
(text lengthOfIndentAtLocation:(- (lineRange first) 1)))
((/^\s*#/ findInString:(text line))
0)
(else -1)
)
</string>
</dict>
<key>uuid</key>
<string>02EB44C6-9203-4F4C-BFCB-7E3360B12812</string>
Expand Down

0 comments on commit 38d8ae6

Please sign in to comment.