From d4e2098277c66a35a940624c0fd6869d17da1939 Mon Sep 17 00:00:00 2001 From: mattn Date: Fri, 26 Feb 2010 10:07:16 +0900 Subject: [PATCH 1/7] store undo before working. --- zencoding.vim | 8 ++++---- zencoding.vim.vimup | 4 +++- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/zencoding.vim b/zencoding.vim index af0e789..d21560e 100644 --- a/zencoding.vim +++ b/zencoding.vim @@ -1,8 +1,8 @@ "============================================================================= " File: zencoding.vim " Author: Yasuhiro Matsumoto -" Last Change: 25-Feb-2010. -" Version: 0.24 +" Last Change: 26-Feb-2010. +" Version: 0.25 " 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/ @@ -70,8 +70,8 @@ if exists('g:use_zen_complete_tag') && g:use_zen_complete_tag setlocal completefunc=ZenCompleteTag endif -inoremap ZenCodingExpandAbbr :call zen_expand(0)a -inoremap ZenCodingExpandWord :call zen_expand(1)a +inoremap ZenCodingExpandAbbr u:call zen_expand(0)a +inoremap ZenCodingExpandWord u:call zen_expand(1)a vnoremap ZenCodingExpandVisual :call zen_expand(2) if !exists('g:user_zen_expandword_key') diff --git a/zencoding.vim.vimup b/zencoding.vim.vimup index e1f8c88..972aeb5 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.24' +script_version: '0.25' 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.25': | + This is an upgrade for ZenCoding.vim: store undo before working. - '0.24': | This is an upgrade for ZenCoding.vim: fixed behavior of parsing area of visual selection. - '0.23': | From 4d0f1b94223993fa9f40fc2756a15a4f87faa7fc Mon Sep 17 00:00:00 2001 From: mattn Date: Fri, 26 Feb 2010 10:17:22 +0900 Subject: [PATCH 2/7] move cursor pos to position of empty attribute values. --- zencoding.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/zencoding.vim b/zencoding.vim index d21560e..5812e35 100644 --- a/zencoding.vim +++ b/zencoding.vim @@ -871,12 +871,12 @@ function! s:zen_parseIntoTree(abbr, type) if type(default_attributes[tag_name]) == 4 let a = default_attributes[tag_name] for k in keys(a) - let current['attr'][k] = a[k] + let current['attr'][k] = len(a[k]) ? a[k] : '|' endfor else for a in default_attributes[tag_name] for k in keys(a) - let current['attr'][k] = a[k] + let current['attr'][k] = len(a[k]) ? a[k] : '|' endfor endfor endif From f33f8aab68c7ac0277b5d7fea480b87c8025b621 Mon Sep 17 00:00:00 2001 From: mattn Date: Fri, 26 Feb 2010 17:36:29 +0900 Subject: [PATCH 3/7] for debug. --- zencoding.vim | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/zencoding.vim b/zencoding.vim index 5812e35..c28fe04 100644 --- a/zencoding.vim +++ b/zencoding.vim @@ -962,7 +962,7 @@ function! s:zen_parseIntoTree(abbr, type) endfor endif let abbr = abbr[stridx(abbr, match) + len(match):] - if 0 + if exists('g:zencoding_debug') echo "str=".str echo "block_start=".block_start echo "tag_name=".tag_name @@ -1202,7 +1202,10 @@ if exists('g:user_zen_settings') call s:zen_mergeConfig(s:zen_settings, g:user_zen_settings) endif -" test +if !exists('g:zencoding_debug') + finish +endif + "echo ZenExpand('html:xt>div#header>div#logo+ul#nav>li.item-$*5>a', '') "echo ZenExpand('ol>li*2', '') "echo ZenExpand('a', '') From 98116f925e9efb806c90b7b2e0d346a072bb9c2e Mon Sep 17 00:00:00 2001 From: mattn Date: Fri, 26 Feb 2010 17:50:17 +0900 Subject: [PATCH 4/7] good luck about 'table>(tr>td*3)*4' --- zencoding.vim | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/zencoding.vim b/zencoding.vim index c28fe04..37e56a3 100644 --- a/zencoding.vim +++ b/zencoding.vim @@ -830,7 +830,7 @@ function! s:zen_parseIntoTree(abbr, type) endif 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 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}\%(\*\([0-9]\+\)\)\{0,1}' let root = { 'name': '', 'attr': {}, 'child': [], 'snippet': '', 'multiplier': 1, 'parent': {}, 'value': '', 'pos': 0 } let parent = root let last = root @@ -845,6 +845,7 @@ function! s:zen_parseIntoTree(abbr, type) let value = substitute(match, mx, '\5', 'ig') let multiplier = 0 + substitute(match, mx, '\6', 'ig') let block_end = substitute(match, mx, '\7', 'ig') + let multiplier_block = 0 + substitute(match, mx, '\8', 'ig') if len(str) == 0 break endif @@ -852,9 +853,8 @@ function! s:zen_parseIntoTree(abbr, type) let attributes = tag_name . attributes let tag_name = 'div' endif - if multiplier <= 0 - let multiplier = 1 - endif + if multiplier <= 0 | let multiplier = 1 | endif + if multiplier_block <= 0 | let multiplier_block = 1 | endif if has_key(s:zen_settings[type], 'aliases') if has_key(s:zen_settings[type]['aliases'], tag_name) let tag_name = s:zen_settings[type]['aliases'][tag_name] @@ -910,6 +910,7 @@ function! s:zen_parseIntoTree(abbr, type) let current['value'] = value endif let current['multiplier'] = multiplier + let current['multiplier'] = multiplier if !empty(last) if operator =~ '>' @@ -958,6 +959,7 @@ function! s:zen_parseIntoTree(abbr, type) endfor call remove(pos, -1) let last = parent + let last['child'][-1]['multiplier'] = multiplier_block let last['pos'] += 1 endfor endif @@ -971,6 +973,7 @@ function! s:zen_parseIntoTree(abbr, type) echo "value=".value echo "multiplier=".multiplier echo "block_end=".block_end + echo "multiplier_block=".multiplier_block echo "abbr=".abbr echo "pos=".string(pos) echo "\n" @@ -1240,5 +1243,6 @@ endif "echo ZenExpand('(#header>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('(div>(ul))+(#utilities)', '') +"echo ZenExpand('table>(tr>td*3)*4', '') " vim:set et: From 8a0a16099614a3e46c1465cce3b579ccbcbabfce Mon Sep 17 00:00:00 2001 From: mattn Date: Fri, 26 Feb 2010 17:53:12 +0900 Subject: [PATCH 5/7] add doc. --- zencoding.vim.vimup | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zencoding.vim.vimup b/zencoding.vim.vimup index 972aeb5..cd58ed6 100644 --- a/zencoding.vim.vimup +++ b/zencoding.vim.vimup @@ -79,7 +79,7 @@ install_details: | versions: - '0.25': | - This is an upgrade for ZenCoding.vim: store undo before working. + This is an upgrade for ZenCoding.vim: store undo before working. good luck about 'table>(tr>td*3)*4'. - '0.24': | This is an upgrade for ZenCoding.vim: fixed behavior of parsing area of visual selection. - '0.23': | From d987123e704d06fc9db8ee52effcd42756a81421 Mon Sep 17 00:00:00 2001 From: mattn Date: Fri, 26 Feb 2010 21:26:29 +0900 Subject: [PATCH 6/7] The count of '(((a#foo + a#bar)*2)*3)' should be 12. --- zencoding.vim | 171 +++++++++++++++++++++++--------------------- zencoding.vim.vimup | 7 +- 2 files changed, 93 insertions(+), 85 deletions(-) diff --git a/zencoding.vim b/zencoding.vim index 37e56a3..d9c835d 100644 --- a/zencoding.vim +++ b/zencoding.vim @@ -2,7 +2,7 @@ " File: zencoding.vim " Author: Yasuhiro Matsumoto " Last Change: 26-Feb-2010. -" Version: 0.25 +" Version: 0.26 " 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/ @@ -61,7 +61,7 @@ " \ } " \} " -" You can set language attribute in html using zen_settings['lang']. +" You can set language attribute in html using 'zen_settings.lang'. " " GetLatestVimScripts: 2981 1 :AutoInstall: zencoding.vim " script type: plugin @@ -814,8 +814,8 @@ let s:zen_settings = { function! s:zen_expandos(key, type) if has_key(s:zen_settings[a:type], 'expandos') - if has_key(s:zen_settings[a:type]['expandos'], a:key) - return s:zen_settings[a:type]['expandos'][a:key] + if has_key(s:zen_settings[a:type].expandos, a:key) + return s:zen_settings[a:type].expandos[a:key] endif endif return a:key @@ -830,7 +830,7 @@ function! s:zen_parseIntoTree(abbr, type) endif 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}\%(\*\([0-9]\+\)\)\{0,1}' + let mx = '\([+>]\|<\+\)\{-}\s*\((*\)\{-}\s*\([@#]\{-}[a-z][a-z0-9:\!\-]*\|{[^}]\+}\)\(\%(\%(#[0-9A-Za-z_\-\$]\+\)\|\%(\[[^\]]\+\]\)\|\%(\.[0-9A-Za-z_\-\$]\+\)\)*\)\%(\({[^}]\+}\)\)\{0,1}\%(\s*\*\s*\([0-9]\+\)\s*\)\{0,1}\(\%(\s*)\%(\s*\*\s*[0-9]\+\s*\)\{0,1}\)*\)' let root = { 'name': '', 'attr': {}, 'child': [], 'snippet': '', 'multiplier': 1, 'parent': {}, 'value': '', 'pos': 0 } let parent = root let last = root @@ -845,7 +845,6 @@ function! s:zen_parseIntoTree(abbr, type) let value = substitute(match, mx, '\5', 'ig') let multiplier = 0 + substitute(match, mx, '\6', 'ig') let block_end = substitute(match, mx, '\7', 'ig') - let multiplier_block = 0 + substitute(match, mx, '\8', 'ig') if len(str) == 0 break endif @@ -854,29 +853,28 @@ function! s:zen_parseIntoTree(abbr, type) let tag_name = 'div' endif if multiplier <= 0 | let multiplier = 1 | endif - if multiplier_block <= 0 | let multiplier_block = 1 | endif if has_key(s:zen_settings[type], 'aliases') - if has_key(s:zen_settings[type]['aliases'], tag_name) - let tag_name = s:zen_settings[type]['aliases'][tag_name] + if has_key(s:zen_settings[type].aliases, tag_name) + let tag_name = s:zen_settings[type].aliases[tag_name] endif endif 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] + if has_key(s:zen_settings[type].snippets, tag_name) + let current.snippet = s:zen_settings[type].snippets[tag_name] else - let current['name'] = substitute(tag_name, ':.*$', '', '') + let current.name = substitute(tag_name, ':.*$', '', '') if has_key(s:zen_settings[type], 'default_attributes') - let default_attributes = s:zen_settings[type]['default_attributes'] + let default_attributes = s:zen_settings[type].default_attributes if has_key(default_attributes, tag_name) if type(default_attributes[tag_name]) == 4 let a = default_attributes[tag_name] for k in keys(a) - let current['attr'][k] = len(a[k]) ? a[k] : '|' + let current.attr[k] = len(a[k]) ? a[k] : '|' endfor else for a in default_attributes[tag_name] for k in keys(a) - let current['attr'][k] = len(a[k]) ? a[k] : '|' + let current.attr[k] = len(a[k]) ? a[k] : '|' endfor endfor endif @@ -891,44 +889,44 @@ function! s:zen_parseIntoTree(abbr, type) break endif if item[0] == '#' - let current['attr']['id'] = item[1:] + let current.attr.id = item[1:] endif if item[0] == '.' - let current['attr']['class'] = substitute(item[1:], '\.', '', 'g') + let current.attr.class = substitute(item[1:], '\.', '', 'g') endif if item[0] == '[' let kk = split(item[1:-2], '=') - let current['attr'][kk[0]] = len(kk) > 1 ? join(kk[1:], '=') : '' + let current.attr[kk[0]] = len(kk) > 1 ? join(kk[1:], '=') : '' endif let attr = substitute(strpart(attr, len(item)), '^\s*', '', '') endwhile endif if tag_name =~ '^{.*}$' - let current['name'] = '' - let current['value'] = str + let current.name = '' + let current.value = str else - let current['value'] = value + let current.value = value endif - let current['multiplier'] = multiplier - let current['multiplier'] = multiplier + let current.multiplier = multiplier + let current.multiplier = multiplier if !empty(last) if operator =~ '>' unlet! parent let parent = last - let current['parent'] = last - let current['pos'] = last['pos'] + 1 + let current.parent = last + let current.pos = last.pos + 1 else - let current['parent'] = parent - let current['pos'] = last['pos'] + let current.parent = parent + let current.pos = last.pos endif else - let current['parent'] = parent - let current['pos'] = 1 + let current.parent = parent + let current.pos = 1 endif if operator =~ '<' for c in range(len(operator)) - let tmp = parent['parent'] + let tmp = parent.parent if empty(tmp) break endif @@ -936,31 +934,38 @@ function! s:zen_parseIntoTree(abbr, type) endfor endif - call add(parent['child'], current) + call add(parent.child, current) let last = current - if block_start == '(' - if operator =~ '>' - let last['pos'] += 1 - let pos += [last['pos']] - else - let pos += [last['pos']] - endif + if block_start =~ '(' + for n in range(len(block_start)) + let pos += [last.pos] + endfor 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 + for n in split(substitute(block_end, ' ', '', 'g'), ')', 1) + if n == '' + if len(pos) > 0 && last.pos >= pos[-1] + 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 endif - let parent = tmp - endfor - call remove(pos, -1) - let last = parent - let last['child'][-1]['multiplier'] = multiplier_block - let last['pos'] += 1 + else + let cl = last.child + let cls = [] + for c in range(n[1:]) + let cls += cl + endfor + let last.child = cls + endif endfor endif let abbr = abbr[stridx(abbr, match) + len(match):] @@ -973,7 +978,6 @@ function! s:zen_parseIntoTree(abbr, type) echo "value=".value echo "multiplier=".multiplier echo "block_end=".block_end - echo "multiplier_block=".multiplier_block echo "abbr=".abbr echo "pos=".string(pos) echo "\n" @@ -992,52 +996,52 @@ function! s:zen_toString(...) if len(type) == 0 | let type = 'html' | endif if has_key(s:zen_settings[type], 'indentation') - let indent = s:zen_settings[type]['indentation'] + let indent = s:zen_settings[type].indentation else - let indent = s:zen_settings['indentation'] + let indent = s:zen_settings.indentation endif let m = 0 let str = '' - while m < current['multiplier'] - if len(current['name']) && type == 'html' - let str .= '<' . current['name'] - for attr in keys(current['attr']) - if current['multiplier'] > 1 && current['attr'][attr] =~ '\$' - let str .= ' ' . attr . '="' . substitute(current['attr'][attr], '\$', m+1, 'g') . '"' + while m < current.multiplier + if len(current.name) && type == 'html' + let str .= '<' . current.name + for attr in keys(current.attr) + if current.multiplier > 1 && current.attr[attr] =~ '\$' + let str .= ' ' . attr . '="' . substitute(current.attr[attr], '\$', m+1, 'g') . '"' else - let str .= ' ' . attr . '="' . current['attr'][attr] . '"' + let str .= ' ' . attr . '="' . current.attr[attr] . '"' endif endfor - let inner = current['value'][1:-2] - for child in current['child'] + let inner = current.value[1:-2] + for child in current.child let inner .= s:zen_toString(child, type) endfor - if len(current['child']) + if len(current.child) let inner = substitute(inner, "\n", "\n" . indent, 'g') let inner = substitute(inner, indent . "$", "", 'g') - let str .= ">\n" . indent . inner . "\n" + let str .= ">\n" . indent . inner . "\n" else - if stridx(','.s:zen_settings[type]['empty_elements'].',', ','.current['name'].',') != -1 + if stridx(','.s:zen_settings[type].empty_elements.',', ','.current.name.',') != -1 let str .= " />\n" else - if stridx(','.s:zen_settings[type]['block_elements'].',', ','.current['name'].',') != -1 && len(current['child']) - let str .= ">\n" . inner . "|\n" + if stridx(','.s:zen_settings[type].block_elements.',', ','.current.name.',') != -1 && len(current.child) + let str .= ">\n" . inner . "|\n" else - let str .= ">" . inner . "|\n" + let str .= ">" . inner . "|\n" endif endif endif else - let str .= '' . current['snippet'] + let str .= '' . current.snippet if len(str) == 0 - let str = current['name'] - if len(current['value']) - let str .= current['value'][1:-2] + let str = current.name + if len(current.value) + let str .= current.value[1:-2] endif endif let inner = '' - if len(current['child']) - for n in current['child'] + if len(current.child) + for n in current.child let inner .= s:zen_toString(n, type) endfor let inner = substitute(inner, "\n", "\n" . indent, 'g') @@ -1069,7 +1073,7 @@ function! s:zen_expand(mode) range let rest = '' if leader =~ '*' let query = substitute(leader, '*', '{$line$}*' . (a:lastline - a:firstline + 1), '') - let items = s:zen_parseIntoTree(query, type)['child'] + let items = s:zen_parseIntoTree(query, type).child for item in items let expand .= s:zen_toString(item, type) endfor @@ -1088,10 +1092,10 @@ function! s:zen_expand(mode) range for n in range(a:firstline, a:lastline) let str .= getline(n) . "\n" endfor - let items = s:zen_parseIntoTree(leader . "{\n" . str . "}", type)['child'] + let items = s:zen_parseIntoTree(leader . "{\n" . str . "}", type).child else let str .= getline(a:firstline) - let items = s:zen_parseIntoTree(leader . "{" . str . "}", type)['child'] + let items = s:zen_parseIntoTree(leader . "{" . str . "}", type).child endif for item in items let expand .= s:zen_toString(item, type) @@ -1106,7 +1110,7 @@ function! s:zen_expand(mode) range let part = matchstr(line, '\(\S.*\)$') endif let rest = getline('.')[col('.'):] - let items = s:zen_parseIntoTree(part, type)['child'] + let items = s:zen_parseIntoTree(part, type).child for item in items let expand .= s:zen_toString(item, type) endfor @@ -1118,10 +1122,10 @@ function! s:zen_expand(mode) range if expand !~ '|' let expand .= '|' endif - let expand = substitute(expand, '${lang}', s:zen_settings['lang'], 'g') + let expand = substitute(expand, '${lang}', s:zen_settings.lang, 'g') if line[:-len(part)-1] =~ '^\s\+$' let size = len(line) - len(part) - let indent = repeat(s:zen_settings['indentation'], size) + let indent = repeat(s:zen_settings.indentation, size) else let indent = '' endif @@ -1139,7 +1143,7 @@ function! s:zen_expand(mode) range endfunction function! ZenExpand(abbr, type) - let items = s:zen_parseIntoTree(a:abbr, a:type)['child'] + let items = s:zen_parseIntoTree(a:abbr, a:type).child let expand = '' for item in items let expand .= s:zen_toString(item, a:type) @@ -1185,13 +1189,13 @@ function! ZenCompleteTag(findstart, base) return res endif if len(type) == 0 | let type = 'html' | endif - for item in keys(s:zen_settings[type]['snippets']) + for item in keys(s:zen_settings[type].snippets) if stridx(item, a:base) != -1 call add(res, item) endif endfor if has_key(s:zen_settings[type], 'aliases') - for item in values(s:zen_settings[type]['aliases']) + for item in values(s:zen_settings[type].aliases) if stridx(item, a:base) != -1 call add(res, item) endif @@ -1242,7 +1246,8 @@ 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('(div>(ul))+(#utilities)', '') +"echo ZenExpand('(div>(ul*2))+(#utilities)', '') "echo ZenExpand('table>(tr>td*3)*4', '') +"echo ZenExpand('(((a#foo+a#bar)*2)*3)', '') " vim:set et: diff --git a/zencoding.vim.vimup b/zencoding.vim.vimup index cd58ed6..d47b27e 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.25' +script_version: '0.26' required_vim_version: '7.0' summary: vim plugins for HTML and CSS hi-speed coding. @@ -22,7 +22,8 @@ detailed_description: | +------------------------------------- | html:5_ +------------------------------------- - "_" is a cursor position. and type "," + "_" is a cursor position. and type "," (Ctrl + z and Comma) + NOTE: Don't worry about key map. you can change it easily. +------------------------------------- | | @@ -78,6 +79,8 @@ install_details: | copy zencoding.vim to your plugin directory. versions: +- '0.26': | + This is an upgrade for ZenCoding.vim: The count of '(((a#foo + a#bar)*2)*3)' should be 12. - '0.25': | This is an upgrade for ZenCoding.vim: store undo before working. good luck about 'table>(tr>td*3)*4'. - '0.24': | From 8b76c77b504a33637f44bb54dfebd60006b63882 Mon Sep 17 00:00:00 2001 From: mattn Date: Fri, 26 Feb 2010 21:58:38 +0900 Subject: [PATCH 7/7] oops --- zencoding.vim | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/zencoding.vim b/zencoding.vim index d9c835d..489ace8 100644 --- a/zencoding.vim +++ b/zencoding.vim @@ -66,6 +66,10 @@ " GetLatestVimScripts: 2981 1 :AutoInstall: zencoding.vim " script type: plugin +if !exists('g:zencoding_debug') + let g:zencoding_debug = 0 +endif + if exists('g:use_zen_complete_tag') && g:use_zen_complete_tag setlocal completefunc=ZenCompleteTag endif @@ -90,7 +94,7 @@ if !hasmapto(g:user_zen_expandabbr_key, 'v') exe "vmap " . g:user_zen_expandabbr_key . " ZenCodingExpandVisual" endif -if exists('s:zen_settings') && !exists('g:zencoding_debug') +if exists('s:zen_settings') && g:zencoding_debug == 0 finish endif @@ -908,7 +912,6 @@ function! s:zen_parseIntoTree(abbr, type) let current.value = value endif let current.multiplier = multiplier - let current.multiplier = multiplier if !empty(last) if operator =~ '>' @@ -938,14 +941,17 @@ function! s:zen_parseIntoTree(abbr, type) let last = current if block_start =~ '(' + if operator =~ '>' + let last.pos += 1 + endif for n in range(len(block_start)) let pos += [last.pos] endfor endif if block_end =~ ')' - for n in split(substitute(block_end, ' ', '', 'g'), ')', 1) - if n == '' + for n in split(substitute(substitute(block_end, ' ', '', 'g'), ')', ',),', 'g'), ',') + if n == ')' if len(pos) > 0 && last.pos >= pos[-1] for c in range(last.pos - pos[-1]) let tmp = parent.parent @@ -958,7 +964,7 @@ function! s:zen_parseIntoTree(abbr, type) let last = parent let last.pos += 1 endif - else + elseif len(n) let cl = last.child let cls = [] for c in range(n[1:]) @@ -969,7 +975,7 @@ function! s:zen_parseIntoTree(abbr, type) endfor endif let abbr = abbr[stridx(abbr, match) + len(match):] - if exists('g:zencoding_debug') + if g:zencoding_debug > 1 echo "str=".str echo "block_start=".block_start echo "tag_name=".tag_name @@ -1209,7 +1215,7 @@ if exists('g:user_zen_settings') call s:zen_mergeConfig(s:zen_settings, g:user_zen_settings) endif -if !exists('g:zencoding_debug') +if g:zencoding_debug == 0 finish endif @@ -1246,7 +1252,7 @@ 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('(div>(ul*2))+(#utilities)', '') +"echo ZenExpand('(div>(ul*2)*2)+(#utilities)', '') "echo ZenExpand('table>(tr>td*3)*4', '') "echo ZenExpand('(((a#foo+a#bar)*2)*3)', '')