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

toggle-markup-hiding stomps on added font-lock-keywords #222

Closed
hmelman opened this issue Jul 11, 2017 · 6 comments
Closed

toggle-markup-hiding stomps on added font-lock-keywords #222

hmelman opened this issue Jul 11, 2017 · 6 comments

Comments

@hmelman
Copy link
Contributor

hmelman commented Jul 11, 2017

I have the following in my markdown-mode-hook:

(font-lock-add-keywords nil '(("\\W@\\w+" . font-lock-variable-name-face))))

Works great when I open a file to highlight things like "@closed". However, using markdown-toggle-markup-hiding removes this highlighting. I might not mind if it only did this while hiding, but using it again to toggle it off doesn't restore my highlighting.

@jrblevin
Copy link
Owner

Thanks for pointing this out. Currently markdown-mode re-defines font-lock-keywords directly when toggling some settings (like math mode), which is why your addition to the list is lost. A better approach would be for markdown-mode to add and remove the feature-specific elements individually, without modifying the other elements. After I get v2.3 out (I'm waiting a bit in case there are outstanding bugs), I'll work on this for the next version.

In the meantime, possible workarounds are to add your highlighter to markdown-mode-font-lock-keywords-basic instead, which shouldn't be modified after toggling markup, or to advise markdown-reload-extensions and use font-lock-add-keywords as in your hook above.

@jrblevin
Copy link
Owner

jrblevin commented Nov 7, 2017

Hopefully this is fixed now, but let me know if you still have issues adding keywords.

@hmelman
Copy link
Contributor Author

hmelman commented Nov 9, 2017

Given the keywords in my original comment, I'm still having the same problem. Am I supposed to be using something else?

@jrblevin
Copy link
Owner

jrblevin commented Nov 9, 2017

Sorry about that. It does seem to work if you specify markdown-mode as the mode (to apply globally, say added to init.el outside of a hook) but not when nil is given (which applies only to the current buffer). I wrote the unit test using the former and incorrectly expected the same behavior from the latter. I'm not sure why there is a difference, but I will reopen this and investigate some more.

In other words, this does work for me, but is applied globally rather than to the current buffer only:

(font-lock-add-keywords 'markdown-mode '(("\\W@\\w+" . font-lock-variable-name-face))))

@jrblevin jrblevin reopened this Nov 9, 2017
@hmelman
Copy link
Contributor Author

hmelman commented Nov 9, 2017

You're right that setting it that way works. I've changed my markdown-mode customization hooks :)

@jrblevin
Copy link
Owner

Glad you were able to adjust your configuration. It appears to be fixed now when adding buffer-specific keywords as well.

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

2 participants