Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove turn-on-purescript-font-lock and turn-off-purescript-font-lock #41

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
95 changes: 20 additions & 75 deletions purescript-font-lock.el
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,32 @@
;; functions, etc. Supports full PureScript 1.4 as well as LaTeX- and
;; Bird-style literate scripts.
;;
;; Installation:
;; Customisation:
;;
;; To turn font locking on for all PureScript buffers under the PureScript
;; mode of Moss&Thorn, add this to .emacs:
;; Two levels of fontification are defined: level one (the default)
;; and level two (more colour). The former does not colour operators.
;; Use the variable `font-lock-maximum-decoration' to choose
;; non-default levels of fontification. For example, adding this to
;; .emacs:
;;
;; (add-hook 'purescript-mode-hook 'turn-on-purescript-font-lock)
;; (setq font-lock-maximum-decoration \\='((purescript-mode . 2) (t . 0)))
;;
;; Otherwise, call `turn-on-purescript-font-lock'.
;; uses level two fontification for `purescript-mode' and default level for all
;; other modes. See documentation on this variable for further details.
;;
;; To alter an attribute of a face, add a hook. For example, to change the
;; foreground colour of comments to brown, add the following line to .emacs:
;;
;; Customisation:
;; (add-hook \\='purescript-font-lock-hook
;; (lambda ()
;; (set-face-foreground \\='purescript-comment-face \"brown\")))
;;
;; Note that the colours available vary from system to system. To see what
;; colours are available on your system, call `list-colors-display' from emacs.
;;
;; The colours and level of font locking may be customised. See the
;; documentation on `turn-on-purescript-font-lock' for more details.
;; Bird-style literate PureScript scripts are supported: If the value of
;; `purescript-literate-bird-style' (automatically set by the PureScript mode of
;; Moss&Thorn) is non-nil, a Bird-style literate script is assumed.
;;
;; Present Limitations/Future Work (contributions are most welcome!):
;;
Expand Down Expand Up @@ -417,73 +429,6 @@ that should be commented under LaTeX-style literate scripts."
;; Get help from font-lock-syntactic-keywords.
(parse-sexp-lookup-properties . t))))

;; The main functions.
(defun turn-on-purescript-font-lock ()
"Turns on font locking in current buffer for PureScript 1.4 scripts.

Changes the current buffer\\='s `font-lock-defaults', and adds the
following variables:

`purescript-keyword-face' for reserved keywords and syntax,
`purescript-constructor-face' for data- and type-constructors, class names,
and module names,
`purescript-operator-face' for symbolic and alphanumeric operators,
`purescript-default-face' for ordinary code.

The variables are initialised to the following font lock default faces:

`purescript-keyword-face' `font-lock-keyword-face'
`purescript-constructor-face' `font-lock-type-face'
`purescript-operator-face' `font-lock-function-name-face'
`purescript-default-face' <default face>

Two levels of fontification are defined: level one (the default)
and level two (more colour). The former does not colour operators.
Use the variable `font-lock-maximum-decoration' to choose
non-default levels of fontification. For example, adding this to
.emacs:

(setq font-lock-maximum-decoration \\='((purescript-mode . 2) (t . 0)))

uses level two fontification for `purescript-mode' and default level for
all other modes. See documentation on this variable for further
details.

To alter an attribute of a face, add a hook. For example, to change
the foreground colour of comments to brown, add the following line to
.emacs:

(add-hook \\='purescript-font-lock-hook
(lambda ()
(set-face-foreground \\='purescript-comment-face \"brown\")))

Note that the colours available vary from system to system. To see
what colours are available on your system, call
`list-colors-display' from emacs.

To turn font locking on for all PureScript buffers, add this to .emacs:

(add-hook \\='purescript-mode-hook \\='turn-on-purescript-font-lock)

To turn font locking on for the current buffer, call
`turn-on-purescript-font-lock'. To turn font locking off in the current
buffer, call `turn-off-purescript-font-lock'.

Bird-style literate PureScript scripts are supported: If the value of
`purescript-literate-bird-style' (automatically set by the PureScript mode
of Moss&Thorn) is non-nil, a Bird-style literate script is assumed.

Invokes `purescript-font-lock-hook' if not nil."
(purescript-font-lock-defaults-create)
(run-hooks 'purescript-font-lock-hook)
(turn-on-font-lock))

(defun turn-off-purescript-font-lock ()
"Turns off font locking in current buffer."
(font-lock-mode -1))

;; Provide ourselves:

(provide 'purescript-font-lock)

;; Local Variables:
Expand Down