0

I want to replace the regular expression `.*` by bolding .* and not displaying the backticks. So I want `elem` to become elem

I looked into these questions about how to prettify strings rather than chars:

Using Prettify Symbols with strings instead of characters

prettify-symbols-mode and multi-character replacements?

I do not understand the answers however. But the answer to this question states prettify-symbols does not support regular expressions anyway and that one needs to use font lock keywords. The wiki entry is not exactly helpful in my opinion; it does not show what the code on the page actually does, but as far as I understand it, apparently it coincidentally is supposed to make some keywords bold (page uses the word highlight... whatever that is supposed to mean here). So I copied and modified it into my init.el like so:

(font-lock-add-keywords 'haskell-mode
                    '(("`.*`"
                       (1 'font-lock-variable-name-face)
                       (3 'font-lock-keyword-face)
                       (5 'font-lock-keyword-face)
                       (6 'font-lock-keyword-face))))

When I do M + x font-lock-mode a string matched by the regex won't by changed.

But I did not expect this to work as I have no idea what I am doing here anyway. Am I even going in the right direction here with that font-lock thing?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.