Skip to content

Commit 2b72ce3

Browse files
committed
New autoloaded turn-on-haskell-unicode-input-method + documentation
...and also add `turn-on-haskell-unicode-input-method` to the list of choices presented for the `haskell-mode-hook` variable in the customization interface. This addresses #13
1 parent 0a9580d commit 2b72ce3

File tree

4 files changed

+26
-11
lines changed

4 files changed

+26
-11
lines changed

NEWS

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ See also [[https://github.com/haskell/haskell-mode/compare/v13.06...v13.07][deta
3535
shifting to apply.
3636

3737
- Add `haskell-unicode-input-method.el` to distribution
38+
(enable with `turn-on-haskell-unicode-input-method`)
3839

3940
- Fix all byte-compilation warnings
4041

haskell-mode.el

+2-1
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,8 @@ CONFIGURING INDENTATION
447447
,@(if (fboundp 'capitalized-words-mode)
448448
'(capitalized-words-mode))
449449
turn-on-haskell-simple-indent turn-on-haskell-doc-mode
450-
turn-on-haskell-decl-scan imenu-add-menubar-index))
450+
turn-on-haskell-decl-scan imenu-add-menubar-index
451+
turn-on-haskell-unicode-input-method))
451452

452453
(defvar eldoc-print-current-symbol-info-function)
453454

haskell-mode.texi

+16-10
Original file line numberDiff line numberDiff line change
@@ -110,16 +110,22 @@ TODO
110110

111111
@cindex Unicode
112112

113-
TODO:
114-
@itemize
115-
@item
116-
tell about the issues and benefits of using Unicode in source code.
117-
@item
118-
tell about @code{UnicodeSyntax} language extension and the unicode
119-
symbol providing packages on hackage
120-
@item
121-
tell about the haskell-unicode entry methods
122-
@end itemize
113+
See the Haskell Wiki's entry on @uref{http://www.haskell.org/haskellwiki/Unicode-symbols, Unicode Symbols} for general information about Unicode support in Haskell.
114+
115+
As Emacs supports editing files containing Unicode out of the box, so does Haskell Mode. As an add-on, Haskell Mode includes the @code{haskell-unicode} input method which allows you to easily type a number of Unicode symbols that are useful when writing Haskell code; for more details @xref{Input Methods,,,Emacs}.
116+
117+
To automatically enable the @code{haskell-unicode} input method in haskell-mode buffers use @kbd{M-x customize-variable @key{RET} haskell-mode-hook} or put the following code in your `.emacs` file:
118+
119+
@example
120+
(add-hook 'haskell-mode-hook 'turn-on-haskell-unicode-input-method)
121+
@end example
122+
123+
@noindent
124+
To temporarily enable this input method for a single buffer you can use @kbd{M-x turn-on-haskell-unicode-input-method}.
125+
126+
When the @code{haskell-unicode} input method is active, you can simply type @samp{->} and it is immediately replaced with @samp{}. Use @kbd{C-\} to toggle the input method. To see a table of all key sequences use @kbd{M-x describe-input-method @key{RET} haskell-unicode}. A sequence like @samp{<=} is ambiguous and can mean either @samp{} or @samp{}. Typing it presents you with a choice. Type @kbd{1} or @kbd{2} to select an option or keep typing to use the default option.
127+
128+
If you don't like the highlighting of partially matching tokens you can turn it off by setting @code{input-method-highlight-flag} to @code{nil} via @kbd{M-x customize-variable}.
123129

124130
@node Indentation, inferior-haskell-mode, Unicode, Top
125131
@chapter Indentation

haskell-unicode-input-method.el

+7
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,13 @@
3737
(provide 'haskell-unicode-input-method)
3838
(require 'quail)
3939

40+
;;;###autoload
41+
(defun turn-on-haskell-unicode-input-method ()
42+
"Set input method `haskell-unicode'.
43+
See Info node `Unicode(haskell-mode)' for more details."
44+
(interactive)
45+
(set-input-method "haskell-unicode"))
46+
4047
(quail-define-package
4148
"haskell-unicode" ;; name
4249
"UTF-8" ;; language

0 commit comments

Comments
 (0)