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.


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
| improve this answer | |

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.

| improve this answer | |
  • Disabled "inherit". Changed "foreground" to dark_gray, "Saved and set" everything, reloaded .emacs file... and still no changes. I must be missing something. – Mario Román Aug 31 '16 at 8:37

Your Answer

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

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