From: Iain Patterson Date: Fri, 12 Feb 2016 14:04:23 +0000 (+0000) Subject: Updated characterize plugin. X-Git-Url: http://git.iain.cx/?a=commitdiff_plain;h=28e8850aa8a696af1c23aa335fc84c08dd01a1ec;p=profile.git Updated characterize plugin. --- diff --git a/.vim/autoload/characterize.vim b/.vim/autoload/characterize.vim index 68b419c..1c05374 100644 --- a/.vim/autoload/characterize.vim +++ b/.vim/autoload/characterize.vim @@ -1,6 +1,8 @@ " autoload/characterize.vim " Maintainer: Tim Pope +unlet! s:digraphs + if exists("g:autoloaded_characterize") || &cp finish endif @@ -9,24 +11,26 @@ let g:autoloaded_characterize = 1 scriptencoding utf-8 function! characterize#digraphs(...) abort - redir => out - silent digraphs - redir END - redraw - let digraphs = {} - for line in split(out, '\n') - for entry in split(line, " \\d\\+\\zs\\s\\+") - let nr = matchstr(entry, '\d\+$') - if nr ==# '10' && len(digraphs) <= 1 - let nr = 0 - endif - if !has_key(digraphs, nr) - let digraphs[nr] = [] - endif - let digraphs[nr] += [matchstr(entry, '^..')] + if !exists('s:digraphs') + redir => out + silent digraphs + redir END + redraw + let s:digraphs = {} + for line in split(out, '\n') + for entry in split(line, " \\d\\+\\zs\\s*") + let nr = matchstr(entry, '\d\+$') + if nr ==# '10' && len(s:digraphs) <= 1 + let nr = 0 + endif + if !has_key(s:digraphs, nr) + let s:digraphs[nr] = [] + endif + let s:digraphs[nr] += [matchstr(entry, '^..')] + endfor endfor - endfor - return a:0 ? get(digraphs, a:1, []) : digraphs + endif + return a:0 ? get(s:digraphs, a:1, []) : s:digraphs endfunction function! characterize#html_entity(nr) abort diff --git a/.vim/plugin/characterize.vim b/.vim/plugin/characterize.vim index 207ca7e..9b24a21 100644 --- a/.vim/plugin/characterize.vim +++ b/.vim/plugin/characterize.vim @@ -11,27 +11,36 @@ function! s:info(char) if empty(a:char) return 'NUL' endif - let nr = a:char ==# "\n" ? 0 : char2nr(a:char) - let char = nr < 32 ? '^'.nr2char(64 + nr) : a:char - let out = '<' . char . '> ' . nr - if nr < 256 - let out .= printf(', \%03o', nr) - endif - let out .= printf(', U+%04X', nr) - let out .= ' '.characterize#description(nr, '') - for digraph in characterize#digraphs(nr) - let out .= ", \".digraph - endfor - for emoji in characterize#emojis(nr) - let out .= ', '.emoji - endfor - let entity = characterize#html_entity(nr) - if !empty(entity) - let out .= ', '.entity - endif - return out + let charseq = a:char + let outs = [] + while !empty(charseq) + let nr = charseq ==# "\n" ? 0 : char2nr(charseq) + let char = nr < 32 ? '^'.nr2char(64 + nr) : nr2char(nr) + let charseq = strpart(charseq, nr ? len(nr2char(nr)) : 1) + let out = '<' . (empty(outs) ? '' : ' ') . char . '> ' . nr + if nr < 256 + let out .= printf(', \%03o', nr) + endif + let out .= printf(', U+%04X', nr) + let out .= ' '.characterize#description(nr, '') + for digraph in characterize#digraphs(nr) + let out .= ", \".digraph + endfor + for emoji in characterize#emojis(nr) + let out .= ', '.emoji + endfor + let entity = characterize#html_entity(nr) + if !empty(entity) + let out .= ', '.entity + endif + call add(outs, out) + endwhile + return join(outs, ' ') endfunction -nmap