Using Python Ruby Golang as Quick Calculator in Emacs

By Xah Lee. Date: . Last updated: .
ruby as calculator in emacs d78e5
ruby as calculator in emacs
golang as calculator in emacs 5b5c7
golang as calculator in emacs
  1. i now use golang as calculator. C-n new buffer, g3 inserts main template. type 1+2, space w j shows result.
  2. many advantages of using lang instead of emacs Alt+x calc. faster, more powerful, flexible, and saved result, editable.
  3. you can use golang python ruby nodejs julia etc. In a buffer and press a button to run it.
  4. i used to use emacs calc for quicky back in 1999. switched to python ~2009. then switched to ruby, now golang.
  5. for example, ruby, just Alt+x eshell, irb, 1+3 enter.
  6. but notebook interface is usually better than repl, because you have more powerful editing and saving features
  7. e.g. Ctrl+n open new, type p 1+2, Alt+x xah-run-current-file, type x.rb, result shows 3
  8. for lang require template such as golang “main” stuff, just type g3 and it inserts it. Using emacs abbrev.

Note, strictly typed language such as golang may not be suitable. Because it's more cumbersome.

The advantage of using a full featured language in a buffer instead of calc are:

For how to setup, see

put in a few bucks to my patreon. Thanks.