Skip to content

Commit 2c8a0de

Browse files
committed
haskell-indentation.el: Add support for UnicodeSyntax tokens
This adds support for handling the UnicodeSyntax symbols `→`, `←`, and `∷` tokens like their ASCII counterparts `->`, `<-`, and `::` respectively. This should resolve purescript-emacs#2 as well.
1 parent a58f6fd commit 2c8a0de

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

NEWS

+4-2
Original file line numberDiff line numberDiff line change
@@ -104,14 +104,16 @@ See also [[https://github.com/haskell/haskell-mode/compare/2_9_1...v13.06][detai
104104
- Add forward declarations to reduce Elisp bytecompile warnings
105105

106106
- Improvements to `haskell-indentation`
107+
- Add support for the UnicodeSyntax tokens `→`, `←`, and `∷`.
107108
- Indent "=" following data/type/newtype declarations.
108-
- Align arrows in types under "::"
109+
- Align "->"/"→" arrows in types under "::"/"∷"
109110
- Make customizable whether "<backspace>" deletes indentation too
110111
(via `haskell-indentation-delete-backward-indentation` and
111112
`haskell-indentation-delete-indentation`)
112113
- Properly indent 'rec' keyword, same as 'mdo'
114+
- Minor optimizations.
113115

114-
- Add support for "'"-prefixed constructors to font-locking
116+
- Add support for "'"-prefixed constructors (-> DataKinds) to font-locking
115117

116118
- New experimental haskell session menu mode (M-x haskell-menu)
117119

haskell-indentation.el

+16
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,19 @@ Preserves indentation and removes extra whitespace"
505505
(t
506506
(haskell-indentation-parse-to-indentations)))))
507507

508+
(defconst haskell-indentation-unicode-tokens
509+
'(("" . "->") ;; #x2192 RIGHTWARDS ARROW
510+
("" . "::") ;; #x2237 PROPORTION
511+
("" . "<-") ;; #x2190 LEFTWARDS ARROW
512+
("" . "=>") ;; #x21D2 RIGHTWARDS DOUBLE ARROW
513+
("" . "forall") ;; #x2200 FOR ALL
514+
("" . "-<") ;; #x2919 LEFTWARDS ARROW-TAIL
515+
("" . ">-") ;; #x291A RIGHTWARDS ARROW-TAIL
516+
("" . "-<<") ;; #x291B LEFTWARDS DOUBLE ARROW-TAIL
517+
("" . ">>-") ;; #x291C RIGHTWARDS DOUBLE ARROW-TAIL
518+
("" . "*")) ;; #x2605 BLACK STAR
519+
"Translation dictionary from UnicodeSyntax tokens to their ASCII representation.")
520+
508521
(defconst haskell-indentation-toplevel-list
509522
'(("module" . haskell-indentation-module)
510523
("data" . (lambda () (haskell-indentation-statement-right #'haskell-indentation-data)))
@@ -976,6 +989,9 @@ Preserves indentation and removes extra whitespace"
976989
(match-string-no-properties 0))
977990
((looking-at "\\(\\\\\\|->\\|<-\\|::\\|=\\||\\)\\([^-:!#$%&*+./<=>?@\\\\^|~]\\|$\\)")
978991
(match-string-no-properties 1))
992+
((looking-at "\\(→\\|←\\|∷\\)\\([^-:!#$%&*+./<=>?@\\\\^|~]\\|$\\)")
993+
(let ((tok (match-string-no-properties 1)))
994+
(or (cdr (assoc tok haskell-indentation-unicode-tokens)) tok)))
979995
((looking-at"[-:!#$%&*+./<=>?@\\\\^|~`]" )
980996
'operator)
981997
(t 'value)))

0 commit comments

Comments
 (0)