From 5efe248f0e15dd0ca9f2c0d73487f28b27661cd3 Mon Sep 17 00:00:00 2001 From: mattn Date: Tue, 14 Feb 2012 19:45:28 +0900 Subject: [PATCH] fix {} regexp pattern. close issue #58 --- autoload/zencoding.vim | 22 +++++++++++----------- plugin/zencoding.vim | 2 +- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/autoload/zencoding.vim b/autoload/zencoding.vim index d201cbd..958b55e 100644 --- a/autoload/zencoding.vim +++ b/autoload/zencoding.vim @@ -1,7 +1,7 @@ "============================================================================= " zencoding.vim " Author: Yasuhiro Matsumoto -" Last Change: 31-Jan-2012. +" Last Change: 14-Feb-2012. let s:save_cpo = &cpo set cpo&vim @@ -69,9 +69,9 @@ function! s:zen_parseIntoTree(abbr, type) let rabbr = substitute(abbr, '\([a-zA-Z][a-zA-Z0-9+]*\)+\([()]\|$\)', '\="(".s:zen_getExpandos(type, submatch(1)).")".submatch(2)', 'i') endif let abbr = rabbr - let mx = '\([+>]\|<\+\)\{-}\s*\((*\)\{-}\s*\([@#.]\{-}[a-zA-Z\!][a-zA-Z0-9:_\!\-$]*\|{[^}]\+}\)\(\%(\%(#{[{}a-zA-Z0-9_\-\$]\+\|#[a-zA-Z0-9_\-\$]\+\)\|\%(\[[^\]]\+\]\)\|\%(\.{[{}a-zA-Z0-9_\-\$]\+\|\.[a-zA-Z0-9_\-\$]\+\)\)*\)\%(\({[^}]\+}\)\)\{0,1}\%(\s*\*\s*\([0-9]\+\)\s*\)\{0,1}\(\%(\s*)\%(\s*\*\s*[0-9]\+\s*\)\{0,1}\)*\)' + let mx = '\([+>]\|<\+\)\{-}\s*\((*\)\{-}\s*\([@#.]\{-}[a-zA-Z\!][a-zA-Z0-9:_\!\-$]*\|{.\+}\)\(\%(\%(#{[{}a-zA-Z0-9_\-\$]\+\|#[a-zA-Z0-9_\-\$]\+\)\|\%(\[[^\]]\+\]\)\|\%(\.{[{}a-zA-Z0-9_\-\$]\+\|\.[a-zA-Z0-9_\-\$]\+\)\)*\)\%(\({[^}]\+}\)\)\{0,1}\%(\s*\*\s*\([0-9]\+\)\s*\)\{0,1}\(\%(\s*)\%(\s*\*\s*[0-9]\+\s*\)\{0,1}\)*\)' else - let mx = '\([+>]\|<\+\)\{-}\s*\((*\)\{-}\s*\([@#.]\{-}[a-zA-Z\!][a-zA-Z0-9:_\!\+\-]*\|{[^}]\+}\)\(\%(\%(#{[{}a-zA-Z0-9_\-\$]\+\|#[a-zA-Z0-9_\-\$]\+\)\|\%(\[[^\]]\+\]\)\|\%(\.{[{}a-zA-Z0-9_\-\$]\+\|\.[a-zA-Z0-9_\-\$]\+\)\)*\)\%(\({[^}]\+}\)\)\{0,1}\%(\s*\*\s*\([0-9]\+\)\s*\)\{0,1}\(\%(\s*)\%(\s*\*\s*[0-9]\+\s*\)\{0,1}\)*\)' + let mx = '\([+>]\|<\+\)\{-}\s*\((*\)\{-}\s*\([@#.]\{-}[a-zA-Z\!][a-zA-Z0-9:_\!\+\-]*\|{.\+}\)\(\%(\%(#{[{}a-zA-Z0-9_\-\$]\+\|#[a-zA-Z0-9_\-\$]\+\)\|\%(\[[^\]]\+\]\)\|\%(\.{[{}a-zA-Z0-9_\-\$]\+\|\.[a-zA-Z0-9_\-\$]\+\)\)*\)\%(\({[^}]\+}\)\)\{0,1}\%(\s*\*\s*\([0-9]\+\)\s*\)\{0,1}\(\%(\s*)\%(\s*\*\s*[0-9]\+\s*\)\{0,1}\)*\)' endif let root = { 'name': '', 'attr': {}, 'child': [], 'snippet': '', 'multiplier': 1, 'parent': {}, 'value': '', 'pos': 0, 'important': 0 } let parent = root @@ -745,7 +745,7 @@ function! zencoding#expandAbbr(mode) range let line = matchstr(line, '^\(.*\%'.col('.').'c.\)') endif if a:mode == 1 - let part = matchstr(line, '\([a-zA-Z0-9_\@:|]\+\)$') + let part = matchstr(line, '\([a-zA-Z0-9:_\-\@|]\+\)$') else let part = matchstr(line, '\(\S.*\)$') if s:zen_isExtends(type, "html") @@ -972,10 +972,10 @@ endfunction function! zencoding#splitJoinTag() let curpos = getpos('.') while 1 - let mx = '<\(/\{0,1}[a-zA-Z][a-zA-Z0-9:]*\)[^>]*>' + let mx = '<\(/\{0,1}[a-zA-Z][a-zA-Z0-9:_\-]*\)[^>]*>' let pos1 = searchpos(mx, 'bcnW') let content = matchstr(getline(pos1[0])[pos1[1]-1:], mx) - let tag_name = substitute(content, '^<\(/\{0,1}[a-zA-Z][a-zA-Z0-9:]*\).*$', '\1', '') + let tag_name = substitute(content, '^<\(/\{0,1}[a-zA-Z][a-zA-Z0-9:_\-]*\).*$', '\1', '') let block = [pos1, [pos1[0], pos1[1] + len(content) - 1]] if content[-2:] == '/>' && s:cursor_in_region(block) let content = content[:-3] . ">' @@ -1019,10 +1019,10 @@ endfunction function! zencoding#removeTag() let curpos = getpos('.') while 1 - let mx = '<\(/\{0,1}[a-zA-Z][a-zA-Z0-9]*\)[^>]*>' + let mx = '<\(/\{0,1}[a-zA-Z][a-zA-Z0-9:_\-]*\)[^>]*>' let pos1 = searchpos(mx, 'bcnW') let content = matchstr(getline(pos1[0])[pos1[1]-1:], mx) - let tag_name = substitute(content, '^<\(/\{0,1}[a-zA-Z0-9]*\).*$', '\1', '') + let tag_name = substitute(content, '^<\(/\{0,1}[a-zA-Z0-9:_\-]*\).*$', '\1', '') let block = [pos1, [pos1[0], pos1[1] + len(content) - 1]] if content[-2:] == '/>' && s:cursor_in_region(block) call s:change_content(block, '') @@ -1062,10 +1062,10 @@ function! zencoding#balanceTag(flag) range let curpos = getpos('.') endif while 1 - let mx = '<\(/\{0,1}[a-zA-Z][a-zA-Z0-9]*\)[^>]*>' + let mx = '<\(/\{0,1}[a-zA-Z][a-zA-Z0-9:_\-]*\)[^>]*>' let pos1 = searchpos(mx, (a:flag == -2 ? 'nW' : 'bcnW')) let content = matchstr(getline(pos1[0])[pos1[1]-1:], mx) - let tag_name = substitute(content, '^<\(/\{0,1}[a-zA-Z0-9]*\).*$', '\1', '') + let tag_name = substitute(content, '^<\(/\{0,1}[a-zA-Z0-9:_\-]*\).*$', '\1', '') let block = [pos1, [pos1[0], pos1[1] + len(content) - 1]] if !s:region_is_valid(block) break @@ -1411,7 +1411,7 @@ function! zencoding#CompleteTag(findstart, base) if a:findstart let line = getline('.') let start = col('.') - 1 - while start > 0 && line[start - 1] =~ '[a-zA-Z0-9:\@]' + while start > 0 && line[start - 1] =~ '[a-zA-Z0-9:_\@\-]' let start -= 1 endwhile return start diff --git a/plugin/zencoding.vim b/plugin/zencoding.vim index 0702e47..561ee54 100644 --- a/plugin/zencoding.vim +++ b/plugin/zencoding.vim @@ -1,7 +1,7 @@ "============================================================================= " File: zencoding.vim " Author: Yasuhiro Matsumoto -" Last Change: 31-Jan-2012. +" Last Change: 02-Feb-2012. " Version: 0.59 " WebPage: http://github.com/mattn/zencoding-vim " Description: vim plugins for HTML and CSS hi-speed coding.