summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2014-04-28 14:32:39 +0200
committerJérémy Zurcher <jeremy@asynk.ch>2014-04-28 14:32:39 +0200
commit020b783b02ed7e31f4b96cda856b1e0d29b6b355 (patch)
tree9dfd104c37bd9681b7477d42686ab61c50ba4a3b
parent53226de6a4f69f32c6a7f49987c0f2668e97e925 (diff)
downloadvim-020b783b02ed7e31f4b96cda856b1e0d29b6b355.zip
vim-020b783b02ed7e31f4b96cda856b1e0d29b6b355.tar.gz
skeleton.rb: use extension before filetype to find a skeleton
-rwxr-xr-xskeletons.rb5
1 files changed, 3 insertions, 2 deletions
diff --git a/skeletons.rb b/skeletons.rb
index 144116b..f88ae49 100755
--- a/skeletons.rb
+++ b/skeletons.rb
@@ -10,11 +10,12 @@ EXTENSION = "erb"
filepath, filetype = ARGV
filename = File.basename( filepath )
+extension = File.extname( filename ).split( '.' )[1]
if filename =~ /\.h$/ then filetype='c_header'; end # otherwise filetype is cpp
-if filetype.nil? then filetype = File.extname( filename ).split( '.' )[1] ; end
+if filetype.nil? then filetype = extension; end
-skeleton = [ filename, filetype ].map { |s| File.join( SKELETON_DIR, "#{s}.#{EXTENSION}" ) }.find { |s| File.exist?(s) && File.readable?(s) }
+skeleton = [ filename, extension, filetype ].map { |s| File.join( SKELETON_DIR, "#{s}.#{EXTENSION}" ) }.find { |s| File.exist?(s) && File.readable?(s) }
exit if skeleton.nil?