Commits

ZyX_I committed 3b7416b

@aurum/edit: Added mrun resource
Added mgroup _f.newcommand key
@aurum/diff, @aurum/file: Made them use mgroup key
ftplugin/aurumannotate, ftplugin/aurumstatus:
Made them use _r.mrun resource. Ref #25

Comments (0)

Files changed (8)

 @aurum/edit:
     1.0: Removed setlines function (moved it to @aurum/repo).
     1.1: Added “requiresbvar” _f.newcommand option.
+    1.2: Added “mgroup” _f.newcommand option and mrun resource
 @aurum/vimdiff:
     0.1: Added full, untracked, onlymodified and files options to |:AuVimDiff|
     0.2: Added _r.vimdiff.full.

ftplugin/aurumannotate.vim

             \             '@aurum/bufvars': '0.0',
             \             '@aurum/vimdiff': '0.2',
             \            '@aurum/annotate': '0.0',
-            \                '@aurum/edit': '1.0',
+            \                '@aurum/edit': '1.2',
             \                 '@/mappings': '0.0',
             \                       '@/os': '0.0',})
 let s:_messages={
                     endif
                     execute 'silent edit' fnameescape(file1)
                 else
-                    let existed=s:_r.run('silent edit', 'file', bvar.repo, rev1,
-                                \                               file)
+                    let existed=s:_r.mrun('silent edit',
+                                \         'file', bvar.repo, rev1, file)
                 endif
                 if existed
                     setlocal bufhidden=wipe
             else
                 let dfile=file
             endif
-            let existed=s:_r.run('silent edit', 'diff', bvar.repo, rev1, rev2,
-                        \        ((a:0 && a:1)?([]):([dfile])), {})
+            let existed=s:_r.mrun('silent edit', 'diff', bvar.repo, rev1, rev2,
+                        \         ((a:0 && a:1)?([]):([dfile])), {})
         endif
     "▶2 `open' action
     elseif a:action is# 'open'
             let newbvar=s:_r.bufvars[abuf]
             execute abwnr.'wincmd w'
         endif
-        let existed=s:_r.run('silent edit', 'file', bvar.repo, hex, file)
+        let existed=s:_r.mrun('silent edit', 'file', bvar.repo, hex, file)
         if exists('lnr')
             execute lnr
         elseif exists('line')
             vertical resize 42
             wincmd p
         endif
-        let existed=s:_r.run('silent edit', 'file', bvar.repo, rev, bvar.file)
+        let existed=s:_r.mrun('silent edit', 'file', bvar.repo, rev, bvar.file)
         setlocal scrollbind
         call s:_r.annotate.setannbuf(newbvar, abuf, bufnr('%'))
     endif

ftplugin/aurumstatus.vim

 execute frawor#Setup('0.0', {'@aurum/bufvars': '0.0',
             \                '@aurum/vimdiff': '0.2',
             \               '@aurum/cmdutils': '0.0',
-            \                   '@aurum/edit': '1.0',
+            \                   '@aurum/edit': '1.2',
             \                 '@aurum/commit': '1.0',
             \                    '@/mappings': '0.0',
             \                          '@/os': '0.0',})
     if a:action is# 'open'
         execute 'silent e' fnameescape(s:_r.os.path.join(bvar.repo.path, file))
     elseif a:action is# 'revopen'
-        call s:_r.run('silent edit', 'file', bvar.repo, rev1, file)
+        call s:_r.mrun('silent edit', 'file', bvar.repo, rev1, file)
     elseif a:action is# 'fulldiff'
-        call s:_r.run('silent edit', 'diff', bvar.repo, rev1, rev2, [], {})
+        call s:_r.mrun('silent edit', 'diff', bvar.repo, rev1, rev2, [], {})
     elseif a:action is# 'revfulldiff'
-        call s:_r.run('silent edit', 'diff', bvar.repo, rev1,  '',  [], {})
+        call s:_r.mrun('silent edit', 'diff', bvar.repo, rev1,  '',  [], {})
     elseif a:action is# 'fullvimdiff'
         execute 'AuVimDiff full '.((empty(rev2) || empty(rev1))?
                     \                   ('curfile '):
         endif
         call s:_r.vimdiff.full(bvar.repo, [rev1, cs1.parents[0]], 1, [], 0)
     elseif !manyfiles && (a:action is# 'revvimdiff' || a:action is# 'vimdiff')
-        let file1=s:_r.fname('file', bvar.repo, rev1, file)
+        let fargs1=['file', bvar.repo, rev1, file]
         if a:action is# 'revvimdiff'
             let cs1=bvar.repo.functions.getcs(bvar.repo, rev1)
             if empty(cs1.parents)
                 call s:_f.throw('nopars', cs1.hex)
             endif
-            let file2=s:_r.fname('file', bvar.repo, cs1.parents[0], file)
+            let fargs2=['file', bvar.repo, cs1.parents[0], file]
         elseif empty(rev2)
             let file2=s:_r.os.path.join(bvar.repo.path, file)
         else
-            let file2=s:_r.fname('file', bvar.repo, rev2, file)
+            let fargs2=['file', bvar.repo, rev2, file]
         endif
         if get(bvar.opts, 'record', 0)
-            execute 'silent view' fnameescape(file2)
+            if exists('file2')
+                execute 'silent view' fnameescape(file2)
+            else
+                call call(s:_r.mrun, ['silent view']+fargs2, {})
+            endif
             diffthis
             execute rwnr.'wincmd w'
-            execute 'silent view' fnameescape(file1)
+            call call(s:_r.mrun, ['silent view']+fargs1, {})
             diffthis
             wincmd p
         else
-            execute 'silent edit' fnameescape(file2)
-            call s:_r.vimdiff.split(file1, -1)
+            if exists('file2')
+                execute 'silent edit' fnameescape(file2)
+            else
+                call call(s:_r.run, ['silent view']+fargs2, {})
+            endif
+            call s:_r.vimdiff.split(call(s:_r.fname, fargs1, {}), -1)
         endif
     elseif a:action is# 'annotate'
-        call s:_r.run('silent edit', 'file', bvar.repo, rev1, file)
+        call s:_r.mrun('silent edit', 'file', bvar.repo, rev1, file)
         AuAnnotate
     endif
     if visual
         call map(copy(files), 'bvar.repo.functions.forget(bvar.repo, v:val)')
         silent edit!
     elseif a:action is# 'diff'
-        call s:_r.run('silent edit', 'diff', bvar.repo, rev1,  '',  files, {})
+        call s:_r.mrun('silent edit', 'diff', bvar.repo, rev1,  '',  files, {})
     elseif a:action is# 'revdiff'
-        call s:_r.run('silent edit', 'diff', bvar.repo, rev1, rev2, files, {})
+        call s:_r.mrun('silent edit', 'diff', bvar.repo, rev1, rev2, files, {})
     elseif a:action is# 'revvimdiff' || a:action is# 'vimdiff'
         let args=[bvar.repo]
         if a:action is# 'revvimdiff'

plugin/aurum/diff.vim

                 \               '@aurum/lineutils': '0.0',
                 \                 '@aurum/vimdiff': '0.2',
                 \                    '@aurum/repo': '3.0',
-                \                    '@aurum/edit': '1.0',
+                \                    '@aurum/edit': '1.2',
                 \                           '@/os': '0.0',
                 \                          '@/fwc': '0.0',
                 \                     '@/mappings': '0.0',
     finish
 elseif s:_pluginloaded
     finish
+elseif !exists('s:_loading')
+    call FraworLoad(s:_frawor.id)
+    finish
 endif
 let s:_messages={
             \'nodfile': 'Failed to get file whose section is under the cursor',
             \ 'listargs': 1,
             \  'options': {'num': s:_r.repo.diffoptslst},
             \ 'filetype': 'diff',
+            \   'mgroup': 'AuDiff',
             \}
 function s:diff.function(read, repo, rev1, rev2, files, opts)
     "▶2 Get revisions

plugin/aurum/edit.vim

 "▶1
 scriptencoding utf-8
 if !exists('s:_pluginloaded')
-    execute frawor#Setup('1.1', {'@/autocommands': '0.0',
+    execute frawor#Setup('1.2', {'@/autocommands': '0.0',
                 \                   '@/functions': '0.0',
                 \                   '@/resources': '0.0',
                 \                   '@aurum/repo': '3.0',
             \'nstr': 'key “%s” is not a string',
             \ 'ift': 'invalid filetype: “%s” '.
             \        '(only lowercase latin letters allowed)',
+            \ 'img': 'invalid mgroup: “%s”',
             \ 'dup': 'string “%s” from key “%s” was already listed',
+            \'nmap': 'plugin dictionary does not contain '.
+            \        'g._f.mapgroup.map function',
         \}, '"Error while registering command %s for plugin %s: ".v:val'))
 "▶1 globtopat :: glob[, catchstars] → pattern
 function s:F.globtopat(glob, ...)
         endif
         let cdescr.filetype=a:cdescr.filetype
     endif
+    "▶2 “mgroup” key
+    if has_key(a:cdescr, 'mgroup')
+        if type(a:cdescr.mgroup)!=type('')
+            call s:_f.throw('nstr', cname, a:plugdict.id, 'mgroup')
+        elseif a:cdescr.mgroup!~#'\v^\u[a-zA-Z0-9]*$'
+            call s:_f.throw('img', cname, a:plugdict.id, a:cdescr.mgroup)
+        elseif !exists('*a:plugdict.g._f.mapgroup.map')
+            call s:_f.throw('nmap', cname, a:plugdict.id)
+        endif
+        let cdescr.mgroup=a:cdescr.mgroup
+        let cdescr.mmap=a:plugdict.g._f.mapgroup.map
+    endif
     "▶2 Function keys: `write'
     if has_key(a:cdescr, 'write')
         if !exists('*a:cdescr.write')
     endif
     return existed
 endfunction
+"▶1 mrun
+function s:F.mrun(...)
+    let r=call(s:F.run, a:000, {})
+    let cdescr=s:commands[a:2]
+    if has_key(cdescr, 'mgroup')
+        call cdescr.mmap(cdescr.mgroup, bufnr('%'))
+    endif
+    return r
+endfunction
 "▶1 Register resources
 call s:_f.postresource('run',       s:F.run)
+call s:_f.postresource('mrun',      s:F.mrun)
 call s:_f.postresource('fname',     s:F.fname)
 call s:_f.postresource('globtopat', s:F.globtopat)
 "▶1

plugin/aurum/file.vim

                 \               '@aurum/lineutils': '0.0',
                 \                 '@aurum/vimdiff': '0.0',
                 \                    '@aurum/repo': '3.0',
-                \                    '@aurum/edit': '1.0',
+                \                    '@aurum/edit': '1.2',
                 \                           '@/os': '0.0',
                 \                          '@/fwc': '0.0',
                 \                     '@/mappings': '0.0',
     endif
 endfunction
 "▶1 file resource
-let s:file={'arguments': 2, 'sourceable': 1}
+let s:file={'arguments': 2, 'sourceable': 1, 'mgroup': 'AuFile'}
 function s:file.function(read, repo, rev, file)
     let rev=a:repo.functions.getrevhex(a:repo, a:rev)
     call s:F.docmd(a:repo.functions.readfile(a:repo, rev, a:file), a:read)
                         \       '['.string(file).", 0], {})\n:wincmd p\n"
         endif
     elseif a:action is# 'diff' || a:action is# 'revdiff'
-        let opts='repo '.fnameescape(bvar.repo.path)
+        let opts='repo '.escape(bvar.repo.path, ' ')
         if a:action is# 'diff'
             let opts.=' rev2 '.bvar.rev
         else

plugin/aurum/log.vim

             \'procinput':   {'default': 1, 'checker': 'range 0 2'},
         \}
 let s:_messages={
-            \'2multl': 'Two multiline statements on one line',
-            \'argmis': 'Missing argument #%u for keyword %s',
             \  'ebuf': 'Switched to another buffer: exiting',
         \}
 " iterfuncs :: {fname: { "start": startfunc, "next": nextfunc }}

plugin/aurum/log/templates.vim

             \'2multl': 'Two multiline statements on one line',
             \'argmis': 'Missing argument #%u for keyword %s',
         \}
-" iterfuncs :: {fname: { "start": startfunc, "next": nextfunc }}
-" startfunc (always) :: repo, opts, * → d
-let s:iterfuncs={}
 "▶1 s:templates
 let s:templates={
             \'default': "Changeset $rev#suf:\:#$hex$branch#hide,pref: (branch ,suf:)#\n".
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.