-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding Word-Highlighter plugin #7417
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Automated testing result: SUCCESS
Repo link: word_highlighter
Packages added:
- word_highlighter
Processing package "word_highlighter"
- All checks passed
For a package as complex as this, you may want to look at
# before
stop_classes = sublime.CLASS_WORD_START | sublime.CLASS_WORD_END | sublime.CLASS_PUNCTUATION_START | sublime.CLASS_PUNCTUATION_END | sublime.CLASS_LINE_START | sublime.CLASS_LINE_END | sublime.CLASS_EMPTY_LINE
# after
from sublime_lib.flags import PointClass
stop_classes = PointClass('WORD_START', 'WORD_END', 'PUNCTUATION_START', 'PUNCTUATION_END', 'LINE_START', 'LINE_END', 'EMPTY_LINE') |
How much different is this plugin from: See also: #7341 Confusing names WordHighlight versus HighlightWords
Ok,, I am getting out of ideias for new names for packages. Let us supposed I got all 3 packages installed, how do I tell which one is which? All have |
Guys, thank you so much for your time.
|
I have considered renaming it to just "highlighter" (or "Highlighter") since I have a vision of coming to a point where you can use the plugin like a smart highlighter pen - not just for words. I will most likely add functionality like coloring sections of code (e.g. grouping functions by functionality) or large portions of text - where the highlight is updated with code changes (shrinks and expands). There are however some limitations in the sublime-API that make it hard to do. |
It would be best to improve the existing package rather than adding a new one. This isn't a hard requirement, but it makes more sense than having two packages with similar functionality and slightly different feature sets. Package Control is temporarily down, but I think that this repo contains the HighlightWords package. It does look like it hasn't been updated in a while. I suggest reaching out to the author and seeing if they would be interested in PRs for new features. If they are, then there may be no need for a new package. If they aren't interested in maintaining the package anymore, then they may be interested in someone else maintaining it. If they still want to maintain it but feel that the new features don't make sense for that package, then that might be a good reason to have two packages with different philosophies. On to the review comments.
The casing is what's important, not the spacing. Generally, package names begin with an uppercase letter and dependency names begin with a lowercase letter. You should use relative imports rather than hardcoding the package name.
I'll have to think about this. Generally, packages have all of their internal code in one place and use
Arguably, but patching the shared global sublime package is definitely not a good thing. At the expense of shilling my own work, “I feel like these kind of constants should exist in the sublime package” is a major reason that sublime_lib exists.
It's conventional, but I think it works without it.
Use |
I've reached out to the author of that package. I however do not feel like merging the packages for two reasons. First, it would involve a lot of work with writing tests, fixing bugs, etc. Second, I'm not sure if the users of HighlightWords would like me to actually change the functionality of the plugin.
I will have to think of a better package name if it becomes accepted into PC.
I have fixed this in the |
I use that package. On my fork I added a new feature, just did not bothered in opening a pull requests because most of them are not merged.
I think I would not like any functionality change on it. If your plugin works different, then, I think it makes sense to be released under a new name. Also, the package author did not responded about adding a open source license to his project few years back: seanliang/HighlightWords#24 Can it be an open source project?
It supports, but you need to know the secret. When I started using the UnitTesting package, I opened an issue about this: SublimeText/UnitTesting#67 To allow relative imports, you need to structure your files like this:
Where {
"tests_dir" : "tests",
"pattern" : "test*.py",
"async": false,
"deferred": false,
"verbosity": 2,
"capture_console": true,
"output": null
} |
By the way, I guess @emanuelen5 wanted to import the package relatively rather than to import a file under |
In that case, there is two alternatives:
|
@randy3k |
If you would not like to hard code the package name, you could do this: import os
import importlib
CURRENT_DIRECTORY = os.path.dirname( os.path.dirname( os.path.realpath( __file__ ) ) )
CURRENT_PACKAGE_NAME = os.path.basename( CURRENT_DIRECTORY ).rsplit('.', 1)[0]
my_package = importlib.import_module( CURRENT_PACKAGE_NAME )
my_package.some_module.some_function() Or just: import importlib
my_package = importlib.import_module( __package__ )
my_package.some_module.some_function() |
I wouldn't like to sacrifice readability of the code. Then I'd actually rather import it by name (leave it as it is). |
If you import by name, you hard code the name, so, I did not understood what you want to accomplish. |
Worked swell! Thanks.
I will migrate to |
Yes, correct. @Thom1729 wanted me to remove the hard-coded imports, that was why I was asking for alternatives. However, I do not feel like the alternatives were much better? |
For me, both ways should be fine. This last alternative seems nice: import importlib
my_package = importlib.import_module( __package__ )
my_package.some_module.some_function() I just do not recall ever needing to import my own package in my Unit Tests. Using this alternative, you will not be required to edit/change your Unit Tests code when you rename the package, which could be soon. Some names I though of:
You could open a pool on the forum https://forum.sublimetext.com And presenting your new names suggestions and allowing new name suggestions, and see which gets most voted. Just remember the name |
The issue with relative imports in tests is a bug and I hope to fix it. It probably won't be in the next couple of days, though, so we'll have to proceed without a fix for now. Hardcoding the package name is a lesser evil than patching Thanks @evandrocoan for the insight and possible workarounds. |
I'm gonna close this until I have figured out a better name and fixed the rest of the review comments |
The plugin is meant for highlighting words or patterns in files (independent of language) in color. I like to use it when reading code to more quickly be able to understand where certain key words (variables) are used, similarly to how I like to use searches. However, many words can be highlighted simultaneously, which thus makes it possible to continue to keep track of the words that are interesting (as opposed to when searching files, where you can only search for one pattern at a time).
See the Readme in the repository for more complete info, as well as a GIF when it is used:
https://github.com/emanuelen5/Word-highlighter