Permalink
Browse files

YAML imenu outline integration

  • Loading branch information...
1 parent bce5aa1 commit f297efe0fc81cf0e561d0c61a025a5c91989823a @timcharper timcharper committed Dec 21, 2009
Showing with 21 additions and 3 deletions.
  1. +2 −0 Changes
  2. +1 −1 Makefile
  3. +18 −2 yaml-mode.el
View
@@ -1,3 +1,5 @@
+0.0.5 Mon Dec 21 2009
+ - Provide outline of yaml document via imenu (Tim Harper)
0.0.4 Mon Apr 20 16:46:13 2009 JST
- Patch from knagano and mad-p. Fixed font-lock bugs(#4)
* Move to github.com
View
@@ -1,4 +1,4 @@
-VERSION=0.0.4
+VERSION=0.0.5
EMACS = emacs
PREFIX = /usr/local
INSTALLLIBDIR = $(PREFIX)/share/emacs/site-lisp
View
@@ -5,7 +5,7 @@
;; Author: Yoshiki Kurihara <kurihara@cpan.org>
;; Marshall T. Vandegrift <llasram@gmail.com>
;; Keywords: data yaml
-;; Version: 0.0.4
+;; Version: 0.0.5
;; This file is not part of Emacs
@@ -104,10 +104,16 @@ that key is pressed to begin a block literal."
:group 'faces
:group 'yaml)
+(defcustom yaml-imenu-generic-expression
+ '((nil "^\\(:?[a-zA-Z_-]+\\):" 1))
+ "The imenu regex to parse an outline of the yaml file."
+ :type 'string
+ :group 'yaml)
+
;; Constants
-(defconst yaml-mode-version "0.0.4" "Version of `yaml-mode.'")
+(defconst yaml-mode-version "0.0.5" "Version of `yaml-mode.'")
(defconst yaml-blank-line-re "^ *$"
"Regexp matching a line containing only (valid) whitespace.")
@@ -381,6 +387,16 @@ margin."
(if (and (not arg) (looking-at yaml-document-delimiter-re))
(delete-horizontal-space))))
+
+(defun yaml-set-imenu-generic-expression ()
+ (make-local-variable 'imenu-generic-expression)
+ (make-local-variable 'imenu-create-index-function)
+ (setq imenu-create-index-function 'imenu-default-create-index-function)
+ (setq imenu-generic-expression yaml-imenu-generic-expression))
+
+(add-hook 'yaml-mode-hook 'yaml-set-imenu-generic-expression)
+
+
(defun yaml-mode-version ()
"Diplay version of `yaml-mode'."
(interactive)

0 comments on commit f297efe

Please sign in to comment.