Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I use other heading styles like twiki ---+ or mediawiki == h2 == in org-mode?

Tags:

emacs

org-mode

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

like image 434
Krazy Glew Avatar asked Jul 27 '12 23:07

Krazy Glew


People also ask

How do you use Org mode tags?

Org mode has extensive support for tags. Every headline can contain a list of tags; they occur at the end of the headline. Tags are normal words containing letters, numbers, ' _ ', and ' @ '. Tags must be preceded and followed by a single colon, e.g., ' :work: '.

Does vim have Org mode?

vim is a minimal Org mode and Outline mode plugin for Vim providing only syntax highlighting and folding. This plugin aims to replicate Vim's existing Markdown editing experience on Org mode (and Outline mode) files, rather than trying to be a full featured Org mode plugin—that is what Emacs is for.

What does Org mode do?

Org Mode (also: org-mode; /ˈɔːrɡ moʊd/) is a document editing, formatting, and organizing mode, designed for notes, planning, and authoring within the free software text editor Emacs.

How do you make a table in Org mode?

The easiest way to create a table is to directly type the "|" character at the beginning of a line, or after any amount of white space. This will put you in the first field of an atomic table. Once you've finished editing this cell, you can jump to the next one by pressing TAB .


1 Answers

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.

like image 197
nealmcb Avatar answered Nov 15 '22 10:11

nealmcb