如何一次性导出所有subtree的

一篇长文章,试图导出为 latex,做法是每个一级标题分别导出,每一次导出,都需要对接近10个标题,执行 export 命令。有没有办法一次性完成?导出时需要设置:subtree, only body。

写个函数,遍历一下。

(let ((continue t)
      (num 1))
  (while continue
    (org-next-visible-heading 1)
    (org-export-to-file
	'latex
	(concat (number-to-string num)
		".tex")
      nil t)
    (setq num (1+ num))
    (and (eq (point) (point-max))
	 (setq continue nil))))

会一直导出到最底下

如果想要加速的话可以试试把 async 改成 t? 不过我这么改了之后 emacs 崩掉了

2 个赞

我按您给的代码, 改出来是这样(因为我指定了 EXPORT_FILE_NAME property):

(defun export-subtree()
(let ((continue t))
  (while continue
    (org-next-visible-heading 1)
(if (org-entry-get nil "EXPORT_FILE_NAME")
    (org-export-to-file
	'latex
	(org-entry-get nil "EXPORT_FILE_NAME")
      nil t nil t) nil)
    (and (eq (point) (point-max))
	 (setq continue nil)))))

我试了 async, 虽然没有崩, 但也没成功. 谢谢您!

不客气,加油加油!