Skip to content
TheChatArchiveThe Chat Archive
Qwenqwen3-235b-a22b-no-thinking· Alibaba (Qwen)Hugging Face LMArena Human Preference 140K

I want to use Emacs Org-Mode source blocks in calc mode to convert units, e.g. 1 inch to…

From a Chatbot Arena battleThe same person sent this prompt to two anonymous models at once. Compare it with Mistralmistral-small-2506’s answer.
  1. User

    I want to use Emacs Org-Mode source blocks in calc mode to convert units, e.g. 1 inch to centimetres using calc units. How do I do that?

  2. Qwen Assistant

    You can use Emacs Org Mode source blocks with calc to convert units like inches to centimeters. GNU Calc has robust unit conversion support, and you can interface with it via ob-calc, which is part of Org Mode's Babel system for evaluating code blocks.

    Here’s how to do it step by step:


    ✅ Step-by-Step Guide

    1. Ensure ob-calc.el is loaded

    Org Babel supports calc through the ob-calc package. Make sure it is loaded.

    Add this to your Emacs config if not already present:

    (org-babel-do-load-languages
     'org-babel-load-languages
     '((calc . t)))
    

    Then restart or reload your config (M-x eval-buffer).


    2. Use a Calc Source Block in Org Mode

    Now, you can write a source block like this in your .org file:

    #+BEGIN_SRC calc :results code
    convert(1_in, cm)
    #+END_SRC
    

    This tells Calc to convert 1 inch (1_in) into centimeters (cm).


    3. Evaluate the Block

    Place the cursor inside the block and press C-c C-c (or run M-x org-babel-execute-src-block).

    The result will be inserted below:

    #+RESULTS:
    : 2.54 cm
    

    🧮 More Examples

    Convert 10 miles to kilometers:

    #+BEGIN_SRC calc :results code
    convert(10_mi, km)
    #+END_SRC
    

    Result:

    #+RESULTS:
    : 16.09344 km
    

    Convert 60 miles per hour to meters per second:

    #+BEGIN_SRC calc :results code
    convert(60_mi/hr, m/s)
    #+END_SRC
    

    Result:

    #+RESULTS:
    : 26.8224 m / s
    

    📌 Notes

    • Use underscores _ to denote units in Calc expressions.
    • Supported unit abbreviations are similar to those in GNU Calc. See Calc Units for more info.
    • You can also perform arithmetic with units directly in the expression, e.g., 1_m + 100_cm.

    Let me know if you'd like to define custom units or automate unit conversions across tables!

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.