https://github.com/mrc/go-emacs-module
Writing an emacs module with Go
https://github.com/mrc/go-emacs-module
emacs go golang
Last synced: over 1 year ago
JSON representation
Writing an emacs module with Go
- Host: GitHub
- URL: https://github.com/mrc/go-emacs-module
- Owner: mrc
- License: gpl-2.0
- Created: 2019-05-18T12:54:22.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2019-05-18T13:32:27.000Z (about 7 years ago)
- Last Synced: 2025-02-04T15:32:54.937Z (over 1 year ago)
- Topics: emacs, go, golang
- Language: Go
- Size: 8.79 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# go-emacs-module
This doesn't work, but it's a start at getting a module written in Go that Emacs can use.
## Building
Requires `emacs-module.h`, which is created when Emacs configure is run.
Some package managers that don't keep source might remove it. macOS Homebrew removes it -- some patches ([example](https://github.com/railwaycat/homebrew-emacsmacport/pull/112)) restore it, or brew cask emacs puts it in `/Applications/Emacs.app/Contents/Resources/include/emacs-module.h`.
```
% go build -o emacsmodtest.so -buildmode=c-shared && emacs --batch -nw -Q -L $(pwd) --eval "(require 'emacsmodtest)" --eval "(princ (frob))"
emacs version: 26
hello from frob!
borf%
```
## What works
* intern a symbol, get the symbol value
* call a Go func from Emacs (just one, with no arguments)
## Todo
* Convert args for the thunk to a Go slice
* Make the thunk call a different Go func
* Figure out if all this casting is safe
## Notes
Emacs requires the symbol `plugin_is_GPL_compatible`. It doesn't need it to be anything in particular, and cgo is happy exporting functions, so I made it a function.
`fmt.Printf` is nice for testing from the command line, but would be bad at runtime.