dracula / emacs

🧛🏻‍♂️ Dark theme for Emacs
https://draculatheme.com/emacs
MIT License
330 stars 87 forks source link

Syntax highlighting for Python "# TODO" comments #69

Closed charliesneath closed 4 years ago

charliesneath commented 4 years ago

In Python, I often use comments in the basic form of # TODO: A note to myself to identify places in my code that I'd like to update later.

I've seen syntax highlighting for this pattern in other themes, but would love to have it for Dracula as well.

It seems similar to how the Dracula theme automatically highlights any bracketed strings in commit messages, i.e [WIP] note about this commit.

milouse commented 4 years ago

Hello,

your proposal looks interesting. However, I don't know that much the offered possibilities of the various python modes.Thus, to help me see if it's feasible or no, could you send us a minimal example (some line of valid python code) containing your exemple, and the name of the python mode you are using (I know there is a bunch of them in the wild)?

Thank you very much.

charliesneath commented 4 years ago

In the following line, I am proposing that the word "TODO" (and possibly other keywords) are highlighted in to stand-out from the comment color:

# TODO: This is a comment, can we highlight the first word?

Here's an example of the syntax highlighting I'm describing for JavaScript (source):

image

I don't think this is an issue, but worth noting that there was an official PEP that was refused focused on this topic. More information here.

charliesneath commented 4 years ago

Also, I'm not sure how to find the name of the Python mode I'm using, but my Mode Line says Python ARev company ElDoc. Let me know where I can find this and I'll update. Thank you!

milouse commented 4 years ago

Hi,

After quick investigation, it's not a native feature of Emacs. However there is a lot of packages, which enable the colorization of such keywords. I let you decide, which is best for you.

I just test quickly the package hl-todo, customized as follow and it seems to do exactly what you want:

(with-eval-after-load 'hl-todo
  (setq hl-todo-keyword-faces
        '(("TODO"   . 'font-lock-constant-face)
          ("FIXME"  . 'font-lock-warning-face))))
(global-hl-todo-mode)
charliesneath commented 4 years ago

This is great, thank you for investigating! Appreciate your help.