3

I am using emacs with org mode.

Question 1:

I want to number a column in a table in hex. E.g.

| 0x00 | xyz | .. |
| 0x01 | abc | .. |

I want to auto generate first column. Any ideas how to do this in org mode?

Question 2:

How to generate a list of numbers/alphabets etc. (in hex, decimal) in emacs (need not be org mode)?

PS: Please let me know if there are any linux/bash tricks to do this.

4

Following is a method using an elisp formula:

| hex  | comment |
|------+---------|
| 0x00 |         |
| 0x01 |         |
| 0x02 |         |
| 0x03 |         |
| 0x04 |         |
| 0x05 |         |
| 0x06 |         |
| 0x07 |         |
| 0x08 |         |
| 0x09 |         |
| 0x0A |         |
| 0x0B |         |
| 0x0C |         |
#+TBLFM: $1='(format "0x%02X" (- @# 2))

format takes a format string much like printf in C.

Then @# gives the current row number, to which I subtract 2 so row 2 displays 0.

2

This is an answer to question 1 based on keyboard macros and calc.

Prepare Calc

Set calc to display in radix 16.

C-x * c d r 16 q

Record a suitable Macro

f3 f3 M-b C-x * w C-x * w C-e RET f4

Use the Macro

f4 f4 ...

Beautification

Use e.g. search and replace to change the format of the list.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.