Permalink
Browse files

Add imenu support to markdown files

  • Loading branch information...
1 parent 97b4cb5 commit fb5422bc41e23b30d765af39e4be447dd82d4624 @magnars magnars committed Dec 17, 2012
Showing with 18 additions and 0 deletions.
  1. +1 −0 init.el
  2. +17 −0 setup-markdown-mode.el
View
@@ -94,6 +94,7 @@
(eval-after-load 'js2-mode '(require 'setup-js2-mode))
(eval-after-load 'ruby-mode '(require 'setup-ruby-mode))
(eval-after-load 'clojure-mode '(require 'setup-clojure-mode))
+(eval-after-load 'markdown-mode '(require 'setup-markdown-mode))
;; Load slime-js when asked for
(autoload 'slime-js-jack-in-browser "setup-slime-js" nil t)
View
@@ -0,0 +1,17 @@
+(setq markdown-imenu-generic-expression
+ '(("title" "^\\(.*\\)[\n]=+$" 1)
+ ("h2-" "^\\(.*\\)[\n]-+$" 1)
+ ("h1" "^# \\(.*\\)$" 1)
+ ("h2" "^## \\(.*\\)$" 1)
+ ("h3" "^### \\(.*\\)$" 1)
+ ("h4" "^#### \\(.*\\)$" 1)
+ ("h5" "^##### \\(.*\\)$" 1)
+ ("h6" "^###### \\(.*\\)$" 1)
+ ("fn" "^\\[\\^\\(.*\\)\\]" 1)
+ ))
+
+(add-hook 'markdown-mode-hook
+ (lambda ()
+ (setq imenu-generic-expression markdown-imenu-generic-expression)))
+
+(provide 'setup-markdown-mode)

0 comments on commit fb5422b

Please sign in to comment.