Fixes against errors/warnings in vint

This commit is contained in:
mattn
2014-12-17 17:26:10 +09:00
parent edf74342b5
commit 47b54c2e5e
11 changed files with 253 additions and 254 deletions

View File

@@ -11,10 +11,10 @@
" --------------------
" begin::end
" --------------------
function! emmet#util#deleteContent(region)
function! emmet#util#deleteContent(region) abort
let lines = getline(a:region[0][0], a:region[1][0])
call setpos('.', [0, a:region[0][0], a:region[0][1], 0])
silent! exe "delete ".(a:region[1][0] - a:region[0][0])
silent! exe 'delete '.(a:region[1][0] - a:region[0][0])
call setline(line('.'), lines[0][:a:region[0][1]-2] . lines[-1][a:region[1][1]])
endfunction
@@ -36,11 +36,11 @@ endfunction
" bar
" baz:end
" --------------------
function! emmet#util#setContent(region, content)
function! emmet#util#setContent(region, content) abort
let newlines = split(a:content, '\n', 1)
let oldlines = getline(a:region[0][0], a:region[1][0])
call setpos('.', [0, a:region[0][0], a:region[0][1], 0])
silent! exe "delete ".(a:region[1][0] - a:region[0][0])
silent! exe 'delete '.(a:region[1][0] - a:region[0][0])
if len(newlines) == 0
let tmp = ''
if a:region[0][1] > 1
@@ -72,7 +72,7 @@ endfunction
" select_region : select region
" this function make a selection of region
function! emmet#util#selectRegion(region)
function! emmet#util#selectRegion(region) abort
call setpos('.', [0, a:region[1][0], a:region[1][1], 0])
normal! v
call setpos('.', [0, a:region[0][0], a:region[0][1], 0])
@@ -80,7 +80,7 @@ endfunction
" point_in_region : check point is in the region
" this function return 0 or 1
function! emmet#util#pointInRegion(point, region)
function! emmet#util#pointInRegion(point, region) abort
if !emmet#util#regionIsValid(a:region) | return 0 | endif
if a:region[0][0] > a:point[0] | return 0 | endif
if a:region[1][0] < a:point[0] | return 0 | endif
@@ -91,7 +91,7 @@ endfunction
" cursor_in_region : check cursor is in the region
" this function return 0 or 1
function! emmet#util#cursorInRegion(region)
function! emmet#util#cursorInRegion(region) abort
if !emmet#util#regionIsValid(a:region) | return 0 | endif
let cur = emmet#util#getcurpos()[1:2]
return emmet#util#pointInRegion(cur, a:region)
@@ -99,14 +99,14 @@ endfunction
" region_is_valid : check region is valid
" this function return 0 or 1
function! emmet#util#regionIsValid(region)
function! emmet#util#regionIsValid(region) abort
if a:region[0][0] == 0 || a:region[1][0] == 0 | return 0 | endif
return 1
endfunction
" search_region : make region from pattern which is composing start/end
" this function return array of position
function! emmet#util#searchRegion(start, end)
function! emmet#util#searchRegion(start, end) abort
let b = searchpairpos(a:start, '', a:end, 'bcnW')
if b == [0, 0]
return [searchpairpos(a:start, '', a:end, 'bnW'), searchpairpos(a:start, '\%#', a:end, 'nW')]
@@ -117,7 +117,7 @@ endfunction
" get_content : get content in region
" this function return string in region
function! emmet#util#getContent(region)
function! emmet#util#getContent(region) abort
if !emmet#util#regionIsValid(a:region)
return ''
endif
@@ -133,7 +133,7 @@ endfunction
" region_in_region : check region is in the region
" this function return 0 or 1
function! emmet#util#regionInRegion(outer, inner)
function! emmet#util#regionInRegion(outer, inner) abort
if !emmet#util#regionIsValid(a:inner) || !emmet#util#regionIsValid(a:outer)
return 0
endif
@@ -142,16 +142,16 @@ endfunction
" get_visualblock : get region of visual block
" this function return region of visual block
function! emmet#util#getVisualBlock()
function! emmet#util#getVisualBlock() abort
return [[line("'<"), col("'<")], [line("'>"), col("'>")]]
endfunction
"==============================================================================
" html utils
"==============================================================================
function! emmet#util#getContentFromURL(url)
let res = system(printf("%s -i %s", g:emmet_curl_command, shellescape(substitute(a:url, '#.*', '', ''))))
while res =~ '^HTTP/1.\d 3' || res =~ '^HTTP/1\.\d 200 Connection established' || res =~ '^HTTP/1\.\d 100 Continue'
function! emmet#util#getContentFromURL(url) abort
let res = system(printf('%s -i %s', g:emmet_curl_command, shellescape(substitute(a:url, '#.*', '', ''))))
while res =~# '^HTTP/1.\d 3' || res =~# '^HTTP/1\.\d 200 Connection established' || res =~# '^HTTP/1\.\d 100 Continue'
let pos = stridx(res, "\r\n\r\n")
if pos != -1
let res = strpart(res, pos+4)
@@ -184,7 +184,7 @@ function! emmet#util#getContentFromURL(url)
return iconv(content, charset, &encoding)
endfunction
function! emmet#util#getTextFromHTML(buf)
function! emmet#util#getTextFromHTML(buf) abort
let threshold_len = 100
let threshold_per = 0.1
let buf = a:buf
@@ -202,7 +202,7 @@ function! emmet#util#getTextFromHTML(buf)
let str = substitute(str, '&gt;', '>', 'g')
let str = substitute(str, '&lt;', '<', 'g')
let str = substitute(str, '&quot;', '"', 'g')
let str = substitute(str, '&apos;', "'", 'g')
let str = substitute(str, '&apos;', '''', 'g')
let str = substitute(str, '&nbsp;', ' ', 'g')
let str = substitute(str, '&yen;', '\&#65509;', 'g')
let str = substitute(str, '&amp;', '\&', 'g')
@@ -221,7 +221,7 @@ function! emmet#util#getTextFromHTML(buf)
return res
endfunction
function! emmet#util#getImageSize(fn)
function! emmet#util#getImageSize(fn) abort
let fn = a:fn
if emmet#util#isImageMagickInstalled()
@@ -231,7 +231,7 @@ function! emmet#util#getImageSize(fn)
if filereadable(fn)
let hex = substitute(system('xxd -p "'.fn.'"'), '\n', '', 'g')
else
if fn !~ '^\w\+://'
if fn !~# '^\w\+://'
let path = fnamemodify(expand('%'), ':p:gs?\\?/?')
if has('win32') || has('win64') |
let path = tolower(path)
@@ -252,29 +252,29 @@ function! emmet#util#getImageSize(fn)
endif
let [width, height] = [-1, -1]
if hex =~ '^89504e470d0a1a0a'
if hex =~# '^89504e470d0a1a0a'
let width = eval('0x'.hex[32:39])
let height = eval('0x'.hex[40:47])
endif
if hex =~ '^ffd8'
if hex =~# '^ffd8'
let pos = 4
while pos < len(hex)
let bs = hex[pos+0:pos+3]
let pos += 4
if bs == 'ffc0' || bs == 'ffc2'
if bs ==# 'ffc0' || bs ==# 'ffc2'
let pos += 6
let height = eval('0x'.hex[pos+0:pos+1])*256 + eval('0x'.hex[pos+2:pos+3])
let pos += 4
let width = eval('0x'.hex[pos+0:pos+1])*256 + eval('0x'.hex[pos+2:pos+3])
break
elseif bs =~ 'ffd[9a]'
elseif bs =~# 'ffd[9a]'
break
elseif bs =~ 'ff\(e[0-9a-e]\|fe\|db\|dd\|c4\)'
elseif bs =~# 'ff\(e[0-9a-e]\|fe\|db\|dd\|c4\)'
let pos += (eval('0x'.hex[pos+0:pos+1])*256 + eval('0x'.hex[pos+2:pos+3])) * 2
endif
endwhile
endif
if hex =~ '^47494638'
if hex =~# '^47494638'
let width = eval('0x'.hex[14:15].hex[12:13])
let height = eval('0x'.hex[18:19].hex[16:17])
endif
@@ -282,7 +282,7 @@ function! emmet#util#getImageSize(fn)
return [width, height]
endfunction
function! emmet#util#imageSizeWithImageMagick(fn)
function! emmet#util#imageSizeWithImageMagick(fn) abort
let img_info = system('identify -format "%wx%h" "'.a:fn.'"')
let img_size = split(substitute(img_info, '\n', '', ''), 'x')
if len(img_size) != 2
@@ -291,14 +291,14 @@ function! emmet#util#imageSizeWithImageMagick(fn)
return img_size
endfunction
function! emmet#util#isImageMagickInstalled()
function! emmet#util#isImageMagickInstalled() abort
if !get(s:, 'emmet_use_identify', 1)
return 0
endif
return executable('identify')
endfunction
function! emmet#util#unique(arr)
function! emmet#util#unique(arr) abort
let m = {}
let r = []
for i in a:arr
@@ -311,39 +311,39 @@ function! emmet#util#unique(arr)
endfunction
let s:seed = localtime()
function! emmet#util#srand(seed)
function! emmet#util#srand(seed) abort
let s:seed = a:seed
endfunction
function! emmet#util#rand()
function! emmet#util#rand() abort
let s:seed = s:seed * 214013 + 2531011
return (s:seed < 0 ? s:seed - 0x80000000 : s:seed) / 0x10000 % 0x8000
endfunction
function! emmet#util#cache(name, ...)
let content = get(a:000, 0, "")
let dir = expand("~/.emmet/cache")
function! emmet#util#cache(name, ...) abort
let content = get(a:000, 0, '')
let dir = expand('~/.emmet/cache')
if !isdirectory(dir)
call mkdir(dir, "p", 0700)
call mkdir(dir, 'p', 0700)
endif
let file = dir . "/" . substitute(a:name, '\W', '_', 'g')
let file = dir . '/' . substitute(a:name, '\W', '_', 'g')
if len(content) == 0
if !filereadable(file)
return ""
return ''
endif
return join(readfile(file), "\n")
endif
call writefile(split(content, "\n"), file)
endfunction
function! emmet#util#getcurpos()
function! emmet#util#getcurpos() abort
let pos = getpos('.')
if mode(0) == 'i' && pos[2] > 0
if mode(0) ==# 'i' && pos[2] > 0
let pos[2] -=1
endif
return pos
endfunction
function! emmet#util#closePopup()
return pumvisible() ? "\<c-e>" : ""
function! emmet#util#closePopup() abort
return pumvisible() ? "\<c-e>" : ''
endfunction