From fd6d54a948a4e79b57da12833a41733a2d4ce0d3 Mon Sep 17 00:00:00 2001 From: mattn Date: Thu, 25 Feb 2010 18:02:05 +0900 Subject: [PATCH 1/5] fixed () expression. --- zencoding.vim | 59 ++++++++++++++++++++++++++------------------------- 1 file changed, 30 insertions(+), 29 deletions(-) diff --git a/zencoding.vim b/zencoding.vim index c651249..5961f8b 100644 --- a/zencoding.vim +++ b/zencoding.vim @@ -824,9 +824,9 @@ function! s:zen_parseIntoTree(abbr, type) let abbr = substitute(abbr, '\([a-z][a-z0-9]*\)+\([()]\|$\)', '\="(".s:zen_expandos(submatch(1), type).")".submatch(2)', 'i') let mx = '\([+>]\|<\+\)\{-}\s*\((*\)\{-}\s*\([@#]\{-}[a-z][a-z0-9:\!\-]*\|{[^}]\+}\)\(\%(\%(#[0-9A-Za-z_\-\$]\+\)\|\%(\[[^\]]\+\]\)\|\%(\.[0-9A-Za-z_\-\$]\+\)\)*\)\%(\({[^}]\+}\)\)\{0,1}\%(\*\([0-9]\+\)\)\{0,1}\s*\(+*)\+\)\{0,1}' - let last = {} - let parent = { 'name': '', 'attr': {}, 'child': [], 'snippet': '', 'multiplier': 1, 'parent': {}, 'value': '', 'rank': 0 } - let root = parent + let root = { 'name': '', 'attr': {}, 'child': [], 'snippet': '', 'multiplier': 1, 'parent': {}, 'value': '', 'pos': 0 } + let parent = root + let last = root let pos = [] while len(abbr) let match = matchstr(abbr, mx) @@ -853,7 +853,7 @@ function! s:zen_parseIntoTree(abbr, type) let tag_name = s:zen_settings[type]['aliases'][tag_name] endif endif - let current = { 'name': '', 'attr': {}, 'child': [], 'snippet': '', 'multiplier': 1, 'parent': {}, 'value': '', 'rank': 0 } + let current = { 'name': '', 'attr': {}, 'child': [], 'snippet': '', 'multiplier': 1, 'parent': {}, 'value': '', 'pos': 0 } if has_key(s:zen_settings[type]['snippets'], tag_name) let current['snippet'] = s:zen_settings[type]['snippets'][tag_name] else @@ -905,20 +905,18 @@ function! s:zen_parseIntoTree(abbr, type) let current['multiplier'] = multiplier if !empty(last) - if operator == '>' - "let tmp = parent + if operator =~ '>' unlet! parent let parent = last - "let parent['parent'] = tmp let current['parent'] = last - let current['rank'] = last['rank'] + 1 + let current['pos'] = last['pos'] + 1 else let current['parent'] = parent - let current['rank'] = last['rank'] + let current['pos'] = last['pos'] endif else let current['parent'] = parent - let current['rank'] = 1 + let current['pos'] = 1 endif if operator =~ '<' for c in range(len(operator)) @@ -934,8 +932,29 @@ function! s:zen_parseIntoTree(abbr, type) let last = current if block_start == '(' - let pos += [last['rank']] + if operator =~ '>' + let last['pos'] += 1 + let pos += [last['pos']] + else + let pos += [last['pos']] + endif endif + + if block_end =~ ')' + for n in range(len(block_end)) + for c in range(last['pos'] - pos[-1]) + let tmp = parent['parent'] + if !has_key(tmp, 'parent') + break + endif + let parent = tmp + endfor + call remove(pos, -1) + let last = parent + let last['pos'] += 1 + endfor + endif + let abbr = abbr[stridx(abbr, match) + len(match):] if 0 echo "str=".str echo "block_start=".block_start @@ -949,21 +968,6 @@ function! s:zen_parseIntoTree(abbr, type) echo "pos=".string(pos) echo "\n" endif - if block_end =~ ')' - for n in range(len(block_end)) - let parent = last['parent'] - for c in range(last['rank'] - pos[-1]) - let tmp = parent['parent'] - if !has_key(tmp, 'parent') - break - endif - let parent = tmp - endfor - let last = parent - call remove(pos, -1) - endfor - endif - let abbr = abbr[stridx(abbr, match) + len(match):] endwhile return root endfunction @@ -1217,9 +1221,6 @@ endif "echo ZenExpand('a>b>c<h1)+#content+#footer', '') "echo ZenExpand('(#header>h1)+(#content>(#main>h2+div#entry$.section*5>(h3>a)+div>p*3+ul+)+(#utilities))+(#footer>address)', '') -"echo ZenExpand('(#header>h1)+(#content>(#main>h2+div#entry$.section*5>(h3>a)+div>p*3+(ul))+(#utilities))+(#footer>address)', '') -"echo ZenExpand('(#header>h1)+(#content>(#main>h2+div#entry$.section*5>(h3>a)+div>p*3+ul+)+(#utilities))+(#footer>address)', '') -"echo ZenExpand('#content>(#main>div#entry$*5>(h3>a)+div>p*3)+#utilities', '') "echo ZenExpand('(div>(ul))+(#utilities)', '') " vim:set et: From e4a0da1e4a11727245ea29cffdfcb0b9672ddf9f Mon Sep 17 00:00:00 2001 From: mattn Date: Thu, 25 Feb 2010 18:03:19 +0900 Subject: [PATCH 2/5] add doc. --- zencoding.vim.vimup | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zencoding.vim.vimup b/zencoding.vim.vimup index 35feb73..b3a7894 100644 --- a/zencoding.vim.vimup +++ b/zencoding.vim.vimup @@ -79,7 +79,7 @@ install_details: | versions: - '0.23': | - This is an upgrade for ZenCoding.vim: pre-expand '#header>li<#content' to 'div#header>lili<#content' to 'div#header>lili'. fix undo ring. support visual selection. when type trigger key on visual select, it request you leader like 'ul>li'. if you give 'ul>li*' as leader, you'll get each separate 'ul>li' tags. and when you give 'blockquote' as leader, you'll get blocked text. - '0.21': | From c02eae3d0ce7dc1b1e9a94e99c4a12a8b700d164 Mon Sep 17 00:00:00 2001 From: mattn Date: Thu, 25 Feb 2010 21:21:51 +0900 Subject: [PATCH 3/5] fixed behavior of parsing area of visual selection. --- zencoding.vim | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/zencoding.vim b/zencoding.vim index 5961f8b..5a4bd4d 100644 --- a/zencoding.vim +++ b/zencoding.vim @@ -768,6 +768,7 @@ let s:zen_settings = { \ 'inline_elements': 'a,abbr,acronym,applet,b,basefont,bdo,big,br,button,cite,code,del,dfn,em,font,i,iframe,img,input,ins,kbd,label,map,object,q,s,samp,script,select,small,span,strike,strong,sub,sup,textarea,tt,u,var', \ }, \ 'xsl': { +\ 'extends': 'html', \ 'default_attributes': { \ 'tmatch': [{'match': ''}, {'mode': ''}], \ 'tname': [{'name': ''}], @@ -802,6 +803,12 @@ let s:zen_settings = { \ 'expandos': { \ 'choose': 'xsl:choose>xsl:when+xsl:otherwise' \ } +\ }, +\ 'haml': { +\ 'extends': 'html' +\ }, +\ 'xhtml': { +\ 'extends': 'html' \ } \} @@ -1057,12 +1064,18 @@ function! s:zen_expand(mode) range let line = '' let part = '' let rest = '' - if leader =~ '\*$' + if leader =~ '*' + let query = substitute(leader, '*', '{$line$}*' . (a:lastline - a:firstline + 1), '') + let items = s:zen_parseIntoTree(query, type)['child'] + for item in items + let expand .= s:zen_toString(item, type) + endfor + let line = getline(a:firstline) + let part = substitute(line, '^\s*', '', '') for n in range(a:firstline, a:lastline) - let items = s:zen_parseIntoTree(leader[:-2] . '{' . getline(n) . '}', type)['child'] - for item in items - let expand .= s:zen_toString(item, type) - endfor + let lline = getline(n) + let lpart = substitute(lline, '^\s*', '', '') + let expand = substitute(expand, '\$line\$', lpart, '') endfor else let str = '' From 9e03ea8a56f6713da399c3590eeb8892d016e50b Mon Sep 17 00:00:00 2001 From: mattn Date: Thu, 25 Feb 2010 21:23:12 +0900 Subject: [PATCH 4/5] fixed behavior of parsing area of visual selection. --- zencoding.vim | 2 +- zencoding.vim.vimup | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/zencoding.vim b/zencoding.vim index 5a4bd4d..c96b0ff 100644 --- a/zencoding.vim +++ b/zencoding.vim @@ -2,7 +2,7 @@ " File: zencoding.vim " Author: Yasuhiro Matsumoto " Last Change: 25-Feb-2010. -" Version: 0.23 +" Version: 0.24 " WebPage: http://github.com/mattn/zencoding-vim " Description: vim plugins for HTML and CSS hi-speed coding. " SeeAlso: http://code.google.com/p/zen-coding/ diff --git a/zencoding.vim.vimup b/zencoding.vim.vimup index b3a7894..e1f8c88 100644 --- a/zencoding.vim.vimup +++ b/zencoding.vim.vimup @@ -2,7 +2,7 @@ script_name: ZenCoding.vim script_id: '2981' script_type: utility script_package: zencoding.vim -script_version: '0.23' +script_version: '0.24' required_vim_version: '7.0' summary: vim plugins for HTML and CSS hi-speed coding. @@ -78,6 +78,8 @@ install_details: | copy zencoding.vim to your plugin directory. versions: +- '0.24': | + This is an upgrade for ZenCoding.vim: fixed behavior of parsing area of visual selection. - '0.23': | This is an upgrade for ZenCoding.vim: pre-expand '#header>li<#content' to 'div#header>li Date: Thu, 25 Feb 2010 21:29:44 +0900 Subject: [PATCH 5/5] fixed indent. --- zencoding.vim | 2 ++ 1 file changed, 2 insertions(+) diff --git a/zencoding.vim b/zencoding.vim index c96b0ff..af0e789 100644 --- a/zencoding.vim +++ b/zencoding.vim @@ -1080,6 +1080,8 @@ function! s:zen_expand(mode) range else let str = '' if a:firstline != a:lastline + let line = getline(a:firstline) + let part = substitute(line, '^\s*', '', '') for n in range(a:firstline, a:lastline) let str .= getline(n) . "\n" endfor