Permalink
Browse files

Generalise arrow rendering, add support for double arrows.

  • Loading branch information...
1 parent cc0bb9a commit 8862c3eb3a28c0312875194dd6f656f39acd3efe @bodil committed Jan 26, 2014
Showing with 13 additions and 8 deletions.
  1. +5 −0 bodil-defuns.el
  2. +8 −8 bodil-haskell.el
View
@@ -11,6 +11,11 @@
(setq result (append (list (car form) result)
(cdr form))))))
+(defun font-lock-replace-symbol (mode reg sym)
+ (font-lock-add-keywords
+ mode `((,reg
+ (0 (progn (compose-region (match-beginning 1) (match-end 1)
+ ,sym 'decompose-region)))))))
(defun add-hooks (modes func)
(dolist (mode modes)
View
@@ -26,16 +26,16 @@
(lambda () (add-to-list 'ac-sources 'ac-source-ghc))))))
;; Use Unicode arrows in place of ugly ASCII arrows
+(require 'bodil-defuns)
+(font-lock-replace-symbol 'haskell-mode "\\(->\\)" "")
+(font-lock-replace-symbol 'haskell-mode "\\(<-\\)" "")
+(font-lock-replace-symbol 'haskell-mode "\\(=>\\)" "")
+(font-lock-replace-symbol 'haskell-mode "\\(<=\\)" "")
+
(define-key haskell-mode-map (kbd "") (lambda () (interactive) (insert "->")))
(define-key haskell-mode-map (kbd "") (lambda () (interactive) (insert "<-")))
-(font-lock-add-keywords
- 'haskell-mode `((,"\\(->\\)"
- (0 (progn (compose-region (match-beginning 1) (match-end 1)
- "" 'decompose-region))))))
-(font-lock-add-keywords
- 'haskell-mode `((,"\\(<-\\)"
- (0 (progn (compose-region (match-beginning 1) (match-end 1)
- "" 'decompose-region))))))
+(define-key haskell-mode-map (kbd "") (lambda () (interactive) (insert "=>")))
+(define-key haskell-mode-map (kbd "") (lambda () (interactive) (insert "<=")))
;; Add a keybinding for (inferior-haskell-type t) to insert
;; inferred type signature for function at point

0 comments on commit 8862c3e

Please sign in to comment.