From 1bb674d731cbead58dca863ef1b216444063faae Mon Sep 17 00:00:00 2001 From: mattn Date: Wed, 30 Nov 2011 09:10:52 +0900 Subject: [PATCH 1/5] fixed join tag for xsl. close #48 --- autoload/zencoding.vim | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/autoload/zencoding.vim b/autoload/zencoding.vim index c0227f6..19f0444 100644 --- a/autoload/zencoding.vim +++ b/autoload/zencoding.vim @@ -1,7 +1,7 @@ "============================================================================= " zencoding.vim " Author: Yasuhiro Matsumoto -" Last Change: 25-Nov-2011. +" Last Change: 30-Nov-2011. let s:save_cpo = &cpo set cpo&vim @@ -944,10 +944,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-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] . ">' From 0e104e30f5e665be6a0c732365cfbe5b4fbc5f72 Mon Sep 17 00:00:00 2001 From: mattn Date: Thu, 1 Dec 2011 11:51:48 +0900 Subject: [PATCH 2/5] visual line. --- autoload/zencoding.vim | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/autoload/zencoding.vim b/autoload/zencoding.vim index 19f0444..b25b5a5 100644 --- a/autoload/zencoding.vim +++ b/autoload/zencoding.vim @@ -1,7 +1,7 @@ "============================================================================= " zencoding.vim " Author: Yasuhiro Matsumoto -" Last Change: 30-Nov-2011. +" Last Change: 01-Dec-2011. let s:save_cpo = &cpo set cpo&vim @@ -577,7 +577,6 @@ function! s:zen_toString(...) endif let tmp = substitute(tmp, '\${zenname}', current.name, 'g') if s:zen_isExtends(type, "css") && s:zen_useFilter(filters, 'fc') - let g:hoge = tmp let tmp = substitute(tmp, '^\([^:]\+\):\([^;]*;\)', '\1: \2', '') if current.important let tmp = substitute(tmp, ';', ' !important;', '') @@ -709,7 +708,7 @@ function! zencoding#expandAbbr(mode) range let expand = substitute(expand, '\$line\d*\$', '', 'g') else let str = '' - if a:firstline != a:lastline + if visualmode() ==# 'V' let line = getline(a:firstline) let part = substitute(line, '^\s*', '', '') for n in range(a:firstline, a:lastline) @@ -781,12 +780,17 @@ function! zencoding#expandAbbr(mode) range " TODO: on windows, %z/%Z is 'Tokyo(Standard)' let expand = substitute(expand, '${datetime}', strftime("%Y-%m-%dT%H:%M:%S %z"), 'g') endif - if a:mode == 2 && a:firstline == a:lastline - let expand = substitute(expand, '>\n\s*', '>', 'g') - let expand = substitute(expand, '\${cursor}', '', '') + "if a:mode == 2 + if visualmode() ==# 'v' + if a:firstline == a:lastline + let expand = substitute(expand, '\n\s*', '', 'g') + else + let expand = substitute(expand, '\n\s*', '\n', 'g') + let expand = substitute(expand, '\n$', '', 'g') + endif + let expand = substitute(expand, '\${cursor}', '', 'g') call feedkeys("gvc".expand, 'n') else - let expand = substitute(expand, '\${cursor}', '$cursor$', '') let expand = substitute(expand, '\${cursor}', '', 'g') if line[:-len(part)-1] =~ '^\s\+$' let indent = line[:-len(part)-1] From 513578327cb2f64e752b408622f94792c834d3be Mon Sep 17 00:00:00 2001 From: mattn Date: Mon, 5 Dec 2011 12:40:38 +0900 Subject: [PATCH 3/5] fix cursor position. --- autoload/zencoding.vim | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/autoload/zencoding.vim b/autoload/zencoding.vim index b25b5a5..b00172a 100644 --- a/autoload/zencoding.vim +++ b/autoload/zencoding.vim @@ -1,7 +1,7 @@ "============================================================================= " zencoding.vim " Author: Yasuhiro Matsumoto -" Last Change: 01-Dec-2011. +" Last Change: 05-Dec-2011. let s:save_cpo = &cpo set cpo&vim @@ -788,9 +788,20 @@ function! zencoding#expandAbbr(mode) range let expand = substitute(expand, '\n\s*', '\n', 'g') let expand = substitute(expand, '\n$', '', 'g') endif + let expand = substitute(expand, '\${cursor}', '$cursor$', '') let expand = substitute(expand, '\${cursor}', '', 'g') - call feedkeys("gvc".expand, 'n') + silent! normal! gvc + let line = getline('.') + let lhs = matchstr(line, '.*\%'.col('.').'c.') + let rhs = matchstr(line, '\%>'.col('.').'c.*') + let expand = lhs.expand.rhs + let lines = split(expand, '\n') + call setline(line('.'), lines[0]) + if len(lines) > 1 + call append(line('.'), lines[1:]) + endif else + let expand = substitute(expand, '\${cursor}', '$cursor$', '') let expand = substitute(expand, '\${cursor}', '', 'g') if line[:-len(part)-1] =~ '^\s\+$' let indent = line[:-len(part)-1] @@ -807,7 +818,6 @@ function! zencoding#expandAbbr(mode) range if len(lines) > 1 call append(line('.'), lines[1:]) endif - silent! exe "normal! ".len(part)."h" endif endif if search('\$cursor\$', 'e') From 1f4dbe3917358462f05373fe7dcd0085d8646a82 Mon Sep 17 00:00:00 2001 From: mattn Date: Mon, 5 Dec 2011 14:50:47 +0900 Subject: [PATCH 4/5] check normal mode or not. --- autoload/zencoding.vim | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/autoload/zencoding.vim b/autoload/zencoding.vim index b00172a..fd424be 100644 --- a/autoload/zencoding.vim +++ b/autoload/zencoding.vim @@ -780,8 +780,7 @@ function! zencoding#expandAbbr(mode) range " TODO: on windows, %z/%Z is 'Tokyo(Standard)' let expand = substitute(expand, '${datetime}', strftime("%Y-%m-%dT%H:%M:%S %z"), 'g') endif - "if a:mode == 2 - if visualmode() ==# 'v' + if a:mode != 0 && visualmode() ==# 'v' if a:firstline == a:lastline let expand = substitute(expand, '\n\s*', '', 'g') else From 732a8aa1d183701d0a5ec297e7fb61810ad37c35 Mon Sep 17 00:00:00 2001 From: mattn Date: Wed, 7 Dec 2011 09:12:31 +0900 Subject: [PATCH 5/5] fix parser to match class like ".b-block__subitem". close #50 --- autoload/zencoding.vim | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/autoload/zencoding.vim b/autoload/zencoding.vim index fd424be..f56cc34 100644 --- a/autoload/zencoding.vim +++ b/autoload/zencoding.vim @@ -1,7 +1,7 @@ "============================================================================= " zencoding.vim " Author: Yasuhiro Matsumoto -" Last Change: 05-Dec-2011. +" Last Change: 07-Dec-2011. 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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