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

Not working in python-mode? #27

Closed
wavexx opened this issue Jul 9, 2018 · 5 comments
Closed

Not working in python-mode? #27

wavexx opened this issue Jul 9, 2018 · 5 comments

Comments

@wavexx
Copy link
Contributor

@wavexx wavexx commented Jul 9, 2018

I'm using emacs 27 from git so I could be an outlier, but I noticed today that hl-todo doesn't seem to find any hit in python-mode's comments.

@tarsius
Copy link
Owner

@tarsius tarsius commented Jul 9, 2018

I can't see a reason why this wouldn't work in python-mode. Maybe this is just an instance of #26.

@wavexx
Copy link
Contributor Author

@wavexx wavexx commented Jul 10, 2018

@wavexx
Copy link
Contributor Author

@wavexx wavexx commented Jul 10, 2018

Mmh, no. After further testing, with a plain emacs -q it works :/
I guess something is wrong on my side.

@wavexx wavexx closed this Jul 10, 2018
@wavexx
Copy link
Contributor Author

@wavexx wavexx commented Jul 10, 2018

Ok, I actually found what the issue is.

@wavexx wavexx reopened this Jul 10, 2018
@wavexx
Copy link
Contributor Author

@wavexx wavexx commented Jul 10, 2018

(setq hl-todo-highlight-punctuation ":"
      hl-todo-keyword-faces '(("TODO" . "#000000)))

Doesn't work correctly in python-mode. With the sample file:

# TEST: me

You can see that ":" is not highlighted. Previously I had "TODO:" as a keyword (with the colon directly in the name). The issue here is indeed related to the syntax table of python-mode.

In the keyword regexp, "_>" doesn't match correctly after the colon. I recommend moving the anchor "_>" just after the keyword block to avoid this issue:

(concat "\\(\\_<" (regexp-opt (mapcar #'car hl-todo-keyword-faces) t) "\\_>"
                (and (not (equal hl-todo-highlight-punctuation ""))
                     (concat "[" hl-todo-highlight-punctuation "]?"))
                "\\)[[({:;.,?!]?"))
wavexx added a commit to wavexx/hl-todo that referenced this issue Jul 10, 2018
- Anchor the keywords themselves, not the punctuation
  (fixes tarsius#27)
- Mach a variable amount of punctuation at the end
  (highlights correctly "TODO?!?" with
  hl-todo-highlight-punctuation ":!?"
wavexx added a commit to wavexx/hl-todo that referenced this issue Jul 10, 2018
- Anchor the keywords themselves, not the punctuation (fixes tarsius#27)
- Match a variable amount of punctuation after the keyword (highlights
  correctly "TODO?!?" with hl-todo-highlight-punctuation ":!?")
tarsius added a commit to wavexx/hl-todo that referenced this issue Oct 3, 2018
Exclude the non-word characters from anchoring.

This was useful for testing:

;;            character syntax meaning
;; TODO TODO: :         _      symbol
;; TODO TODO§ §         .      punctuation
;; TODO()
;; TODO(topic)  previously explicitly highlighted, now implicitly
;; TODO:noise   previously not highlighted, now highlighted
;; TODOnoise    still not highlighted

Fixes tarsius#27.
See tarsius#28.
@tarsius tarsius closed this in #28 Oct 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

2 participants