drupal-sublimetext
drupal-sublimetext copied to clipboard
hook snippets should only grab up to the first '.'
When the hook code snippets grab the filename, they grab everything up to the last '.'
This works fine for any .module, .install etc but doesn't work anytime you have a file like modulename.views.inc etc as it creates:
function modulename.views($vars) {}
Here's a regular expression that changes that behavior: ^[^.]+(?=.)
I tried editing hook.sublime-snippet but it didn't seem to make a difference.
Ok, so editing that file did end up working but my regular expression is a bit off. Regex isn't my strong suit.
If you get a a fix for this, I'd definitely roll it in!
I'll poke around. I should also note that I am on Sublime 3, so it's certainly possible that that is causing issues as well, being a beta and all :)
I just pushed some changes to all the hooks that should fix this. I had forgotten that this was fixed in the generic "hook" snippet. Give it a try and let me know if it works for you.
Thanks,
Rob
Howdy.. nice project :)
I actually had a suggestion related to this topic. I looks like the snippets currently use the active filename (minus suffix) to determine the proper function prefixes. On large projects things are often broken out into lots of files, so I was thinking it might be nice to take the top level module or theme directory name, like:
..../sites/
I've been playing around with this, and the following expression seems to work:
${TM_FILEPATH/.+(?:\/|\\)(?:themes|modules)(?:\/|\\)(.+)(?:\/|\\).*/$1/}
I'm working on OS X/Linux, but I tried to put backslashes in for Windows also.
Just something to consider... :) Thanks...
That's a really good idea. Hopefully I can play around with that soon and try it out!
Actually that first attempt didn't take into account further directory nesting... Ooops.. but you can give this one a try. I imagine it could be optimized, regex is not my day job. :)
${1:${TM_FILEPATH/.+(?:\/|\\)(?:themes|modules)(?:\/|\\)([a-zA-Z0-9_]+)(?:\/|\\).*/$1/}}