6

I have an Emacs org mode table that looks like this:

 |--------------------------------+------------------------------------------------------|
 | <20>                           | <60>                                                 |
 | How do you alter your password | The command to alter your password in oracle is::    |
 | in Oracle?                     |                                                      |
 |                                |     ALTER USER {userid} IDENTIFIED BY {password};    |
 |                                |                                                      |
 |--------------------------------+------------------------------------------------------|

When the table is resized with C-c C-c i.e. with keyboard shortcut: Ctrl-C + Ctrl-C, or automatically, it ruins the spacing inside of the table elements and I get:

 |--------------------------------+------------------------------------------------------|
 | <20>                           | <60>                                                 |
 | How do you alter your password | The command to alter your password in oracle is::    |
 | in Oracle?                     |                                                      |
 |                                | ALTER USER {userid} IDENTIFIED BY {password};        |
 |                                |                                                      |
 |--------------------------------+------------------------------------------------------|

It automatically trims the leading spaces from the content in the table. Is there a way to prevent this in org mode tables? I want org mode to not change the formatting of the content.

This is with Emacs version 24.3.50, but the behavior is the same in version 24.2 (I tried in both versions).

5
  • Try automatic alignment of number-rich columns to the right orgmode.org/manual/Column-width-and-alignment.html
    – artscan
    Jan 25, 2013 at 7:04
  • I just tried your suggestion and it right aligns all text. That's not what I was trying to do. I was hoping there would be a way for it to not do any formatting of the contents.
    – jmq
    Jan 25, 2013 at 7:23
  • 4
    What about using non-breakable spaces? Org mode does not touch them.
    – choroba
    Jan 25, 2013 at 8:15
  • 6
    It works. C-x 8 SPC is for inserting such spaces.
    – artscan
    Jan 25, 2013 at 8:48
  • I'm using a sightly different approach for the task you're doing: put questions as links in the table, and answers as headings. Example at: gist.github.com/abo-abo/6040382
    – abo-abo
    Jan 14, 2014 at 14:10

1 Answer 1

0

A really hack-ish way to work around it is to redefine or defadvice around org-table-align. The relevant snippet is roughly around here. By changing * to ?, you'll keep the spaces at the beginning.

--- ./org-table.el
+++ ./org-table.el.orig
@@ -752,7 +752,7 @@
     ;; Get the data fields by splitting the lines.
     (setq fields (mapcar
          (lambda (l)
-           (org-split-string l " *| *"))
+           (org-split-string l " *| ?"))
          (delq nil (copy-sequence lines))))
     ;; How many fields in the longest line?
     (condition-case nil

I'm not sure if you really want to do that, though. Would you consider restructuring your markup, perhaps by using headings instead, with a custom markup function in case you really need it to look like tables afterwards? If that makes you boggle, another way to accomplish that might be with #+BEGIN_HTML and #+END_HTML blocks. Not elegant, but ah well...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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