How to adjust numbers in the journal with Emacs Calc

Emacs users, you can use Calc’s embedded mode to adjust numbers quickly while editing the journal. Eg, to divide a number by 2, put the cursor in it, then press C-x * w 2 / q.

Calc rewrites decimal numbers to a standard format, hiding trailing zeros by default, which you may not want. To preserve trailing zeros, you must force a fixed number of decimal digits. In calc mode (eg before pressing q above) do:

  • d f 2 return to force two digits (eg shows .00)
  • d f 3 return to force three digits (eg shows .005 when there's a half cent)
  • d n to choose normal mode (shows all digits except trailing zeros)

And to ensure that such config changes are saved in (and reloaded from) ~/.emacs.d/calc.el rather than the current buffer, add this to your emacs config:

(setq calc-mode-save-mode 'save)

From https://hledger.org/editors.html

3 Likes