1

How can I change the color of the comments starting with -- | in Haskell mode?

When I write a comment in Haskell I get a grey face, but when the comment starts with -- |, as required by Haddock documentation lines, it takes a green one. I have tried to change the Haskell Literate Comment Face to inherit from font-lock-doc-face to font-lock-comment-face, but it has had no effect over the comments starting with -- |.

Edited: Ok. Now I see the problem. The face of these comments is not Haskell Literate Comment Face, it is directly font-lock-doc-face (?). If I change it, the comments reflect the change. But why is it like this? I would like to change the color of the doc-comments only for Haskell, not globally.

1

2 Answers 2

1

I would like to change the color of the doc-comments only for Haskell, not globally.

You can combine the buffer-local effects of Face Remapping with a mode hook to achieve this. For example, in order to display Haddock comments with the same face as plain comments, you can write something like

(add-hook 'haskell-mode-hook
          (lambda ()
            (face-remap-add-relative 'font-lock-doc-face
                                     'font-lock-comment-face)))
0

Assume it had no effect, because font-lock-comment-face is set to grey too.

Try M-x customize-face RET haskell-literate-comment-face RET

Then disable the check-box "inherit", open the now enabled menu and edit the values at place.

WRT your comment: Looks like a bug. See in haskell-mode-autoloads.el

(defface haskell-literate-comment-face '((t :inherit font-lock-doc-face))

Maybe editing it there will help. Might require a re-compile than, as the *.elc files --if present-- will be loaded.

1
  • Disabled "inherit". Changed "foreground" to dark_gray, "Saved and set" everything, reloaded .emacs file... and still no changes. I must be missing something. Aug 31, 2016 at 8:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.