Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

add c indent expression

  • Loading branch information...
commit 38d8ae68e49ebc42c074b51b459f8de5ada88569 1 parent 4e69907
martinh martinh authored

Showing 1 changed file with 19 additions and 0 deletions. Show diff stats Hide diff stats

  1. +19 0 Preferences/Indentation Rules.plist
19 Preferences/Indentation Rules.plist
@@ -31,6 +31,25 @@
31 31 </string>
32 32 <key>unIndentedLinePattern</key>
33 33 <string>^\s*((/\*|\*/|//|#|template\b.*?&gt;(?!\(.*\))|@protocol|@optional|@interface(?!.*\{)|@implementation|@end).*)?$</string>
  34 + <key>indentExpression</key>
  35 + <string>
  36 +;
  37 +; the code should return the absolute amount of whitespace to use for the current line
  38 +; return a negative number to use default indentation rules
  39 +;
  40 +(set text (current-text))
  41 +(set lineRange ((text textStorage) rangeOfLineAtLocation:(text caret)))
  42 +(set scope ((current-document) scopeAtLocation:(lineRange first)))
  43 +(cond
  44 + ((scope match:"(source.c $ | source.c++ $ | source.objc $ | source.objc++ $ | meta.function.c - meta.block.c)")
  45 + 0)
  46 + ((/^\s*\{\}$/ findInString:(text line))
  47 + (text lengthOfIndentAtLocation:(- (lineRange first) 1)))
  48 + ((/^\s*#/ findInString:(text line))
  49 + 0)
  50 + (else -1)
  51 +)
  52 + </string>
34 53 </dict>
35 54 <key>uuid</key>
36 55 <string>02EB44C6-9203-4F4C-BFCB-7E3360B12812</string>

0 comments on commit 38d8ae6

Please sign in to comment.
Something went wrong with that request. Please try again.