纠结这个:
#+BEGIN_SRC C :tangle no :noweb-ref begin
int main() {
printf("Line 1\n");
#+END_SRC
#+BEGIN_SRC C :tangle no :noweb-ref middle
printf("Second\n");
#+END_SRC
#+BEGIN_SRC C :tangle no :noweb-ref end
}
#+END_SRC
#+BEGIN_SRC C :tangle ~/test.c :noweb no-export
<<begin>>
<<middle>>
<<end>>
#+END_SRC
产生这个:
int main() {
printf("Line 1\n");
printf("Second\n");
}
我打开了org-src-preserve-indentation,但它无法保留不存在的内容。如果代码编辑窗口看不到先前源代码块中的部分,则无法正确设置它。最后,我不想在每次启动新的源代码块时都必须遍历所有前面的代码片段来弄清楚缩进应该从什么开始。
当前的黑客方法是缠结源代码,在新缓冲区中打开缠结文件,选择全部并运行c-indent-line-or-region,但我希望有更好的东西比那。
组织模式版本:8.2.5h
最佳答案
如前所述, Hook org-babel-post-tangle-hook 是正确的方法。我使用以下内容:
(defun tnez/src-cleanup ()
(indent-region (point-min) (point-max)))
(add-hook 'org-babel-post-tangle-hook 'tnez/src-cleanup)
关于emacs - 有什么方法可以让 org-babel 正确缩进 noweb 纠结的代码吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24297597/