storvik / gomacro-mode

Emacs package for working with gomacro REPL.
4 stars 1 forks source link
comint-mode emacs golang gomacro gomacro-mode repl

gomacro-mode

MELPA CI

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

Todo

Issues

Does not handle multiple packages as all files are evaluated without package header.

Installation

Installation can be done using use-package:

(use-package gomacro-mode
  :hook (go-mode . gomacro-mode))

Usage

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

Interactive functions

The following functions are ment to be used from the M-x interface.

gomacro-run

Run an inferior instance of gomacro inside Emacs comint-mode buffer

gomacro-verbose-toggle

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".

gomacro-eval (stmt)

Evaluate stmt in gomacro REPL buffer. Will prompt for statement if run interactively.

gomacro-eval-region (begin end)

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.

gomacro-eval-line

Evaluate current line.

gomacro-eval-defun

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.

gomacro-eval-buffer

Evaluate entire buffer.

Does not evaluate package statement, hence all buffers sent to gomacro REPL will be in the same namespace.

gomacro-eval-file

Evaluate file, will prompt for file if run interactively.

gomacro-eval-package

Evaluate go package, will prompt for path if run interactively. If filename is specified all other go files in same directory will be processed.

Other useful functions

These functions are not ment to run interactively.

gomacro-running-p

Check if gomacro REPL is running or not.