This Emacs package provides bindings for working with Gomacro, a read eval print loop for Go. Gomacro installation instuctions can be found in the gomacro repo. Thanks to the gomacro author!
Table of Contents
- Look into using
go--build-font-lock-keywords
to to syntax highlightning in gomacro buffer - Add
gomacro-eval-file
which prompts for file to eval - Add
gomacro-eval-pacakge
which evaluates all files in specified folder - Combine eval region and eval region verbose to one function with config param
- Add
gomacro-eval-buffer
- Add
gomacro-eval-line
- Add support for type definitions in eval defun (struct and interface)
- Remove all comments in
gomacro--sanitize-string
- Ensure only one whitespace in
gomacro--sanitize-string
- Add some tests
- Handle package declarations
Does not handle multiple packages as all files are evaluated without package header.
Installation can be done using use-package:
(use-package gomacro-mode
:hook (go-mode . gomacro-mode))
By enabling gomacro-mode
in buffer with Go source code the following keybindings will be set:
Keybinding | Function |
---|---|
C-M-x | gomacro-eval-defun |
C-c C-r | gomacro-eval-region |
C-c C-l | gomacro-eval-line |
C-c C-t | gomacro-verbose-toggle |
The following functions are ment to be used from the M-x
interface.
Run an inferior instance of gomacro
inside Emacs comint-mode
buffer
Toggle value of gomacro-verbose-toggle
.
When verbose mode is activated everything is sent to gomacro line by line, default behaviour is to only display "Region is sent to gomacro REPL".
Evaluate stmt
in gomacro REPL buffer.
Will prompt for statement if run interactively.
Evaluate region between begin
and end
.
Can be run interactively with marked region.
If gomacro-verbose-eval
is set region will be sent line by line to gomacro REPL.
Evaluate current line.
Evaluate the nearest function, type or import statement looking backwards. This function will select whichever function, type or import statement that is nearest to current cursor position and pass it to gomacro REPL.
Evaluate entire buffer.
Does not evaluate package statement, hence all buffers sent to gomacro REPL will be in the same namespace.
Evaluate file, will prompt for file if run interactively.
Evaluate go package, will prompt for path if run interactively. If filename is specified all other go files in same directory will be processed.
These functions are not ment to run interactively.
Check if gomacro REPL is running or not.