Skip to content

Commit

Permalink
New autoloaded turn-on-haskell-unicode-input-method + documentation
Browse files Browse the repository at this point in the history
...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
  • Loading branch information
hvr committed Jun 30, 2013
1 parent 0a9580d commit 2b72ce3
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 11 deletions.
1 change: 1 addition & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ See also [[https://github.com/haskell/haskell-mode/compare/v13.06...v13.07][deta
shifting to apply.

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

- Fix all byte-compilation warnings

Expand Down
3 changes: 2 additions & 1 deletion haskell-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,8 @@ CONFIGURING INDENTATION
,@(if (fboundp 'capitalized-words-mode)
'(capitalized-words-mode))
turn-on-haskell-simple-indent turn-on-haskell-doc-mode
turn-on-haskell-decl-scan imenu-add-menubar-index))
turn-on-haskell-decl-scan imenu-add-menubar-index
turn-on-haskell-unicode-input-method))

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

Expand Down
26 changes: 16 additions & 10 deletions haskell-mode.texi
Original file line number Diff line number Diff line change
Expand Up @@ -110,16 +110,22 @@ TODO

@cindex Unicode

TODO:
@itemize
@item
tell about the issues and benefits of using Unicode in source code.
@item
tell about @code{UnicodeSyntax} language extension and the unicode
symbol providing packages on hackage
@item
tell about the haskell-unicode entry methods
@end itemize
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.

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}.

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:

@example
(add-hook 'haskell-mode-hook 'turn-on-haskell-unicode-input-method)
@end example

@noindent
To temporarily enable this input method for a single buffer you can use @kbd{M-x turn-on-haskell-unicode-input-method}.

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.

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}.

@node Indentation, inferior-haskell-mode, Unicode, Top
@chapter Indentation
Expand Down
7 changes: 7 additions & 0 deletions haskell-unicode-input-method.el
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@
(provide 'haskell-unicode-input-method)
(require 'quail)

;;;###autoload
(defun turn-on-haskell-unicode-input-method ()
"Set input method `haskell-unicode'.
See Info node `Unicode(haskell-mode)' for more details."
(interactive)
(set-input-method "haskell-unicode"))

(quail-define-package
"haskell-unicode" ;; name
"UTF-8" ;; language
Expand Down

0 comments on commit 2b72ce3

Please sign in to comment.