Skip to content
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

Feature request : add custom markup comments #23617

Open
hprodh opened this issue Feb 1, 2025 · 6 comments
Open

Feature request : add custom markup comments #23617

hprodh opened this issue Feb 1, 2025 · 6 comments

Comments

@hprodh
Copy link

hprodh commented Feb 1, 2025

I sometimes use comments beginning with #NOTE : ....
These are not highlighted by default as markup comments, and this is actually OK. But sometimes, I would like to temporarily highlight them. Could it be possible to add entries to the list of markup comments in Preferences -> Editor -> Advanced Settings -> Annotations ?
Quick visual example :
Image

@dalthviz
Copy link
Member

dalthviz commented Feb 3, 2025

Hi @hprodh thank you for the feedback! Just in case, I think the current logic to handle the markers is based on a regular expression at

# =============================================================================
# Find tasks - TODOs
# =============================================================================
TASKS_PATTERN = r"(^|#)[ ]*(TODO|FIXME|XXX|HINT|TIP|@todo|" \
r"HACK|BUG|OPTIMIZE|!!!|\?\?\?)([^#]*)"

Also, checking this I remembered another related issue #22341

Maybe a way to let people customize the markers could be by allowing them to define a custom pattern besides the default hardcoded one or even making possible defining in the preferences only one pattern and leaving the current hardcoded pattern value as the default value for that new preference?

What do you think @spyder-ide/core-developers ?

@ccordoba12
Copy link
Member

ccordoba12 commented Feb 4, 2025

I think we should be able to extend the regexp pattern by

  1. Exposing all patterns we support in an option (a lineedit) in Preferences. That would easily allow users to customize them.
  2. Join those patterns with the | operator.
  3. Build the regexp with the resulting string from step 2.

What do you think?

@dalthviz
Copy link
Member

dalthviz commented Feb 4, 2025

That should work but then the patterns in the lineedit will be separated by some character like ,? Or multiple lineedits will be available, one for each pattern to be added? If the patterns are in a single string via a lineedit having to manipulate that to programatically join them after with | could not be prompt to errors?

I was thinking that the preference to be added could probably be a string that has the patterns you would like, with their characters escaped if needed (since the value will be used as part of a regular expression - i.e ??? -> ???), and separated with |. So for example the default value for the preference would be something like:

    TODO|FIXME|XXX|HINT|TIP|@todo|HACK|BUG|OPTIMIZE|!!!|\?\?\?

@hprodh
Copy link
Author

hprodh commented Feb 5, 2025

I think the separator , is the best bet, as the user will just have to follow the convention as displayed just above in the same window (see picture in OP). I also think that simply supporting alphanumeric characters (and maybe _) for a start will be enough for the majority of use-cases.

And also I don't think the hardcoded markups should be modifiable.

@ccordoba12
Copy link
Member

I think the separator , is the best bet

I agree with @hprodh: a single line edit with comma separated patterns should be enough.

I also think that simply supporting alphanumeric characters (and maybe _) for a start will be enough for the majority of use-cases.

Ok, that would make composing the regexp easier. @dalthviz, we'd need to validate the extra patterns introduced by users and report to them in case some don't follow this convention.

And also I don't think the hardcoded markups should be modifiable.

Ok, that's a good point too because it'd make the experience consistent between different Spyder installations (instead of showing markup comments in some installations and not in others).

@hprodh
Copy link
Author

hprodh commented Feb 7, 2025

... Also, a little checkbox ☑ to enable/disable custom markups could be convenient.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants