6

我真的很想使用组织模式。

但是,我想使用 org-mode 来理解已经使用不同标题语法编写的结构化文档,

例如使用 twiki 的 ---+

---+ H1 

Top level

---++ H2

Nested

---+ H1 #2

Second top level

或 mediawiki 之类的

= H1 = 

Top level

== H2 ==

Nested

= H1 #2 =

Second top level

我想拥有 org-mode 折叠等的所有优点,只需使用这些不同的标题样式。


实际上,更糟糕的是:

例如,我希望 twiki 或 mediawaiki 标题优先于 org 模式星号标题。但我想同时使用两者。

= H1 =

Top level

* this is a list
** nested
* list
** nested

== H2 ==

Nested

= H1 #2 =

Second top level

--+ 到目前为止我尝试过的

我已经能够使用大纲模式来处理 twiki,例如通过

---+ Emacs stuff
# try (defvar twiki-outline-regexp "---+\\++ \\|\\(\\(?:   \\)+\\)[0-9*] ")
Local Variables: ***
outline-regexp: "^---\\++" ***
org-outline-regexp: "^---\\++" ***
End: ***

但是,org-outline-regexp 并没有我希望的那样做。

emacs 的outline-mode 的out-level 函数看起来几乎和我想要的一样。

(defvar outline-level 'outline-level
  "*Function of no args to compute a header's nesting level in an outline.
It can assume point is at the beginning of a header line and that the match
data reflects the `outline-regexp'.")

即,而不是正则表达式,一个通用函数。

但我还没有设法让它与 org-mode 一起工作。看起来 org-mode 并没有真正使用它,或者更确切地说,还有其他东西。

;; In Org buffers, the value of `outline-regexp' is that of
;; `org-outline-regexp'.  The only function still directly relying on
;; `outline-regexp' is `org-overview' so that `org-cycle' can do its
;; job when `orgstruct-mode' is active.
(defvar org-outline-regexp "\\*+ "
  "Regexp to match Org headlines.")
(defconst org-outline-regexp-bol "^\\*+ "
  "Regexp to match Org headlines.
This is similar to `org-outline-regexp' but additionally makes
sure that we are at the beginning of the line.")

(defconst org-heading-regexp "^\\(\\*+\\)\\(?: +\\(.*?\\)\\)?[ \t]*$"
  "Matches an headline, putting stars and text into groups.
Stars are put in group 1 and the trimmed body in group 2.")

失败了,好吧,我想从 org-mode 获得的主要是链接,在这里问另一个问题 How can I "linkify" a non-org-mode buffer in emacs

4

1 回答 1

4

我的挫败感只是 org-mode 对新大纲部分的构成与大纲模式有不同的规则。它需要在星号之后有一个空格,因此它不适用于我的大量笔记,这些笔记放弃了这些空格。

我通过删除未充分记录的org-outline-regexp变量中的尾随空格解决了这个问题,该变量用于初始化缓冲区局部变量outline-regexp,这似乎对我有用。例如(set-variable 'org-outline-regexp "\\*+")

至于您的实际问题,我的猜测是其他正则表达式和代码必须更改以处理完全不同的内容,例如 twiki 或 mediawiki 标题。

于 2012-08-14T12:51:19.387 回答