Download Yapakit User Guide

Transcript
18.4. ANATOMY OF A PLUGIN
18.4
107
Anatomy of a Plugin
The following picture shows the content of the ”mode-perl” plugin.
The file ”pkgIndex.tcl” is the package index for the directory. The file ”mode-perl.tcl”
contains the script of the plugin.
18.5
How Plugins are loaded
At the startup of the editor, the list of all sub-directories of the emphplugins directory
is computed. That list of directories is added to the Tcl global ”::auto path” variable, so
that Tcl knows that these directories may contain packages. The name of the directory
may be different from the name of the package. This allows that the directory name may
include a version number to makes the manual management of the plugins easy. The
editor loads the plugin by using the ”package require packagename” Tcl command. Each
plugin directory may contain one or several Tcl files, and may contain sub-directories,
in a way that is internal to the plugin. The only requirement is that the ”pkgIndex.tcl”
located at the root of the plugin directory defines the list of Tcl scripts to source in order
to load a package. The name of the package associated with the plugin is computed from
the content of the ”pkgIndex.tcl” file.
18.6
How to Remove a Plugin
Removing the plugin ”pluginName” simply consists in deleting the directory ”plugins/pluginName”.
18.7
How to Add a Plugin
Adding a new plugin ”pluginName” simply consists in moving the directory under the
”plugins” directory.