Previous: Character Syntax and Key Bindings, Up: Advanced Customisation


6.2 Major Modes

The many features of predictive mode allow you to set things up appropriately for whatever language you are typing, whether it be plain text, markup languages such as LaTeX, HTML or Texinfo, programming languages such as C or Lisp, etc. Predictive mode will work happily alongside the appropriate major-mode. However, since each language makes different demands of predictive completion, you may find yourself changing a large number of settings when switching major modes.

To facilitate using predictive completion alongside different major-modes, predictive mode can run a setup function determined by the current major-mode whenever it is switched on in a buffer. Of course, you can also use major mode hooks, but hooks are less convenient if you don't want to always switch on predictive mode in that major mode, or if you want to switch it on and off whilst within the mode.

predictive-major-mode-alist
Alist associating a major-mode symbol with a function, which should take one argument. The alist is checked whenever predictive mode is enabled or disabled in a buffer using the predictive-mode or turn-on-predictive-mode commands (see Basic Completion Commands). If the buffer's major-mode matches one in the alist, the associated function is called with a positive argument if predictive mode is being enabled or a negative one if it is being disabled. This makes it easier to customize predictive mode for different major modes.

Since the setup function is determined by the current major-mode, predictive mode should be switched on after switching to the appropriate major-mode. If you always want to use predictive mode with a particular major-mode, the easiest way to do this is to add the predictive-mode command to the major-mode hook in your .emacs file, using a line something like this:

     (add-hook 'major-mode-hook 'turn-on-predictive-mode)

The predictive package itself includes comprehensive support for LaTeX (predictive-setup-latex), Texinfo (predictive-setup-texinfo) and HTML (predictive-setup-html). More contributions are always welcome!. You must ensure that the dictionaries required in order to support these major-modes (which are also included in the package, see Obtaining and Installing) can be found in your load-path. The LaTeX, Texinfo, and HTML support goes far beyond simply changing a few configuration variables. See LaTeX Support, Texinfo Support, and HTML Support.