Next: , Previous: Creating Dictionaries, Up: Dictionaries


5.2 Loading and Saving Dictionaries

predictive-load-dict
Load a dictionary by name, and add it to the list of dictionaries used by the current buffer. The dictionary will be included when learning from the buffer, see Learning from Buffers and Files, and if its autosave flag is set (see Creating Dictionaries), it will automatically be saved when the buffer is killed. The dictionary file must be in your load-path.

You should never normally need to use this command interactively, since predictive mode loads and unloads dictionaries automatically, as needed.

dictree-load
Load a dictionary from file. The name of the loaded dictionary is the same as the file name, with the extension removed. This will not add it to the list of dictionaries used by the current buffer (see predictive-load-dict, above).
predictive-unload-dict
Remove a dictionary from the list of dictionaries used by the current buffer. If the dictionary is no longer used by any other buffer, this also unloads it from Emacs. In that case, if its autosave flag is set, the dictionary will be saved before being unloaded (see Creating Dictionaries), unless this is overridden by supplying a prefix argument.

You should never normally need to use this command interactively, since predictive mode loads and unloads dictionaries automatically, as needed.

dictree-unload
You probably don't want to do this! Unloading a dictionary that's still in use will cripple predictive mode, resulting in it spewing out incomprehensible Lisp errors. This command unconditionally unloads a dictionary. If the dictionary's autosave flag is set, this will also save it (see Creating Dictionaries), unless overridden by supplying a prefix argument.
predictive-save-dict
Save a dictionary to its associated file. Prompt for a file name if there is none associated with the dictionary.
predictive-write-dict
Write a dictionary to a file specified via the mini-buffer. This also associates the dictionary with that file. If a prefix argument is supplied, you will not be asked to confirm if over-writing an existing file.
predictive-save-modified-dicts
Save all modified dictionaries that have a non-nil autosave flag. If a prefix argument is supplied, prompt for confirmation before saving each dictionary.
predictive-dump-dict-to-buffer
Dump all words, weights and prefix relationships in the dictionary to a buffer, in the same format as that used to populate dictionaries (see Creating Dictionaries).
predictive-dump-dict-to-file
Dump words, weights and prefix relationships to a text file rather than a buffer. If a prefix argument is supplied, you will not be asked to confirm if over-writing an existing file.
predictive-dict-autosave
Sets the default autosave property for dictionaries created with predictive-create-dict. If non-nil, modified dictionaries will automatically be saved when they are unloaded (either with the predictive-dict-unload command, or when exiting emacs). If nil, any unsaved modifications will be lost unless the dictionary is saved manually. See Loading and Saving Dictionaries.
predictive-dict-compilation
Determines whether dictionaries are saved in compiled or uncompiled form, or both. If set to the symbol compiled, dictionaries are saved in compiled form, if set to uncompiled they are saved in uncompiled form, and if set to anything else they are saved in both forms (the default). A compiled dictionary can be loaded a lot faster, and is always used in preference to the uncompiled form if it exists. However, compiled dictionaries are not portable between different Emacs versions, whereas uncompiled ones are.
predictive-dict-lock-loaded-list
List of dictionaries that should never be automatically unloaded, in addition to predictive-main-dict (see Basic Dictionary Usage).

To use a dictionary, it must be loaded into memory. Usually, predictive mode loads the dictionaries it needs automatically, and unloads them again when they are no longer needed. Once it has been loaded, the predictive-main-dict is never automatically unloaded. It can take a while to load large dictionaries, and predictive-main-dict is likely to be used by most predictive-mode buffers. If you would like to prevent any other dictionaries from being unloaded automatically, add them to predictive-dict-lock-loaded.

You can also load and unload dictionaries manually. If a dictionary is saved somewhere in your load path, you can load it using the predictive-load-dict and dictree-load commands. The predictive-load-dict command additionally adds it to the list of dictionaries used by the current buffer. This has two implications: the dictionary will automatically be saved when the buffer is killed (assuming its autosave flag is non-nil, see Creating Dictionaries), and it will be included when learning from the buffer (see Learning from Buffers and Files). (You should avoid loading a dictionary using the load-file command, as it will not necessarily ensure that the dictionary is correctly associated with the file it was loaded from).

If you want a dictionary to be loaded every time you run Emacs, and the dictionary is saved somewhere in your load-path, you can add the following line to your .emacs file:

     (dictree-load 'dictionary-name)

The major-mode setup functions load the dictionaries they need automatically. See Major Modes.

A buffer is usually associated with a file, and saving the buffer with the Emacs save-buffer command writes any changes back to that file. Similarly, dictionaries are usually associated with a dictionary file. The predictive-save-dict command saves any changes back to that file. The predictive-write-dict command is analogous to the Emacs write-file command.

You should never rename a dictionary file. (Moving a dictionary file to another directory in your load-path is fine, but you cannot rename the file itself.) The correct way to rename a dictionary is to supply a new file name to predictive-write-dict.

Dictionaries can be modified by adding words to them with the predictive-add-to-dict command (see Creating Dictionaries). If the auto-learn features are used, dictionaries are modified whenever a completion is accepted (see Automatic Learning). The predictive-save-modified-dicts saves all modified dictionaries whose autosave flag is set. Modified dictionaries used in a buffer are automatically saved when that buffer is killed if they have their autosave flag set. All modified autosave dictionaries are saved when you exit Emacs.