You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
And the target should depend on the `ModuleFactoryPlugin` to automatically setup C definitions required for each dynamic module.
31
41
32
-
Each module is required to have two exported C functions: `plugin_is_GPL_compatible` and `emacs_module_init`. The first one is the way to tell Emacs that your code is GPL-compatible. The second function is your module's `main` function. It is called when Emacs loads your module.
42
+
## Writing a module code
33
43
34
-
Of course, we can define these two functions from Swift and this is how you'd typically do this.
44
+
Each module should have a class conforming to ``Module``. This protocol has only two requirements:
45
+
-``Module/isGPLCompatible``, a boolean property that should always return true telling Emacs that your code is GPL-compatible.
46
+
-``Module/Init(_:)``, your module's `main` function, it is called when Emacs loads your module.
you should see the `"Hello from Swift!"` message in your Emacs.
62
67
63
-
> Important: Don't throw exceptions in your init methods, crashing the module is the same as crashing the whole Emacs. That's not what Emacs users expect from their plugins!
68
+
> Important: Uncaught exceptions in the `Init` method prevent your module from loading, use that only when you absolutely cannot proceed.
/// Emacs dynamic module, @main class of your package.
2
+
publicprotocolModule{
3
+
/// Every dynamic module should be distributed under the GPL compatible license.
4
+
///
5
+
/// By returning true here, you agree that your module follows this rule.
6
+
varisGPLCompatible:Bool{get}
7
+
/// Module initialization point.
8
+
///
9
+
/// This function gets executed only once when the user loads the module from Emacs. Usually the module defines some package-specific functions here and/or creates the channel of communication with Emacs.
10
+
///
11
+
/// When this function finishes its execution, the given environment becomes invalid and shouldn't be used. See <doc:Lifetimes> for more details.
0 commit comments