Friday, December 19, 2008

Emacs: vimoutliner

I've been drinking too much caffeine lately, and if you know me, you know what that means--I start getting weird urges to play with Emacs.

One of the things that always drives me crazy about Emacs is indentation. It's hard to get it to do what I want it to do in cases where there is no mode that matches what I'm coding. I have a ton of files written using vimoutliner, and I don't feel like switching them to Emacs' own format. It's a simple outline format. Four space wide tabs are used for nesting.

I could never figure out how to get Emacs to just "do the right thing" with these .otl files. I finally figured out the right magical incantation, thanks to some hints from Jesse Montrose. Updated:
;; Add support for Vim outline files.
(defun otl-setup ()
(setq outline-regexp "\t+")
(setq indent-tabs-mode t) ;; Use real tabs.
(setq tab-width 4))

(setq auto-mode-alist
(cons '("\\.otl$" . outline-mode)
auto-mode-alist))
(add-hook 'outline-mode-hook
'otl-setup)
Viola! Editing .otl files just became possible!

6 comments:

Shannon -jj Behrens said...

Ooo! I get even get Emacs' own outliner mode to work with .otl files!

(defun otl-setup ()
(setq outline-regexp "\t+")
(setq indent-tabs-mode t) ;; Use real tabs.
(setq tab-width 4))

(setq auto-mode-alist
(cons '("\\.otl$" . outline-mode)
auto-mode-alist))
(add-hook 'outline-mode-hook
'otl-setup)

Bryan Berry said...

Why even use vimoutliner? I just switched to emacs' org-mode and found it a world of improvement over vimoutliner. check it out www.orgmode.org

Shannon -jj Behrens said...

> Why even use vimoutliner?

Since I am normally a die-hard Vim user, I already have a ton of files in vimoutliner mode. I don't want to have to convert these to Emacs' outline-mode.

Shannon -jj Behrens said...

Jesse also suggested AllOut: http://www.emacswiki.org/emacs-ja/AllOut

It looks like a very sophisticated outline tool.

darin said...

So caffeine is a gateway drug to Emacs. Good to know... ;)

Shannon -jj Behrens said...

Grumble, grumble. It messes up sometimes. I hit tab to indent, and it indents like 7 spaces instead of one tab, which totally breaks the format. I don't know what the deal is.