Orgmode表格单元格格式化

6

我有一个Emacs org模式的表格,看起来像这样:

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

当使用键盘快捷键 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};        |
 |                                |                                                      |
 |--------------------------------+------------------------------------------------------|

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

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


尝试自动将数字丰富的列右对齐 http://orgmode.org/manual/Column-width-and-alignment.html - artscan
我刚刚尝试了您的建议,它将所有文本右对齐。这不是我想做的。我希望有一种方法让它不进行任何内容格式化。 - jmq
4
使用不间断空格如何?Org模式不会对它们进行修改。 - choroba
6
可以。 C-x 8 SPC是用于插入此类空格的快捷键,它有效。 - artscan
我在做你正在做的任务时使用了稍微不同的方法:将问题作为表格中的链接,将答案作为标题。示例请参见:https://gist.github.com/abo-abo/6040382 - abo-abo
1个回答

0

解决这个问题的一个非常hack-ish的方法是重新定义或者在org-table-align周围添加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块。不太优雅,但是嘿...


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接