Commits

ZyX_I committed 9267d05

ftplugin/aurumlog: Made it use _r.mrun. Fixes #25

Comments (0)

Files changed (2)

ftplugin/aurumlog.vim

             \                    '@aurum/repo': '3.0',
             \                    '@aurum/edit': '1.0',
             \                           '@/os': '0.0',
+            \                 '@aurum/vimdiff': '0.0',
             \                     '@/mappings': '0.0',})
 let s:_messages={
             \'nocontents': 'Log is empty',
 "▶1 cwin
 function s:F.cwin(bvar)
     if a:bvar.cw
-        if winnr('$')==1
-            return ''
-        else
-            return ":wincmd c\n"
+        if winnr('$')!=1
+            close
         endif
     else
-        return ":new\n"
+        new
     endif
 endfunction
 "▶1 cr
     "▶2 Commit actions based on current special
     "▶3 branch: add `branch' filter
     if spname is# 'branch'
-        let cmd='edit '.fnameescape(s:_r.fname('log', bvar.repo,
-                    \                          extend(copy(opts),
-                    \                                 {'branch': cs.branch,
-                    \                              'crrestrict': 'branch'})))
+        let cargs=[s:_r.run, ['silent edit', 'log',
+                    \         bvar.repo, extend(copy(opts),
+                    \                           {    'branch': cs.branch,
+                    \                            'crrestrict': 'branch' })]]
     "▶3 user: add `user' filter
     elseif spname is# 'user'
-        let cmd='edit '.fnameescape(s:_r.fname('log', bvar.repo,
-                    \                          extend(copy(opts),
-                    \                        {'user': '\V'.escape(cs.user, '\'),
-                    \                   'crrestrict': 'user'})))
+        let cargs=[s:_r.run, ['silent edit', 'log',
+                    \         bvar.repo,
+                    \         extend(copy(opts),
+                    \                {      'user': '\V'.escape(cs.user, '\'),
+                    \                 'crrestrict': 'user' })]]
     "▶3 time: add `date' filter (only show commits done in the current month)
     elseif spname is# 'time'
-        let cmd='edit '.fnameescape(s:_r.fname('log', bvar.repo,
-                    \                extend(copy(opts),
-                    \                       {'date': strftime('%Y-%m', cs.time),
-                    \                  'crrestrict': 'date'})))
+        let cargs=[s:_r.run, ['silent edit', 'log',
+                    \         bvar.repo,
+                    \         extend(copy(opts),
+                    \                {      'date': strftime('%Y-%m', cs.time),
+                    \                 'crrestrict': 'date' })]]
     "▶3 changeset: show only ancestors of the current changeset
     elseif spname is# 'hex' || spname is# 'rev'
-        let cmd='edit '.fnameescape(s:_r.fname('log', bvar.repo,
-                    \                         extend(copy(opts),
-                    \                                {'revision': hex,
-                    \                               'crrestrict': 'revision'})))
+        let cargs=[s:_r.run, ['silent edit', 'log',
+                    \         bvar.repo,
+                    \         extend(copy(opts),
+                    \                {  'revision': hex,
+                    \                 'crrestrict': 'revision' })]]
     "▶3 file: view file
     elseif spname=~#'\v^file\d+$'
         " XXX If fileN special exists, then files property was definitely added, 
         " so no need to use getcsprop()
         let file=cs.files[str2nr(spname[4:])]
-        let cmd='edit '.fnameescape(s:_r.fname('file', bvar.repo, hex, file))
+        let cargs=[s:_r.mrun, ['silent edit', 'file', bvar.repo, hex, file]]
     "▶3 view diff between changeset and current state or its parent
     else
-        let args=['diff', bvar.repo]
+        let args=['silent edit', 'diff', bvar.repo]
         if spname is# 'curdiff'
             let args+=['', hex]
         else
         endif
         if has_key(bvar.opts, 'files') && !has_key(bvar.opts.ignorefiles,'diff')
             let args+=[bvar.opts.csfiles[hex]]
+        else
+            let args+=[[]]
         endif
-        let cmd='edit '.fnameescape(call(s:_r.fname, args, {}))
+        let args+=[{}]
+        let cargs=[s:_r.mrun, args]
     endif
     "▲3
-    return s:F.cwin(bvar).":silent ".cmd."\n"
+    call s:F.cwin(bvar)
+    return call('call', cargs+[{}])
 endfunction
 "▶1 fvdiff
 function s:F.fvdiff(...)
 function s:F.open()
     let [hex, file]=s:F.gethexfile()
     if file is 0
-        return ''
+        return 0
     endif
     let bvar=s:_r.bufvars[bufnr('%')]
-    return s:F.cwin(bvar).":silent edit ".
-                \fnameescape(s:_r.fname('file', bvar.repo, hex, file))."\n"
+    call s:F.cwin(bvar)
+    call s:_r.mrun('silent edit', 'file', bvar.repo, hex, file)
+    return 1
 endfunction
 "▶1 annotate
 function s:F.annotate()
-    let r=s:F.open()
-    if empty(r)
-        return r
-    else
-        return r.":AuAnnotate\n"
+    if s:F.open()
+        AuAnnotate
     endif
 endfunction
 "▶1 diff
         return ''
     endif
     let bvar=s:_r.bufvars[bufnr('%')]
+    call s:F.cwin(bvar)
     if a:0 && a:1
-        return s:F.cwin(bvar).":silent edit ".
-                    \fnameescape(s:_r.fname('diff', bvar.repo, hex, '', file)).
-                    \"\n"
+        call s:_r.mrun('silent edit', 'diff', bvar.repo, hex, '', [file], {})
     else
-        return s:F.cwin(bvar).":silent edit ".
-                    \fnameescape(s:_r.fname('diff', bvar.repo, '', hex, file)).
-                    \"\n"
+        call s:_r.mrun('silent edit', 'diff', bvar.repo, '', hex, [file], {})
     endif
 endfunction
 "▶1 vimdiff
 function s:F.vimdiff(...)
     let [hex, file]=s:F.gethexfile()
     if file is 0
-        return ''
+        return
     endif
     let bvar=s:_r.bufvars[bufnr('%')]
     let cs=bvar.repo.changesets[hex]
+    call s:F.cwin(bvar)
     if a:0 && a:1
-        return s:F.cwin(bvar).":silent edit ".
-                    \fnameescape(s:_r.os.path.join(bvar.repo.path, file))."\n".
-                    \':silent diffsplit '.
-                    \fnameescape(s:_r.fname('file', bvar.repo, hex, file))."\n"
+        execute 'silent edit'
+                    \ fnameescape(s:_r.os.path.join(bvar.repo.path, file))
+        call s:_r.vimdiff.split(s:_r.fname('file', bvar.repo, hex, file), 0)
     elseif !empty(cs.parents)
-        return s:F.cwin(bvar).":silent edit ".
-                    \fnameescape(s:_r.fname('file', bvar.repo, hex, file))."\n".
-                    \':silent diffsplit '.
-                    \fnameescape(s:_r.fname('file', bvar.repo, cs.parents[0],
-                    \                       file))."\n"
+        call s:_r.run('silent edit', 'file', bvar.repo, hex, file)
+        call s:_r.vimdiff.split(s:_r.fname('file', bvar.repo, cs.parents[0],
+                    \                      file), 0)
     else
         call s:_f.throw('nopars', hex)
     endif
     return "\<C-\>\<C-n>:silent edit\n"
 endfunction
 "▶1 AuLog mapping group
+function s:m(f, ...)
+    return ':<C-u>call <SNR>'.s:_sid.'_Eval(''s:F.'.a:f.
+                \                   '('.string(string(a:000))[2:-3].')'')<CR>'
+endfunction
 call s:_f.mapgroup.add('AuLog', {
-            \   'Enter': {'lhs': "\n", 'rhs': [],                             },
+            \   'Enter': {'lhs': "\n", 'rhs': s:m('cr'),                      },
             \    'File': {'lhs': 'gF', 'rhs': s:F.filehistory                 },
-            \    'User': {'lhs': 'gu', 'rhs': ['user']                        },
-            \    'Date': {'lhs': 'gM', 'rhs': ['time']                        },
-            \  'Branch': {'lhs': 'gb', 'rhs': ['branch']                      },
-            \     'Rev': {'lhs': 'gr', 'rhs': ['rev']                         },
+            \    'User': {'lhs': 'gu', 'rhs': s:m('cr', 'user')               },
+            \    'Date': {'lhs': 'gM', 'rhs': s:m('cr', 'time')               },
+            \  'Branch': {'lhs': 'gb', 'rhs': s:m('cr', 'branch')             },
+            \     'Rev': {'lhs': 'gr', 'rhs': s:m('cr', 'rev')                },
             \  'FVdiff': {'lhs': 'gD', 'rhs': s:F.fvdiff                      },
             \ 'RFVdiff': {'lhs': 'gC', 'rhs': [1],         'func': s:F.fvdiff },
-            \   'Fdiff': {'lhs': 'gd', 'rhs': ['curdiff']                     },
-            \  'RFdiff': {'lhs': 'gc', 'rhs': ['revdiff']                     },
-            \    'Diff': {'lhs':  'd', 'rhs': [1],         'func': s:F.diff   },
-            \   'Rdiff': {'lhs':  'c', 'rhs': s:F.diff                        },
-            \   'Vdiff': {'lhs':  'D', 'rhs': [1],         'func': s:F.vimdiff},
-            \  'RVdiff': {'lhs':  'C', 'rhs': s:F.vimdiff                     },
+            \   'Fdiff': {'lhs': 'gd', 'rhs': s:m('cr', 'curdiff')            },
+            \  'RFdiff': {'lhs': 'gc', 'rhs': s:m('cr', 'revdiff')            },
+            \    'Diff': {'lhs':  'd', 'rhs': s:m('diff', 1)                  },
+            \   'Rdiff': {'lhs':  'c', 'rhs': s:m('diff')                     },
+            \   'Vdiff': {'lhs':  'D', 'rhs': s:m('vimdiff', 1)               },
+            \  'RVdiff': {'lhs':  'C', 'rhs': s:m('vimdiff')                  },
             \    'Next': {'lhs':  'K', 'rhs': s:F.next                        },
             \    'Prev': {'lhs':  'J', 'rhs': s:F.prev                        },
-            \    'Open': {'lhs':  'o', 'rhs': s:F.open                        },
-            \'Annotate': {'lhs':  'a', 'rhs': s:F.annotate                    },
+            \    'Open': {'lhs':  'o', 'rhs': s:m('open')                     },
+            \'Annotate': {'lhs':  'a', 'rhs': s:m('annotate')                 },
             \  'Update': {'lhs':  'U', 'rhs': s:F.update                      },
             \    'Exit': {'lhs':  'X', 'rhs': ':<C-u>bwipeout<CR>'            },
             \}, {'func': s:F.cr, 'silent': 1, 'mode': 'n'})
+delfunction s:m
 "▶1
 call frawor#Lockvar(s:, '_r')
 " vim: ft=vim ts=4 sts=4 et fmr=▶,▲
 {{{1 <CR>
-aurum://diff:%ETMPDIR%%-test%-maps-logrepo:504f74154456dbb0e9441326514e42ce66279e62:
+aurum://diff:%ETMPDIR%%-test%-maps-logrepo:504f74154456dbb0e9441326514e42ce66279e62:::
 {{{1 branch <CR>
 aurum://log:%ETMPDIR%%-test%-maps-logrepo:crrestrict:branch,branch:A,
 {{{1 user <CR>
 *2*1: aurum://file:%ETMPDIR%%-test%-maps-logrepo:dfe39aa48c6ddde158e42217548b531a45ff66e9:crepo.zsh
 *2#2: aurum://file:%ETMPDIR%%-test%-maps-logrepo:5a6a1bf999fad1f4547eeb887af54f31d11833f2:crepo.zsh
 {{{1 gd
-aurum://diff:%ETMPDIR%%-test%-maps-logrepo::dfe39aa48c6ddde158e42217548b531a45ff66e9
+aurum://diff:%ETMPDIR%%-test%-maps-logrepo::dfe39aa48c6ddde158e42217548b531a45ff66e9::
 {{{1 gc
-aurum://diff:%ETMPDIR%%-test%-maps-logrepo:5a6a1bf999fad1f4547eeb887af54f31d11833f2:
+aurum://diff:%ETMPDIR%%-test%-maps-logrepo:5a6a1bf999fad1f4547eeb887af54f31d11833f2:::
 {{{1 d
-aurum://diff:%ETMPDIR%%-test%-maps-logrepo:dfe39aa48c6ddde158e42217548b531a45ff66e9::crepo.zsh
+aurum://diff:%ETMPDIR%%-test%-maps-logrepo:dfe39aa48c6ddde158e42217548b531a45ff66e9::crepo.zsh:
 w$: 1
 {{{1 c
-aurum://diff:%ETMPDIR%%-test%-maps-logrepo::dfe39aa48c6ddde158e42217548b531a45ff66e9:crepo.zsh
+aurum://diff:%ETMPDIR%%-test%-maps-logrepo::dfe39aa48c6ddde158e42217548b531a45ff66e9:crepo.zsh:
 w$: 1
 {{{1 D
 aurum://file:%ETMPDIR%%-test%-maps-logrepo:dfe39aa48c6ddde158e42217548b531a45ff66e9:crepo.zsh
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.