Skip to content
Browse files

Make function snippets more sensible

- The snippet for a short function now actually outputs short boilerplate without useless cruft, and the tab trigger for the short function is short.
- The snippet for the full function boilerplate that you would put at the top of a file matches MATLAB's documentation-in-comments a bit better, but not perfectly, because if we all emulated MATLAB perfectly the world would explode, and it's more important to be able to read the comments in the source code than for MATLAB to be able to read the comments in the source code. Also the tab trigger is longer, as is proper. Also got rid of stupid copyright cruft.
  • Loading branch information...
1 parent b10394f commit 802ec43b0e5105910800aa147f7ae965692cd29e Daniel Grady committed with infininight Nov 3, 2010
Showing with 20 additions and 15 deletions.
  1. +9 −11 Snippets/function (fun).plist
  2. +11 −4 Snippets/small function.tmSnippet
View
20 Snippets/function (fun).plist
@@ -3,14 +3,11 @@
<plist version="1.0">
<dict>
<key>content</key>
- <string>function ${1:Output variables} = ${2:functionName}(${3:Input variables})
-$TM_COMMENT_START ${2/.*/\U$0/} ${4:Short description}
-$TM_COMMENT_START [${1/.*/\U$0/}] = ${2/.*/\U$0/}(${6:${3/.*/\U$0/}})
-$TM_COMMENT_START
-$TM_COMMENT_START ${5:Long description}
-$TM_COMMENT_START
-$TM_COMMENT_START Created by $TM_FULLNAME on `date +%Y-%m-%d`.
-$TM_COMMENT_START Copyright (c) ${TM_YEAR} ${TM_ORGANIZATION_NAME}. All rights reserved.
+ <string>function ${1:out} = ${2:f}(${3:in})
+% ${2/.*/\U$0/} ${4:Description}
+% ${1/.*/\U$0/} = ${2/.*/\U$0/}(${6:${3/.*/\U$0/}})
+%
+% ${5:Long description}
$0
@@ -19,15 +16,16 @@ $0
if [[ $TM_USE_OCTAVE -ne '0' ]]
then echo "endfunction"
else
- echo "end $TM_COMMENT_START function"
+ echo "end ${TM_COMMENT_START}function"
fi
-fi`</string>
+fi`
+</string>
<key>name</key>
<string>function</string>
<key>scope</key>
<string>source.matlab, source.octave</string>
<key>tabTrigger</key>
- <string>fun</string>
+ <string>function</string>
<key>uuid</key>
<string>0EA9BDAD-6EA3-48C4-ADF5-EA549D84CAF0</string>
</dict>
View
15 Snippets/small function.tmSnippet
@@ -3,15 +3,22 @@
<plist version="1.0">
<dict>
<key>content</key>
- <string>%% ${1:functionname}: ${2:function description}
-function [${3:outputs}] = ${1}(${4:arg})
-${3/,?\s*([a-zA-Z]\w*)|,\s*/(?1:\t$1 = ;\n)/g}</string>
+ <string>function ${1:out} = ${2:f}(${3:in})
+ $0
+`if [[ $TM_CLOSE_FUNCTIONS -ne '0' ]]
+ then
+ if [[ $TM_USE_OCTAVE -ne '0' ]]
+ then echo "endfunction"
+ else
+ echo "end"
+ fi
+fi`</string>
<key>name</key>
<string>small function</string>
<key>scope</key>
<string>source.matlab, source.octave</string>
<key>tabTrigger</key>
- <string>func</string>
+ <string>f</string>
<key>uuid</key>
<string>2376F2E2-E240-422F-B6E8-48B6AA20C9EE</string>
</dict>

0 comments on commit 802ec43

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