import emacs_module as emacs
proc Fmod_test_return_t(env: ptr emacs_env, nargs: ptrdiff_t,
args: ptr emacs_value, data: pointer): emacs_value
{.exportc.} =
env.intern(env, "t".cstring)
I wrote below template:
template addFunc*(name: expr, body: stmt):stmt {.immediate.} =
proc name*(env: ptr emacs_env, nargs: ptrdiff_t,
args: ptr emacs_value, data: pointer): emacs_value
{.exportc.} =
body
emacs.addFunc(Fmod_test_return_t):
env.intern(env, "t".cstring)
But I got undeclared identifier: env error...
Am I missing something? (I could compile if I write without that template and complete code is here https://github.com/yuutayamada/nim-emacs-module/blob/master/emacs_module.nim)
Sorry, somehow I could solve myself.
After I just added dirty pragma, the error was disappeared (and could call nim's function from Emacs)
template addFunc*(function_name: expr, body: stmt): stmt {.immediate, dirty.} =
proc function_name*(env: ptr emacs_env, nargs: ptrdiff_t,
args: ptr emacs_value, data: pointer): emacs_value
{.exportc.} =
body
though I don't know what I'm doing