Copyright (C) 2000-2012 |
GNU Info (efaq)Turning on syntax highlightingHow do I turn on syntax highlighting? ===================================== `font-lock-mode' is the standard way to have Emacs perform syntax highlighting in the current buffer. With `font-lock-mode' turned on, different types of text will appear in different colors. For instance, if you turn on `font-lock-mode' in a programming mode, variables will appear in one face, keywords in a second, and comments in a third. Earlier versions of Emacs supported hilit19, a similar package. Use of hilit19 is now considered non-standard, although `hilit19.el' comes with the stock Emacs distribution. It is no longer maintained. To turn `font-lock-mode' on within an existing buffer, use `M-x font-lock-mode <RET>'. To automatically invoke `font-lock-mode' when a particular major mode is invoked, set the major mode's hook. For example, to fontify all `c-mode' buffers, add the following to your `.emacs' file: (add-hook 'c-mode-hook 'turn-on-font-lock) To automatically invoke `font-lock-mode' for all major modes, you can turn on `global-font-lock-mode' by including the following line in your `.emacs' file: (global-font-lock-mode 1) This instructs Emacs to turn on font-lock mode in those buffers for which a font-lock mode definition has been provided (in the variable `font-lock-global-modes'). If you edit a file in `pie-ala-mode', and no font-lock definitions have been provided for `pie-ala' files, then the above setting will have no effect on that particular buffer. Highlighting a buffer with `font-lock-mode' can take quite a while, and cause an annoying delay in display, so several features exist to work around this. In Emacs 21 and later, turning on `font-lock-mode' automatically activates the new "Just-In-Time fontification" provided by `jit-lock-mode'. `jit-lock-mode' defers the fontification of portions of buffer until you actually need to see them, and can also fontify while Emacs is idle. This makes display of the visible portion of a buffer almost instantaneous. For details about customizing `jit-lock-mode', type `C-h f jit-lock-mode <RET>'. In versions of Emacs before 21, different levels of decoration are available, from slight to gaudy. More decoration means you need to wait more time for a buffer to be fontified (or a faster machine). To control how decorated your buffers should become, set the value of `font-lock-maximum-decoration' in your `.emacs' file, with a `nil' value indicating default (usually minimum) decoration, and a `t' value indicating the maximum decoration. For the gaudiest possible look, then, include the line (setq font-lock-maximum-decoration t) in your `.emacs' file. You can also set this variable such that different modes are highlighted in a different ways; for more information, see the documentation for `font-lock-maximum-decoration' with `C-h v' (or `M-x describe-variable <RET>'). You might also want to investigate `fast-lock-mode' and `lazy-lock-mode', versions of `font-lock-mode' that speed up highlighting. These are the alternatives for `jit-lock-mode' in versions of Emacs before 21.1. The advantage of `lazy-lock-mode' is that it only fontifies buffers when certain conditions are met, such as after a certain amount of idle time, or after you have finished scrolling through text. See the documentation for `lazy-lock-mode' by typing `C-h f `lazy-lock-mode'' (`M-x describe-function <RET> lazy-lock-mode <RET>'). Also see the documentation for the function `font-lock-mode', available by typing `C-h f font-lock-mode' (`M-x describe-function <RET> font-lock-mode <RET>'). For more information on font-lock mode, take a look at the `font-lock-mode' FAQ, maintained by Jari Aalto <jari.aalto@ntc.nokia.com> at `ftp://cs.uta.fi/pub/ssjaaa/ema-font.gui' To print buffers with the faces (i.e., colors and fonts) intact, use `M-x ps-print-buffer-with-faces' or `M-x ps-print-region-with-faces'. You will need a way to send text to a PostScript printer, or a PostScript interpreter such as Ghostscript; consult the documentation of the variables `ps-printer-name', `ps-lpr-command', and `ps-lpr-switches' for more details. automatically generated by info2www version 1.2.2.9 |