|
31 | 31 | ;; functions, etc. Supports full PureScript 1.4 as well as LaTeX- and |
32 | 32 | ;; Bird-style literate scripts. |
33 | 33 | ;; |
34 | | -;; Installation: |
| 34 | +;; Customisation: |
35 | 35 | ;; |
36 | | -;; To turn font locking on for all PureScript buffers under the PureScript |
37 | | -;; mode of Moss&Thorn, add this to .emacs: |
| 36 | +;; Two levels of fontification are defined: level one (the default) |
| 37 | +;; and level two (more colour). The former does not colour operators. |
| 38 | +;; Use the variable `font-lock-maximum-decoration' to choose |
| 39 | +;; non-default levels of fontification. For example, adding this to |
| 40 | +;; .emacs: |
38 | 41 | ;; |
39 | | -;; (add-hook 'purescript-mode-hook 'turn-on-purescript-font-lock) |
| 42 | +;; (setq font-lock-maximum-decoration \\='((purescript-mode . 2) (t . 0))) |
40 | 43 | ;; |
41 | | -;; Otherwise, call `turn-on-purescript-font-lock'. |
| 44 | +;; uses level two fontification for `purescript-mode' and default level for all |
| 45 | +;; other modes. See documentation on this variable for further details. |
42 | 46 | ;; |
| 47 | +;; To alter an attribute of a face, add a hook. For example, to change the |
| 48 | +;; foreground colour of comments to brown, add the following line to .emacs: |
43 | 49 | ;; |
44 | | -;; Customisation: |
| 50 | +;; (add-hook \\='purescript-font-lock-hook |
| 51 | +;; (lambda () |
| 52 | +;; (set-face-foreground \\='purescript-comment-face \"brown\"))) |
| 53 | +;; |
| 54 | +;; Note that the colours available vary from system to system. To see what |
| 55 | +;; colours are available on your system, call `list-colors-display' from emacs. |
45 | 56 | ;; |
46 | | -;; The colours and level of font locking may be customised. See the |
47 | | -;; documentation on `turn-on-purescript-font-lock' for more details. |
| 57 | +;; Bird-style literate PureScript scripts are supported: If the value of |
| 58 | +;; `purescript-literate-bird-style' (automatically set by the PureScript mode of |
| 59 | +;; Moss&Thorn) is non-nil, a Bird-style literate script is assumed. |
48 | 60 | ;; |
49 | 61 | ;; Present Limitations/Future Work (contributions are most welcome!): |
50 | 62 | ;; |
@@ -417,73 +429,6 @@ that should be commented under LaTeX-style literate scripts." |
417 | 429 | ;; Get help from font-lock-syntactic-keywords. |
418 | 430 | (parse-sexp-lookup-properties . t)))) |
419 | 431 |
|
420 | | -;; The main functions. |
421 | | -(defun turn-on-purescript-font-lock () |
422 | | - "Turns on font locking in current buffer for PureScript 1.4 scripts. |
423 | | -
|
424 | | -Changes the current buffer\\='s `font-lock-defaults', and adds the |
425 | | -following variables: |
426 | | -
|
427 | | - `purescript-keyword-face' for reserved keywords and syntax, |
428 | | - `purescript-constructor-face' for data- and type-constructors, class names, |
429 | | - and module names, |
430 | | - `purescript-operator-face' for symbolic and alphanumeric operators, |
431 | | - `purescript-default-face' for ordinary code. |
432 | | -
|
433 | | -The variables are initialised to the following font lock default faces: |
434 | | -
|
435 | | - `purescript-keyword-face' `font-lock-keyword-face' |
436 | | - `purescript-constructor-face' `font-lock-type-face' |
437 | | - `purescript-operator-face' `font-lock-function-name-face' |
438 | | - `purescript-default-face' <default face> |
439 | | -
|
440 | | -Two levels of fontification are defined: level one (the default) |
441 | | -and level two (more colour). The former does not colour operators. |
442 | | -Use the variable `font-lock-maximum-decoration' to choose |
443 | | -non-default levels of fontification. For example, adding this to |
444 | | -.emacs: |
445 | | -
|
446 | | - (setq font-lock-maximum-decoration \\='((purescript-mode . 2) (t . 0))) |
447 | | -
|
448 | | -uses level two fontification for `purescript-mode' and default level for |
449 | | -all other modes. See documentation on this variable for further |
450 | | -details. |
451 | | -
|
452 | | -To alter an attribute of a face, add a hook. For example, to change |
453 | | -the foreground colour of comments to brown, add the following line to |
454 | | -.emacs: |
455 | | -
|
456 | | - (add-hook \\='purescript-font-lock-hook |
457 | | - (lambda () |
458 | | - (set-face-foreground \\='purescript-comment-face \"brown\"))) |
459 | | -
|
460 | | -Note that the colours available vary from system to system. To see |
461 | | -what colours are available on your system, call |
462 | | -`list-colors-display' from emacs. |
463 | | -
|
464 | | -To turn font locking on for all PureScript buffers, add this to .emacs: |
465 | | -
|
466 | | - (add-hook \\='purescript-mode-hook \\='turn-on-purescript-font-lock) |
467 | | -
|
468 | | -To turn font locking on for the current buffer, call |
469 | | -`turn-on-purescript-font-lock'. To turn font locking off in the current |
470 | | -buffer, call `turn-off-purescript-font-lock'. |
471 | | -
|
472 | | -Bird-style literate PureScript scripts are supported: If the value of |
473 | | -`purescript-literate-bird-style' (automatically set by the PureScript mode |
474 | | -of Moss&Thorn) is non-nil, a Bird-style literate script is assumed. |
475 | | -
|
476 | | -Invokes `purescript-font-lock-hook' if not nil." |
477 | | - (purescript-font-lock-defaults-create) |
478 | | - (run-hooks 'purescript-font-lock-hook) |
479 | | - (turn-on-font-lock)) |
480 | | - |
481 | | -(defun turn-off-purescript-font-lock () |
482 | | - "Turns off font locking in current buffer." |
483 | | - (font-lock-mode -1)) |
484 | | - |
485 | | -;; Provide ourselves: |
486 | | - |
487 | 432 | (provide 'purescript-font-lock) |
488 | 433 |
|
489 | 434 | ;; Local Variables: |
|
0 commit comments