如何在组织模式中使用其他标题样式,如twiki --- +或mediawiki == h2 == [英] How can I use other heading styles like twiki ---+ or mediawiki == h2 == in org-mode?

查看:129
本文介绍了如何在组织模式中使用其他标题样式,如twiki --- +或mediawiki == h2 ==的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我真的想使用组织模式。



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



例如使用twiki的--- +

  --- + H1 

顶级

--- ++ H2

嵌套

--- + H1#2

第二顶级

或像

  = H1 = 

顶级

== H2 ==

嵌套

= H1#2 =

第二顶级

我想拥有组织的所有好处模式折叠等,只是使用这些不同的标题样式。






实际上,更糟糕的是:



我想说,twiki或mediawaiki标题优先于组织模式星号标题。但是我想同时使用。



= H1 =

 顶级

*这是一个列表
**嵌套
*列表
**嵌套

== H2 ==

嵌套

= H1#2 =

第二顶级

- +我迄今为止尝试过的



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

  --- + Emacs东西
#try(defvar twiki-outline-regexp - + \\ ++ \\ | \\(\\(?: \\)+ \\)[0-9 *])
本地变量:***
outline-regexp:^ --- \\ ++***
org-outline-regexp:^ --- \\ ++ ***
结束:***

然而,org-outline-regexp doesn'



emacs'outline-mode的外层功能几乎完全像我想要的那样。

 (defvar outline-level'outline-level 
*没有参数的函数来计算标题在大纲中的嵌套级别。
它可以假设点位于标题行的开头,匹配
数据反映了outline-regexp。)

ie而不是regexps,一个通用函数。



但是我没有设法使它与org-模式,它看起来像组织模式并不真正使用这个,或者是具有其他的东西。

  ;;在组织缓冲区,outline-regexp的值是
;;org-outline-regexp的值,唯一仍然直接依赖
;;outline-regexp的函数是org-overview '所以当orgstruct-mode被激活时,'org-cycle'可以执行
;; job。
(defvar org-outline-regexp\\ * +
regexp to match org headlines。)
(defconst org-outline-regexp-bol^ \\ * +
Regexp来匹配Org标题
这类似于`org-outline-regexp',但是另外让
肯定我们在行的开头。)

(defconst org-heading-regexp ^ \\(\\ * + \\)\\(?: + \\(。*?\\)\\)?[\t] * $
匹配标题,将星和文字分组。
星星被放在组1和组2中的修剪体。)

失败这个,好的,我想从组织模式的主要是链接,另外一个问题在这里
我如何在emacs中链接非组织模式缓冲区

解决方案

我的沮丧只是组织模式对于什么构成一个新的大纲部分而不同于大纲模式的规则,它需要在星号后面有一个空格,所以它在我的广泛收集笔记,放弃了这些空格。



我通过删除未完好记录的 org-outline- regexp 变量,用于初始化缓冲区局部变量 outline-regexp ,这似乎在为我工作,例如(set-variable'org-outline-regexp\\ * +)



对于您的实际问题,我猜测其他正则表达式和代码将不得不更改以处理截然不同的东西,如twiki或mediawiki标题。 p>

I really want to use org-mode.

But, I want to use org-mode to understand structured documents that have already been written using different heading syntax,

e.g. using twiki's ---+

---+ H1 

Top level

---++ H2

Nested

---+ H1 #2

Second top level

Or mediawiki like

= H1 = 

Top level

== H2 ==

Nested

= H1 #2 =

Second top level

I'd like to have all of the goodness of org-mode folding, etc., just using these different heading styles.


Actually, worse that that:

I would like, say, the twiki or mediawaiki headings to take priority over org mode asterisk headings. But I would like to have both in use.

= H1 =

Top level

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

== H2 ==

Nested

= H1 #2 =

Second top level

--+ What I have tried so far

I have been able to use outline mode to handle twiki, for example via

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

However, org-outline-regexp doesn't do hwat I would hope.

emacs' outline-mode's out-level function looks almost exactly like what I want.

(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'.")

i.e. instead of regexps, a generic function.

But I have not managed to make it work with org-mode. It looks like org-mode does not really use this, or, rather, has other stuff.

;; 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.")

Failing this, well, the main thing that I want from org-mode is links, Asking another question here How can I "linkify" a non-org-mode buffer in emacs

解决方案

My frustration was simply that org-mode has different rules for what constitutes a new outline section than outline-mode does. It requires a space after the asterisks, so it doesn't work on my extensive collection of notes, which forgo those spaces.

I resolved that by removing the trailing space in the not-well-documented org-outline-regexp variable, which is used to initialize the buffer-local variable outline-regexp, and that seems to be working for me. E.g. (set-variable 'org-outline-regexp "\\*+")

As to your actual question, my guess is that other regexp's and code would have to change to handle radically different stuff like twiki or mediawiki headings.

这篇关于如何在组织模式中使用其他标题样式,如twiki --- +或mediawiki == h2 ==的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆