1

我正在寻找一种将特定树(包括子树)读入列表的简洁方法。

说我有:

* Branch
** Small branch
** Another small branch
*** Leaves
* Flowers

该函数应该能够通过正则表达式搜索并将子树(例如搜索分支)复制到如下列表:

'(("Small branch") ("Another small branch" ("Leaves")))
4

1 回答 1

2

以下似乎有效:

(defun org-list-siblings ()
  "List siblings in current buffer starting at point.
Note, you can always (goto-char (point-min)) to collect all siblings."
  (interactive)
  (let (ret)
    (unless (org-at-heading-p)
      (org-forward-heading-same-level nil t))
    (while (progn
         (setq ret (cons (append (list (substring-no-properties (org-get-heading)))
                       (save-excursion
                         (when (org-goto-first-child)
                           (org-list-siblings))))
                 ret))
         (org-goto-sibling)))
      (nreverse ret)))

如果您不需要完整的树,而是将子树放置在其第一个子标题上。这是有条不紊的,因为顶级标题被解释为第一个孩子。没有共同的根。

于 2013-11-19T13:48:54.870 回答