Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm working with Org-Mode to manage a database refactoring, and part of that involved me getting the current schema into text so I can clean things up. I wrote a query that outputs data like this:

| table |        |
|       | column |
|       | column |
|       | column |
|       | column |
| table |        |
|       | column |
|       | column |

I can copy and paste that into Emacs, and the empty fields convert to tabs. All is fine, but is there any means to make Org-Mode convert a list with indentation into a list with sub-lists?

The best I was able to do was to hack the query to output:

| + table |          |
|         | - column |

So as to effectively "trick" Org-Mode into thinking it was already a correctly formatted list.

share|improve this question

1 Answer 1

If you receive the data as you show in your code-box including the | for the tables:

With the point preceeding the table:
M-x replace-regexp <RET> " ?| \{0,4\}" <RET><RET>
M-x replace-regexp <RET> " *$" <RET><RET>

That will remove the table formatting as well as the blank spaces at the end of lines (where the "column" is missing). In my case tabs are converted to spaces so (which also makes it easier to remove the whitespace). You may need to adjust the {0,4} if it keeps them as tabs. There may be a way to create a regexp that will remove spaces or tabs, but I don't know enough about regexp to do so.

If you have already removed the | that mark the content as being an org-table you'll simply have to follow the below.

Then to convert to a set of lists, mark the entire region you want to convert and use the following as per the Org-Manual: http://orgmode.org/org.html#Plain-lists

C-u C-c -
or
C-u M-x org-toggle-item

result is as follows:

- table
  - column
  - column
  - column
  - column
- table
  - column
  - column
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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