单元格的Orgmode表格式

时间:2013-01-25 05:52:44

标签: emacs org-mode org-table

我有一个Emacs组织模式表,如下所示:

 |--------------------------------+------------------------------------------------------|
 | <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};    |
 |                                |                                                      |
 |--------------------------------+------------------------------------------------------|

当使用C-c C-c(例如使用键盘快捷键:Ctrl-C + Ctrl-C调整表格时,或者自动调整表格时,它会破坏表格元素内部的间距,我得到:

 |--------------------------------+------------------------------------------------------|
 | <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};        |
 |                                |                                                      |
 |--------------------------------+------------------------------------------------------|

它会自动修剪表格中内容的前导空格。有没有办法在组织模式表中防止这种情况?我希望组织模式不会改变内容的格式。

这是使用Emacs版本24.3.50,但版本24.2中的行为相同(我在两个版本中都尝试过)。

1 个答案:

答案 0 :(得分:0)

解决它的一个非常黑客的方法是重新定义ord-table-align周围的defadine或defadvice。相关的片段大致在这里。通过将*更改为?,您可以将空格保留在开头。

--- ./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
但是,我不确定你是否真的想这样做。您是否会考虑使用自定义标记功能重新构建标记(可能是使用标题),以防您之后真的需要它来查看表格?如果这让你陷入困境,另一种方法可能是#+ BEGIN_HTML和#+ END_HTML块。不优雅,但很好......