On Tue, Sep 29, 2009 at 01:08:25PM -0400, Michael Sanders wrote:
> > Functionator
> http://www.vim.org/scripts/script.php?script_id=2795

That's really neat.

Attached is a simple hack to add perl support.

-- 
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Gregory H. Margo
gmargo at yahoo/com, gmail/com, pacbell/net; greg at margofamily/org

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

--- functionator.vim.00	2009-09-29 14:37:32.000000000 -0700
+++ functionator.vim	2009-09-29 15:08:43.000000000 -0700
@@ -4,7 +4,8 @@
 " Description: Shows the name of the function the cursor is currently in when
 "              gn is pressed, and goes to the [count] line of that function when
 "              [count]gn is used.
-"              Currently supports: C, Obj-C, JavaScript, Python, and Vim script.
+"              Currently supports: C, Obj-C, JavaScript, Perl, Python, and
+"              Vim script.
 "
 "              The functions can be placed in either the 'plugin' or
 "              'autoload' directory.
@@ -42,6 +43,11 @@
 		let funBegin = search('^\s*function\s\+\w\+\s*(\w*)', 'bWce')
 		let funEnd = searchpair('*{', '', '}', 'n')
 		let funName = matchstr(getline(funBegin), '\w\+\s*(.*)')
+	elseif a:ft == 'perl'
+		let funBegin = search('^\s*sub\s\+\w\+', 'bWce')
+		let funEnd = searchpair('*{', '', '}', 'n')
+		let funName = matchstr(getline(funBegin), 'sub\s\+\w\+')
+		let funName = substitute(funName, 'sub\s\+', '', '')
 	elseif a:ft == 'python'
 		" Go to the first line number out of "if:", "while:", etc. statements
 		" inside the current function.
@@ -81,7 +87,7 @@
 endf
 
 fun functionator#GetName()
-	if &ft !~ '^\v(c|objc|javascript|python|vim)$'
+	if &ft !~ '^\v(c|objc|javascript|perl|python|vim)$'
 		return s:Warning('This filetype is currently not supported by functionator.vim.')
 	endif
 	let function = s:GetFuncName(&ft)

Raspunde prin e-mail lui