No description, website, or topics provided.
Clone or download
Pull request Compare This branch is 39 commits ahead of yuutayamada:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
emacs_module
extra
test
.gitignore
.travis.yml
README.md
emacs_module.nim
emacs_module.nimble

README.md

What is this?

This is a wrapper library to use Emacs Dynamic Module feature from Nim language.

Note that the Emacs Dynamic Module feature is supported from Emacs 25.1 onwards.

Note

I'm either Nim and C language's newbie, so probably I'm doing something wrong... So beware. (PRs are welcome!)

Requirements

  • Emacs with version 25.1 or higher compiled with the --with-modules configure option.

GPL compatibility

In order for Emacs to load Dynamic Modules, like the ones created using this package, the modules need to export a symbol named plugin_is_GPL_compatible to indicate that that code is released under the GPL or compatible license.

If this symbol is not exported, Emacs will refuse the module and error out with "Module is not GPL compatible".

For that reason, all modules compiled using this package will export the plugin_is_GPL_compatible symbol. This is done in the helpers.nim.

Usage Example

  1. Clone this repo.
  2. cd test
  3. make sample
  • If the above make step fails, set EMACS_MODULE_DIR to the directory containing the emacs-module.h header file. Example: make sample EMACS_MODULE_DIR=/dir/containing/emacs-module.h/.

Output

emacs --batch -L .  -l test.el -f ert-run-tests-batch-and-exit
Running 6 tests (2018-06-21 15:27:04-0400, selector ‘t’)
   passed  1/6  sample-mod-test-non-local-exit-signal-test (0.055210 sec)
   passed  2/6  sample-mod-test-non-local-exit-throw-test (0.000234 sec)
   passed  3/6  sample-mod-test-return-t (0.000264 sec)
   passed  4/6  sample-mod-test-return-uname-cmd (0.000247 sec)
   passed  5/6  sample-mod-test-sum (0.000267 sec)
   passed  6/6  sample-mod-test-vector-test (0.001737 sec)

Ran 6 tests, 6 results as expected (2018-06-21 15:27:04-0400, 0.058906 sec)

Another Example

The return42.nim example shows how simple it is to write a Nim proc with the same functionality as that of the mymod_test function in the Emacs Modules tutorial.

All you do is:

import emacs_module

init(emacs)

emacs.defun(return42, 0):
  return env.make_integer(env, 42)

emacs.provide()

Assuming that you already are past Steps 1 and 2 above, do:

make return42

Output

emacs --batch -L .  -l test-return42.el -f ert-run-tests-batch-and-exit
Running 1 tests (2018-06-21 16:48:28-0400, selector ‘t’)
   passed  1/1  return42-return42-cmd (0.000421 sec)

Ran 1 tests, 1 results as expected (2018-06-21 16:48:28-0400, 0.000766 sec)

Other References