Commits

ZyX_I committed aabf1d8

@aurum/repo: Moved setlines and some other functions to @aurum/lineutils

Comments (0)

Files changed (19)

autoload/aurum.vim

 "▶1 
-execute frawor#Setup('0.0', {'@aurum/repo': '2.0',
+execute frawor#Setup('0.0', {'@aurum/repo': '3.0',
             \               '@aurum/cache': '0.0',})
 "▶1 aurum#repository
 function aurum#repository()
     2.3: Added |aurum-rf-getroot| support.
     2.4: Added {requiresclean} argument to |aurum-rf-status|.
     2.5: Added parsecmdarg and crnl resources
+    3.0: Moved setlines and some other functions to @aurum/lineutils
 @aurum:
     0.1: Added :AuBranch and :AuName.
 @aurum/edit:

ftplugin/aurumannotate.vim

 endif
 setlocal noswapfile
 setlocal nomodeline
-execute frawor#Setup('0.0', {'@aurum/repo': '2.0',
+execute frawor#Setup('0.0', {'@aurum/repo': '3.0',
             \             '@aurum/bufvars': '0.0',
             \             '@aurum/vimdiff': '0.2',
             \            '@aurum/annotate': '0.0',

ftplugin/aurumlog.vim

 setlocal nomodeline
 execute frawor#Setup('0.0', {'@aurum/cmdutils': '0.0',
             \                 '@aurum/bufvars': '0.0',
-            \                    '@aurum/repo': '2.0',
+            \                    '@aurum/repo': '3.0',
             \                    '@aurum/edit': '1.0',
             \                           '@/os': '0.0',
             \                     '@/mappings': '0.0',})

macros/reload-aurum.vim

 for s:plug in ['@aurum/repo',
             \  '@aurum/bufvars',
+            \  '@aurum/lineutils',
             \  '@aurum/cache',
             \  '@aurum/drivers/common/xml',
             \  '@aurum/drivers/common/utils',
                 \                      '@/os': '0.1',
                 \           '@aurum/cmdutils': '0.0',
                 \                     '@/fwc': '0.2',
-                \               '@aurum/repo': '2.0',
+                \               '@aurum/repo': '3.0',
                 \               '@aurum/edit': '1.0',
                 \            '@aurum/bufvars': '0.0',}, 0)
     "▶2 Команды

plugin/aurum/cmdutils.vim

 if !exists('s:_pluginloaded')
     execute frawor#Setup('0.0', {'@/resources': '0.0',
                 \                       '@/os': '0.0',
-                \                '@aurum/repo': '2.0',
+                \                '@aurum/repo': '3.0',
                 \                '@aurum/edit': '1.0',
                 \               '@aurum/cache': '0.0',
                 \             '@aurum/bufvars': '0.0',}, 0)

plugin/aurum/commit.vim

                 \              '@aurum/status': '1.0',
                 \            '@aurum/cmdutils': '0.0',
                 \             '@aurum/bufvars': '0.0',
-                \                '@aurum/repo': '2.0',
+                \                '@aurum/repo': '3.0',
                 \                '@aurum/edit': '1.0',
                 \                      '@/fwc': '0.3',
                 \                 '@/commands': '0.0',

plugin/aurum/diff.vim

 if !exists('s:_pluginloaded')
     execute frawor#Setup('0.0', {'@aurum/cmdutils': '0.0',
                 \                 '@aurum/bufvars': '0.0',
+                \               '@aurum/lineutils': '0.0',
                 \                 '@aurum/vimdiff': '0.2',
-                \                    '@aurum/repo': '2.0',
+                \                    '@aurum/repo': '3.0',
                 \                    '@aurum/edit': '1.0',
                 \                           '@/os': '0.0',
                 \                          '@/fwc': '0.0',
     endif
     "▲2
     if a:read
-        call s:_r.setlines(a:repo.functions.diff(a:repo, rev1, rev2, a:files,
-                    \                            a:opts), 1)
+        call s:_r.lineutils.setlines(
+                    \a:repo.functions.diff(a:repo, rev1, rev2, a:files, a:opts),
+                    \1)
         return {}
     else
         call a:repo.functions.difftobuffer(a:repo, bufnr('%'), rev1, rev2,

plugin/aurum/drivers/git.vim

 "▶1
 scriptencoding utf-8
 if !exists('s:_pluginloaded')
-    execute frawor#Setup('0.1', {   '@aurum/repo': '2.0',
+    execute frawor#Setup('0.1', {   '@aurum/repo': '3.0',
                 \                          '@/os': '0.1',
                 \   '@aurum/drivers/common/utils': '0.0',
                 \'@aurum/drivers/common/hypsites': '0.0',}, 0)

plugin/aurum/drivers/mercurial.vim

 scriptencoding utf-8
 if !exists('s:_pluginloaded')
     execute frawor#Setup('0.2', {      '@/python': '0.0',
-                \                   '@aurum/repo': '2.0',
+                \                   '@aurum/repo': '3.0',
                 \                          '@/os': '0.0',
                 \                     '@/options': '0.0',
                 \   '@aurum/drivers/common/utils': '0.0',

plugin/aurum/drivers/subversion.vim

 "▶1
 scriptencoding utf-8
 if !exists('s:_pluginloaded')
-    execute frawor#Setup('0.1', {   '@aurum/repo': '2.3',
+    execute frawor#Setup('0.1', {   '@aurum/repo': '3.0',
                 \                          '@/os': '0.0',
                 \   '@aurum/drivers/common/utils': '0.0',
                 \     '@aurum/drivers/common/xml': '0.0',

plugin/aurum/edit.vim

     execute frawor#Setup('1.1', {'@/autocommands': '0.0',
                 \                   '@/functions': '0.0',
                 \                   '@/resources': '0.0',
-                \                   '@aurum/repo': '2.5',
+                \                   '@aurum/repo': '3.0',
+                \              '@aurum/lineutils': '0.0',
                 \                '@aurum/bufvars': '0.0',}, 0)
     call FraworLoad('@/autocommands')
     call FraworLoad('@/functions')
 endfunction
 "▶1 copy
 function s:F.copy(read, file)
-    call s:_r.setlines(readfile(a:file, 'b'), a:read)
+    call s:_r.lineutils.setlines(readfile(a:file, 'b'), a:read)
     if !a:read
         let s:_r.bufvars[bufnr('%')]={'file': a:file, 'command': 'copy'}
         if exists('#filetypedetect#BufRead')
         endif
     endif
 endfunction
-"▶1 getopts :: Bool → Dictionary
-function s:F.getopts()
-    let r=s:_r.parsecmdarg()
-    if !has_key(r, 'b')
-        let r.b=&binary
-    endif
-    if !has_key(r, 'e') && !empty(&fileencoding)
-        let r.e=&fileencoding
-    endif
-    if has_key(r, 'e') && r.e is# &encoding
-        unlet r.e
-    endif
-    if !has_key(r, 'f')
-        let r.f=&fileformat
-    endif
-    return r
-endfunction
-"▶1 wtransform :: [String] → [String] +? [String]
-function s:F.wtransform(lines)
-    let r=a:lines
-    let a=s:F.getopts()
-    if a.b
-        if &endofline
-            call add(r, '')
-        endif
-    else
-        call add(r, '')
-        if a.f is# 'dos'
-            call map(r, 'v:val."\n"')
-        elseif a.f is# 'mac'
-            let r=s:_r.crnl(r)
-        endif
-    endif
-    if has_key(a, 'e')
-        call map(r, 'iconv(v:val, "'.&encoding.'","'.(a.e).'")')
-    endif
-    return r
-endfunction
 "▶1 edit
 function s:F.edit(rw, file)
     if a:rw>=0
             let s:_r.bufvars[bufnr('%')]={'file': a:file, 'command': 'edit'}
         endif
     elseif a:rw==-1
-        call writefile(s:F.wtransform(getline(1, '$')), a:file, 'b')
+        call writefile(s:_r.lineutils.wtransform(getline(1, '$')), a:file, 'b')
         setlocal nomodified
     endif
 endfunction
     endif
     if a:rw<0
         call call(cdescr.write,
-                    \[s:F.wtransform(call('getline', ((a:rw==-1)?
-                    \                                   ([ 1,   '$' ]):
-                    \                                   (["'[", "']"]))))]+
+                    \[s:_r.lineutils.wtransform(
+                    \            call('getline', ((a:rw==-1)?([ 1,   '$' ]):
+                    \                                        (["'[", "']"]))))]+
                     \args, {})
     else
         let args=[a:rw]+args

plugin/aurum/file.vim

 if !exists('s:_pluginloaded')
     execute frawor#Setup('0.0', {'@aurum/cmdutils': '0.0',
                 \                 '@aurum/bufvars': '0.0',
+                \               '@aurum/lineutils': '0.0',
                 \                 '@aurum/vimdiff': '0.0',
-                \                    '@aurum/repo': '2.0',
+                \                    '@aurum/repo': '3.0',
                 \                    '@aurum/edit': '1.0',
                 \                           '@/os': '0.0',
                 \                          '@/fwc': '0.0',
         let rev=repo.functions.getrevhex(repo, a:rev)
     endif
     if get(a:opts, 'replace', 0)
-        call s:_r.setlines(repo.functions.readfile(repo, rev, file), 0)
+        call s:_r.lineutils.setlines(repo.functions.readfile(repo, rev, file),0)
         return
     endif
     if hasbuf
 "▶1 docmd :: [String], read::0|1|2 → _ + ?
 function s:F.docmd(lines, read)
     if a:read==0 || a:read==1
-        return s:_r.setlines(a:lines, a:read)
+        return s:_r.lineutils.setlines(a:lines, a:read)
     elseif a:read==2
         let tmpname=tempname()
         if writefile(a:lines, tmpname, 'b')==-1

plugin/aurum/lineutils.vim

+"▶1
+scriptencoding utf-8
+if !exists('s:_pluginloaded')
+    execute frawor#Setup('0.0', {'@/resources': '0.0',}, 0)
+    finish
+elseif s:_pluginloaded
+    finish
+endif
+let s:resource={}
+"▶1 crnl :: [String] → [String]
+function s:F.crnl(text)
+    let r=['']
+    for crsplit in map(copy(a:text), 'split(v:val, "\r", 1)')
+        let r[-1].="\r".crsplit[0]
+        call extend(r, crsplit[1:])
+    endfor
+    if empty(r[0])
+        call remove(r, 0)
+    else
+        let r[0]=r[0][1:]
+    endif
+    return r
+endfunction
+"▶1 parsecmdarg :: + v:cmdarg + opts → Dictionary
+function s:F.parsecmdarg()
+    let r={}
+    for arg in filter(split(v:cmdarg),
+                \     'v:val =~# ''\V\^++\v%(%(enc|ff)\=|%(no)bin)''')
+        let idx=stridx(arg, '=')
+        let r[arg[2]]=arg[(idx+1):]
+    endfor
+    if has_key(r, 'b')
+        let r.b=1
+    elseif has_key(r, 'n')
+        let r.b=0
+        unlet r.n
+    endif
+    return r
+endfunction
+"▶1 getopts :: Bool → Dictionary
+function s:F.getopts()
+    let r=s:F.parsecmdarg()
+    if !has_key(r, 'b')
+        let r.b=&binary
+    endif
+    if !has_key(r, 'e') && !empty(&fileencoding)
+        let r.e=&fileencoding
+    endif
+    if has_key(r, 'e') && r.e is# &encoding
+        unlet r.e
+    endif
+    if !has_key(r, 'f')
+        let r.f=&fileformat
+    endif
+    return r
+endfunction
+"▶1 setlines :: [String], read::Bool → + buffer
+function s:resource.setlines(lines, read)
+    let lines=a:lines
+    if !empty(v:cmdarg)
+        let a=s:F.parsecmdarg()
+        if has_key(a, 'f') && !(has_key(a, 'b') && a.b) && !&binary
+            if a.f is# 'dos'
+                let lines=map(copy(lines), 'v:val[-1:] is# "\r" ? '.
+                            \                   'v:val[:-2] : '.
+                            \                   'v:val')
+            elseif a.f is# 'mac'
+                let lines=s:F.crnl(lines)
+            endif
+            if !a:read
+                let &l:fileformat=a.f
+            endif
+        endif
+        if has_key(a, 'e')
+            let lines=map(copy(lines), 'iconv(v:val, "'.(a.e).'", "'.&enc.'")')
+            if !a:read
+                let &l:fileencoding=a.e
+            endif
+        endif
+        if !a:read && has_key(a, 'b')
+            let &l:binary=a.b
+        endif
+    endif
+    let d={'set': function((a:read)?('append'):('setline'))}
+    if len(lines)>1 && empty(lines[-1])
+        call d.set('.', lines[:-2])
+    else
+        if !a:read
+            setlocal binary noendofline
+        endif
+        call d.set('.', lines)
+    endif
+endfunction
+"▶1 wtransform :: [String] → [String] +? [String]
+function s:resource.wtransform(lines)
+    let r=a:lines
+    let a=s:F.getopts()
+    if a.b
+        if &endofline
+            call add(r, '')
+        endif
+    else
+        call add(r, '')
+        if a.f is# 'dos'
+            call map(r, 'v:val."\n"')
+        elseif a.f is# 'mac'
+            let r=s:F.crnl(r)
+        endif
+    endif
+    if has_key(a, 'e')
+        call map(r, 'iconv(v:val, "'.&encoding.'","'.(a.e).'")')
+    endif
+    return r
+endfunction
+"▶1 Post resource
+call s:_f.postresource('lineutils', s:resource)
+"▶1
+call frawor#Lockvar(s:, '')
+" vim: ft=vim ts=4 sts=4 et fmr=▶,▲

plugin/aurum/log.vim

 if !exists('s:_pluginloaded')
     execute frawor#Setup('0.3', {'@/table': '0.1',
                 \        '@aurum/cmdutils': '0.0',
+                \       '@aurum/lineutils': '0.0',
                 \         '@aurum/bufvars': '0.0',
                 \            '@aurum/edit': '1.1',
                 \                  '@/fwc': '0.3',
-                \            '@aurum/repo': '2.2',
+                \            '@aurum/repo': '3.0',
                 \             '@/commands': '0.0',
                 \            '@/functions': '0.0',
                 \              '@/options': '0.0',}, 0)
     let bvar.cw=s:_f.getoption('closewindow')
     let text=s:F.glog.graphlog(a:repo, opts, csiterfuncs, bvar, a:read)
     if a:read
-        call s:_r.setlines(text, a:read)
+        call s:_r.lineutils.setlines(text, a:read)
     elseif bufnr('%')==buf
         setlocal readonly nomodifiable
     endif

plugin/aurum/record.vim

                 \                   '@/functions': '0.0',
                 \                 '@aurum/commit': '1.0',
                 \               '@aurum/cmdutils': '0.0',
-                \                   '@aurum/repo': '2.0',
+                \              '@aurum/lineutils': '0.0',
+                \                   '@aurum/repo': '3.0',
                 \                   '@aurum/edit': '1.0',
                 \                     '@/options': '0.0',}, 0)
     call FraworLoad('@/commands')
                 let diff=&diff
                 if exists('fcontents')
                     silent %delete _
-                    call s:_r.setlines(fcontents, 0)
+                    call s:_r.lineutils.setlines(fcontents, 0)
                     if diff
                         diffupdate
                     endif

plugin/aurum/repo.vim

 "▶1
 scriptencoding utf-8
 if !exists('s:_pluginloaded')
-    execute frawor#Setup('2.5', {'@/resources': '0.0',
+    execute frawor#Setup('3.0', {'@/resources': '0.0',
                 \                       '@/os': '0.0',
                 \                  '@/options': '0.0',
+                \           '@aurum/lineutils': '0.0',
                 \             '@aurum/bufvars': '0.0',}, 0)
     finish
 elseif s:_pluginloaded
 endfunction
 "▶2 changesets
 let s:iterfuncs.changesets=s:iterfuncs.revrange
-"▶1 crnl :: [String] → [String]
-function s:F.crnl(text)
-    let r=['']
-    for crsplit in map(copy(a:text), 'split(v:val, "\r", 1)')
-        let r[-1].="\r".crsplit[0]
-        call extend(r, crsplit[1:])
-    endfor
-    if empty(r[0])
-        call remove(r, 0)
-    else
-        let r[0]=r[0][1:]
-    endif
-    return r
-endfunction
-"▶1 parsecmdarg :: + v:cmdarg + opts → Dictionary
-function s:F.parsecmdarg()
-    let r={}
-    for arg in filter(split(v:cmdarg),
-                \     'v:val =~# ''\V\^++\v%(%(enc|ff)\=|%(no)bin)''')
-        let idx=stridx(arg, '=')
-        let r[arg[2]]=arg[(idx+1):]
-    endfor
-    if has_key(r, 'b')
-        let r.b=1
-    elseif has_key(r, 'n')
-        let r.b=0
-        unlet r.n
-    endif
-    return r
-endfunction
-"▶1 setlines :: [String], read::Bool → + buffer
-function s:F.setlines(lines, read)
-    let lines=a:lines
-    if !empty(v:cmdarg)
-        let a=s:F.parsecmdarg()
-        if has_key(a, 'f') && !(has_key(a, 'b') && a.b) && !&binary
-            if a.f is# 'dos'
-                let lines=map(copy(lines), 'v:val[-1:] is# "\r" ? '.
-                            \                   'v:val[:-2] : '.
-                            \                   'v:val')
-            elseif a.f is# 'mac'
-                let lines=s:F.crnl(lines)
-            endif
-            if !a:read
-                let &l:fileformat=a.f
-            endif
-        endif
-        if has_key(a, 'e')
-            let lines=map(copy(lines), 'iconv(v:val, "'.(a.e).'", "'.&enc.'")')
-            if !a:read
-                let &l:fileencoding=a.e
-            endif
-        endif
-        if !a:read && has_key(a, 'b')
-            let &l:binary=a.b
-        endif
-    endif
-    let d={'set': function((a:read)?('append'):('setline'))}
-    if len(lines)>1 && empty(lines[-1])
-        call d.set('.', lines[:-2])
-    else
-        if !a:read
-            setlocal binary noendofline
-        endif
-        call d.set('.', lines)
-    endif
-endfunction
 "▶1 dirty :: repo, file → Bool
 function s:deffuncs.dirty(repo, file)
     let status=a:repo.functions.status(a:repo, 0, 0, [a:file])
     if oldbuf!=a:buf
         execute 'buffer' a:buf
     endif
-    call s:F.setlines(diff, 0)
+    call s:_r.lineutils.setlines(diff, 0)
     if oldbuf!=a:buf
         execute 'buffer' oldbuf
     endif
             \                'update': s:F.update,
             \           'diffoptslst': s:diffoptslst,
             \           'diffoptsstr': s:diffoptsstr,})
-call s:_f.postresource('crnl',        s:F.crnl)
-call s:_f.postresource('parsecmdarg', s:F.parsecmdarg)
-call s:_f.postresource('setlines',    s:F.setlines)
 "▶1 regdriver feature
 let s:requiredfuncs=['repo', 'getcs', 'checkdir']
 let s:optfuncs=['readfile', 'annotate', 'diff', 'status', 'commit', 'update',

plugin/aurum/status.vim

     execute frawor#Setup('1.1', {'@/resources': '0.0',
                 \            '@aurum/cmdutils': '0.0',
                 \                      '@/fwc': '0.2',
-                \                '@aurum/repo': '2.4',
+                \                '@aurum/repo': '3.0',
                 \                '@aurum/edit': '1.0',
                 \                 '@/commands': '0.0',
                 \                  '@/options': '0.0',