You are not logged in.
Hi there !
It's still time to wish you all a happy new year .
I posted here because I guess it's a simple trick, but in there a simple way to change the colors of syntax highlighting under emacs with emacs-haskell-mode ?
As I made xterm appear with a black background and green foreground, the colors in emacs are sometimes hard to distinguish. I'm using emacs with the "-nw" parameter aliased.
Thanks !
The important thing is not to stop questioning.
If you can't explain something simply, you don't know enough about it.
Offline
It's still time to wish you all a happy new year .
Same to you!
I posted here because I guess it's a simple trick, but in there a simple way to change the colors of syntax highlighting under emacs with emacs-haskell-mode ?
There are a handful of variables specific to haskell-mode which control font-locking (highlighting). These and their default values are:
* haskell-keyword-face -> font-lock-keyword-face
* haskell-constructor-face -> font-lock-type-face
* haskell-definition-face -> font-lock-function-name-face
* haskell-operator-face -> font-lock-variable-name-face
* haskell-default-face -> nil
* haskell-literate-comment-face -> font-lock-doc-face
If you want to change the colour only in haskell-mode, you will need to define a face to use, and assign it to the appropriate face in haskell-mode.
(defface haskell-custom-keyword-face
'((t (:foreground "yellow")))
"Custom face for `haskell-keyword-face'."
:group 'haskell)
(defface haskell-custom-constructor-face
'((t (:background "red")))
"Custom face for `haskell-constructor-face'."
:group 'haskell)
(setq haskell-keyword-face 'haskell-custom-keyword-face
haskell-constructor-face 'haskell-custom-constructor-face)
If you want to change the colours globally, it is much simpler:
(set-face-foreground 'font-lock-keyword-face "yellow")
(set-face-background 'font-lock-type-face "red")
And to get a list of colours supported by your display:
M-x list-colours-display
Offline
Hi, thank you for your answer ^^
There are a handful of variables specific to haskell-mode which control font-locking (highlighting).
You talk about font-locking, is is related to my "/usr/share/emacs/site-lisp/haskell-mode/haskell-font-lock.el" feature, i.e. when I edit haskell files in emacs and I have syntaxe highlighting and colors (for types, functiosn etc), is it this file that's used ?
These and their default values are:
* haskell-keyword-face -> font-lock-keyword-face
* haskell-constructor-face -> font-lock-type-face
* haskell-definition-face -> font-lock-function-name-face
* haskell-operator-face -> font-lock-variable-name-face
* haskell-default-face -> nil
* haskell-literate-comment-face -> font-lock-doc-face
Well, I'm sorry I'm a newbie, but I'm not sure I get it : "haskell-keyword-face" is a variable and "font-lock-keyword-face" is a value stored in "/usr/.../haskell-font-lock.el" ?
Thanks again for answering, sorry for asking questions that I guess are so simple to you, but I must say that I'm just beginning to use Emacs, so it's kinda harsh ^^
The important thing is not to stop questioning.
If you can't explain something simply, you don't know enough about it.
Offline
Thanks again for answering, sorry for asking questions that I guess are so simple to you, but I must say that I'm just beginning to use Emacs, so it's kinda harsh ^^
That is fine
Yes, haskell-font-lock.el defines the font-locking behaviour within haskell-mode.
I should have mentioned, while modifying the variables in `haskell-font-lock.el' to correspond to a different face would work, it is considered poor practise. The example code in my earlier post should be added to ~/.emacs. To see the changes take effect, you can restart Emacs or, easier still, evaluate each expression as you go. See here for more information on this.
`font-lock-keyword-face' is a face built into Emacs. Whereas, `haskell-keyword-face' is a variable defined in haskell-font-lock.el whose default value is the face named `font-lock-keyword-face'.
This is the reason why there are two ways to modify the face attributes (e.g., colours, weight, font, etc.): globally or haskell-mode-specific. Changing the face attributes of `font-lock-keyword-face' means that the changes will also be used by haskell-mode. I refer to this as a `global', as the majority of major-modes behave exactly the same way. The alternative method is to change the face pointed to by `haskell-keyword-face'.
Just to clarify the formatting of the variables in my previous post:
* <haskell-mode-specific face variable> -> <corresponding global face>
Since colours are sometimes hard to distinguish, it would be better to make changes to the global face. So:
(set-face-foreground 'font-lock-keyword-face "yellow")
will have Emacs use a yellow foreground for keywords. You may also want to do the same for font-lock-type-face, font-lock-function-face, font-lock-variable-name-face and font-lock-doc-face.
Offline