4

I'm trying to add more symbols to haskell-mode's haskell-font-lock.

The documentation for haskell-font-lock-symbols-alist says:

Alist mapping Haskell symbols to chars. Each element has the form (STRING . CHAR) or (STRING CHAR PREDICATE). STRING is the Haskell symbol. CHAR is the character with which to represent this symbol. PREDICATE if present is a function of one argument (the start position of the symbol) which should return non-nil if this mapping should be disabled at that position.

I'm trying something like:

(add-to-list 'haskell-font-lock-symbols-alist `("heart" . 2665))

But when typing 'heart' in haskell mode the font-lock won't work, although it works for ->, ., =>.

What am I missing ?

Drew
  • 75,699
  • 9
  • 109
  • 225
Renan Ranelli
  • 1,379
  • 10
  • 17

1 Answers1

4

The important value at runtime is haskell-font-lock-keywords, which is generated from the alist when loading haskell-font-lock.el. After changing haskell-font-lock-symbols-alist you will also have to recompute the value of hakskell-font-lock-keywords.

This snippet will add the heart character to the alist and recompute haskell-font-lock-keywords such that heart in a Haskell source file is rendered as :

(eval-after-load 'haskell-font-lock
 '(progn
    (add-to-list 'haskell-font-lock-symbols-alist `("heart" . 9829))
    (setq haskell-font-lock-keywords
          (haskell-font-lock-keywords-create nil))))