Skip to content

Commit

Permalink
Add @ expantion to memoized ivar
Browse files Browse the repository at this point in the history
  • Loading branch information
elia authored and infininight committed Sep 14, 2015
1 parent 2b650de commit 5c9f974
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
39 changes: 39 additions & 0 deletions Commands/@variable ||= memoized.tmCommand
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>beforeRunningCommand</key>
<string>nop</string>
<key>command</key>
<string>#!/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby -wKU
line_number = ENV['TM_LINE_NUMBER'].to_i - 1
line = STDIN.lines.to_a[line_number-1]
ivar_name = 'instance_variable'
ivar_name = $1 if line =~ /def (?:self\.)?([a-z\d_]+)/i
print "@${1:#{ivar_name}} ||= $0"
</string>
<key>input</key>
<string>document</string>
<key>inputFormat</key>
<string>text</string>
<key>name</key>
<string>@variable ||= memoized</string>
<key>outputCaret</key>
<string>afterOutput</string>
<key>outputFormat</key>
<string>snippet</string>
<key>outputLocation</key>
<string>atCaret</string>
<key>scope</key>
<string>source.ruby</string>
<key>tabTrigger</key>
<string>@</string>
<key>uuid</key>
<string>20ACDEEE-1F1D-4CFB-8B66-940E902693EF</string>
<key>version</key>
<integer>2</integer>
</dict>
</plist>
1 change: 1 addition & 0 deletions info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
<string>0BA2B2F1-E767-4A03-9791-0AC0183251F1</string>
<string>B46D35B8-5DEB-4C10-A110-BA1965A2EB9C</string>
<string>97054C4D-E4A3-45B1-9C00-B82DBCB30CAD</string>
<string>20ACDEEE-1F1D-4CFB-8B66-940E902693EF</string>
<string>------------------------------------</string>
<string>2BB6D28F-914E-4132-BC53-E43CF5060BFA</string>
</array>
Expand Down

0 comments on commit 5c9f974

Please sign in to comment.