Sublime Forum

Underline Functions

#1

hi
i present my first plugin ever. This is also my first useful python script, so input regarding style and effectiveness is very welcome :smile:

It underlines all lines with function definitions (based on the selector entity.name.function). for most languages very useful. does not look so great in header files though.

in my opinion, it makes code better readable. this way, functions act more like headlines in an article.

its quite possible that there are performance issues with large files. please let me know if you encounter them.

you can get it at github.com/menodev/sublime_exte … nctions.py

this is how it looks (the line color is the same as the comments)
http://www0.xup.in/exec/ximg.php?fid=20280769

0 Likes

#2

I just take a quick look at the code and I think there is effectively some performance issues, but as I didn’t try it I couldn’t say how bad it is.
You didn’t make anything wrong cause actually there isn’t any proper option to achieve efficiently what you want to do.

The function find_all_function_lines parse every character in the buffer to check the scope_name, so for multi-megabytes files it’s a very intensive task.

I already ask for a better way to achieve this in userecho http://sublimetext.userecho.com/feedback/22398-api-enhance-viewget_symbols-to-return-arbitrary-symbol-list/, fell free to vote for this.
The solution is to have a function that return the Regions containing the scope you look for, something like a find_all_scope(‘entity.name.function’) or get_symbols(‘entity.name.function’).

0 Likes

#3

yes thats true. for normal sized files its absolutely fast and i feel no delay because of the script. really big files (which shouldnt happen anyway) will definitely have problems with this plugin.

i tried to find a function like you are suggesting and i did not find it so im going this expensive way. if you know a better way as of now im would be happy to hear it.
i voted your request.

0 Likes