Does anyone know how I can print λ instead of \ using haskell in emacs. I know that one can use haskell-font-lock-symbols, but I find the rest of them hard to read - the arrows are TOO small!
Is there a simple way of over-riding the rest of the keys?
You can also solve the problem with something like
(eval-after-load 'haskell-font-lock
'(setq haskell-font-lock-symbols-alist
(delq nil
(mapcar (lambda (rewrite)
(if (member (car rewrite) '("->" "<-"))
nil rewrite))
haskell-font-lock-symbols-alist))))
which should keep all mappings except for the one that changes "->" into "→" and "<-" into "←".
You can do this:
(defun pretty-lambdas-haskell ()
(font-lock-add-keywords
nil `((,(concat "\\(" (regexp-quote "\\") "\\)")
(0 (progn (compose-region (match-beginning 1) (match-end 1)
,(make-char 'greek-iso8859-7 107))
nil))))))
(add-hook 'haskell-mode-hook 'pretty-lambdas-haskell)
This adds the lambda as a keyword, meaning that it won't appear in escape sequences in strings for example (TODO: this is not the case after changing a thing). The ,(make-char 'greek-iso8859-7 107) is of course equivalent to ?λ, but you must make sure that your Emacs init file is encoded as unicode in that case.
You can also enable full symbol font locking and use a better (read: with wider arrows) font, like Pragmata Pro, Inconsolata or Ubuntu Monospace. I use the following code to select a good font:
(defun font-existsp (font)
"Check to see if the named FONT is available."
(if (null (x-list-fonts font))
nil t))
(require 'cl)
(defun font-avail (fonts)
"Finds the available fonts."
(remove-if-not 'font-existsp fonts))
(defvar font-preferences
'("PragmataPro"
"Inconsolata"
"DejaVu Sans Mono"
"Bitstream Vera Sans Mono"
"Anonymous Pro"
"Menlo"
"Consolas"))
(unless (eq window-system nil)
(let ((fonts (font-avail font-preferences)))
(unless (null fonts)
(set-face-attribute
'default nil :font
(car fonts)))))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With