branch: elpa/yaml-mode commit f297efe0fc81cf0e561d0c61a025a5c91989823a Author: Tim Harper <timchar...@gmail.com> Commit: Tim Harper <timchar...@gmail.com>
YAML imenu outline integration --- Changes | 2 ++ Makefile | 2 +- yaml-mode.el | 20 ++++++++++++++++++-- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/Changes b/Changes index 4a2b2a6..ae626f5 100644 --- a/Changes +++ b/Changes @@ -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 diff --git a/Makefile b/Makefile index b135d1b..57ccbf5 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -VERSION=0.0.4 +VERSION=0.0.5 EMACS = emacs PREFIX = /usr/local INSTALLLIBDIR = $(PREFIX)/share/emacs/site-lisp diff --git a/yaml-mode.el b/yaml-mode.el index ac9d9bb..a8534d8 100644 --- a/yaml-mode.el +++ b/yaml-mode.el @@ -5,7 +5,7 @@ ;; Author: Yoshiki Kurihara <kurih...@cpan.org> ;; Marshall T. Vandegrift <llas...@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)