Commits

ZyX_I  committed 9a06989

ftplugin/aurumlog: Made it not show selection dialog if there is the only file
to open (previously it was done only if there is only one
file in the commit that can opened)
@aurum/edit, @aurum/cmdutils, some other:
Moved bvar.prevbuf creation to @aurum/edit from other places. Fixes #34

  • Participants
  • Parent commits a070fd5

Comments (0)

Files changed (14)

File doc/aurum.txt

     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
+    1.3: Added prevbuf function
 @aurum/vimdiff:
     0.1: Added full, untracked, onlymodified and files options to |:AuVimDiff|
     0.2: Added _r.vimdiff.full.
     1.0: Added fifth argument to _r.commit.commit()
 @aurum/annotate:
     1.0: Removed one argument to _r.annotate.setannbuf()
+@aurum/cmdutils:
+    1.0: Removed cmdutils.prevbuf()
 
 vim: ft=help:tw=78

File ftplugin/aurumlog.vim

 endif
 setlocal noswapfile
 setlocal nomodeline
-execute frawor#Setup('0.0', {'@aurum/cmdutils': '0.0',
+execute frawor#Setup('0.0', {'@aurum/cmdutils': '1.0',
             \                 '@aurum/bufvars': '0.0',
             \                    '@aurum/repo': '3.0',
             \                    '@aurum/edit': '1.0',
     " Above is not applicable if we don't know exactly whether such special 
     " exists
     elseif !empty(bvar.repo.functions.getcsprop(bvar.repo, cs, 'files'))
-        if len(cs.files)==1
-            let file=cs.files[0]
+        if has_key(bvar.opts, 'files') &&
+                    \!has_key(bvar.opts.ignorefiles, 'open')
+            let files=copy(bvar.opts.csfiles[hex])
+            call filter(files, 'index(cs.files, v:val)!=-1')
+            if empty(files)
+                call s:_f.throw('novfilesff', hex)
+            endif
         else
-            if has_key(bvar.opts, 'files') &&
-                        \!has_key(bvar.opts.ignorefiles, 'open')
-                let files=copy(bvar.opts.csfiles[hex])
-                call filter(files, 'index(cs.files, v:val)!=-1')
-                if empty(files)
-                    call s:_f.throw('novfilesff', hex)
-                endif
-            else
-                let files=cs.files
-                if empty(files)
-                    call s:_f.throw('novfiles', hex)
-                endif
+            let files=cs.files
+            if empty(files)
+                call s:_f.throw('novfiles', hex)
             endif
+        endif
+        if len(files)==1
+            let file=files[0]
+        else
             let choice=inputlist(['Select file (0 to cancel):']+
                         \        map(copy(files), '(v:key+1).". ".v:val'))
             if choice

File ftplugin/aurumstatus.vim

 setlocal nomodeline
 execute frawor#Setup('0.0', {'@aurum/bufvars': '0.0',
             \                '@aurum/vimdiff': '0.2',
-            \               '@aurum/cmdutils': '0.0',
+            \               '@aurum/cmdutils': '1.0',
             \                   '@aurum/edit': '1.2',
             \                 '@aurum/commit': '1.0',
             \                    '@/mappings': '0.0',

File plugin/aurum.vim

                 \                '@/mappings': '0.0',
                 \                 '@/options': '0.0',
                 \                      '@/os': '0.1',
-                \           '@aurum/cmdutils': '0.0',
+                \           '@aurum/cmdutils': '1.0',
                 \                     '@/fwc': '0.2',
                 \               '@aurum/repo': '3.1',
                 \               '@aurum/edit': '1.0',

File plugin/aurum/annotate.vim

 scriptencoding utf-8
 if !exists('s:_pluginloaded')
     execute frawor#Setup('1.0', {'@/table': '0.1',
-                \        '@aurum/cmdutils': '0.0',
+                \        '@aurum/cmdutils': '1.0',
                 \         '@aurum/bufvars': '0.0',
                 \            '@aurum/edit': '1.0',
                 \                  '@/fwc': '0.3',

File plugin/aurum/cmdutils.vim

 "▶1
 scriptencoding utf-8
 if !exists('s:_pluginloaded')
-    execute frawor#Setup('0.0', {'@/resources': '0.0',
+    execute frawor#Setup('1.0', {'@/resources': '0.0',
                 \                       '@/os': '0.0',
                 \                '@aurum/repo': '3.0',
                 \                '@aurum/edit': '1.0',
     let buf=bufnr('%')
     return r.':if bufexists('.buf.')|bwipeout '.buf."|endif\n"
 endfunction
-"▶1 getprevbuf :: () + bufvars → buf
-function s:F.prevbuf()
-    let r=bufnr('%')
-    if has_key(s:_r.bufvars, r) && (&bufhidden is# 'wipe' ||
-                \                   &bufhidden is# 'delete') &&
-                \has_key(s:_r.bufvars[r], 'prevbuf')
-        let r=s:_r.bufvars[r].prevbuf
-    endif
-    return r
-endfunction
 "▶1 Post cmdutils resource
 call s:_f.postresource('cmdutils', {'globescape': s:F.globescape,
             \                           'getrrf': s:F.getrrf,
             \                      'getdifffile': s:F.getdifffile,
             \                        'checkrepo': s:F.checkrepo,
             \                         'closebuf': s:F.closebuf,
-            \                          'prevbuf': s:F.prevbuf,
             \                     'nogetrepoarg': s:nogetrepoarg,
             \})
 "▶1 Some completion-related globals

File plugin/aurum/commit.vim

     execute frawor#Setup('1.0', {'@/resources': '0.0',
                 \                  '@/options': '0.0',
                 \              '@aurum/status': '1.0',
-                \            '@aurum/cmdutils': '0.0',
+                \            '@aurum/cmdutils': '1.0',
                 \             '@aurum/bufvars': '0.0',
                 \                '@aurum/repo': '3.0',
                 \                '@aurum/edit': '1.0',

File plugin/aurum/diff.vim

 "▶1 
 scriptencoding utf-8
 if !exists('s:_pluginloaded')
-    execute frawor#Setup('0.0', {'@aurum/cmdutils': '0.0',
+    execute frawor#Setup('0.0', {'@aurum/cmdutils': '1.0',
                 \                 '@aurum/bufvars': '0.0',
                 \               '@aurum/lineutils': '0.0',
                 \                 '@aurum/vimdiff': '0.2',
     endif
     "▲2
     let opts=filter(copy(a:opts), 'index(s:_r.repo.diffoptslst, v:key)!=-1')
-    let prevbuf=s:_r.cmdutils.prevbuf()
     call s:_r.run(get(a:opts, 'cmd', 'silent edit'), 'diff', repo, rev1, rev2,
                 \ filelist, opts)
     if !has_key(a:opts, 'cmd')
-        let s:_r.bufvars[bufnr('%')].prevbuf=prevbuf
         setlocal bufhidden=wipe
         if has('folding')
             setlocal foldmethod=expr

File plugin/aurum/edit.vim

 "▶1
 scriptencoding utf-8
 if !exists('s:_pluginloaded')
-    execute frawor#Setup('1.2', {'@/autocommands': '0.0',
+    execute frawor#Setup('1.3', {'@/autocommands': '0.0',
                 \                   '@/functions': '0.0',
                 \                   '@/resources': '0.0',
                 \                   '@aurum/repo': '3.0',
         endif
     endif
 endfunction
+"▶1 addpats :: args → + args
+function s:F.addpats(cdescr, args)
+    let opts=a:args[-1]
+    for o in filter(copy(a:cdescr.options.pats), 'has_key(opts, v:val)')
+        let opts[o[:-2].'pats']=map(copy(opts[o]), 's:F.globtopat(v:val)')
+    endfor
+endfunction
 "▶1 auefunc
 let s:okeys={
             \'list': 'map(split(opts[o],";"), "s:F.ounescape(v:val)")',
                 let newopts[o]=eval(expr)
             endfor
         endfor
-        for o in filter(copy(get(cdescr.options, 'pats', [])),
-                    \   'has_key(newopts, v:val)')
-            let newopts[o[:-2].'pats']=map(newopts[o],
-                        \                  's:F.globtopat(v:val)')
-        endfor
         call add(args, newopts)
+        if has_key(cdescr.options, 'pats')
+            call s:F.addpats(cdescr, args)
+        endif
     endif
     "▶2 Get repository
     let repo=s:_r.repo.get(s:F.ounescape(args[0]))
     let file=call(s:F.fname, [a:command, a:repo]+a:000, {})
     let existed=bufexists(file)
     call s:F.checkcmd(a:command)
-    if type(a:repo)==type({}) && a:vcommand=~#'\v%(sil%[ent]\ )?%(edit|view)'
+    if type(a:repo)==type({}) &&
+                \a:vcommand=~#'\v%(sil%[ent]\ )?%(e%[dit]|view?)'
+        let args=copy(a:000)
+        let cdescr=s:commands[a:command]
+        if has_key(cdescr, 'options') && has_key(cdescr.options, 'pats')
+            let args[-1]=copy(args[-1])
+            call s:F.addpats(cdescr, args)
+        endif
+        let prevbuf=s:F.prevbuf()
         try
             let savedei=&eventignore
             set eventignore+=BufReadCmd
             let &eventignore=savedei
         endtry
         setlocal modifiable noreadonly
-        silent call s:F.runcmd(s:commands[a:command], file, [0, a:repo]+a:000)
+        silent call s:F.runcmd(s:commands[a:command], file, [0, a:repo]+args)
+        if bufexists(prevbuf)
+            let s:_r.bufvars[bufnr('%')].prevbuf=prevbuf
+        endif
         if a:vcommand[:2] isnot# 'sil'
             file
         endif
     endif
     return r
 endfunction
+"▶1 prevbuf :: () + bufvars → buf
+function s:F.prevbuf()
+    let r=bufnr('%')
+    if has_key(s:_r.bufvars, r) && (&bufhidden is# 'wipe' ||
+                \                   &bufhidden is# 'delete') &&
+                \has_key(s:_r.bufvars[r], 'prevbuf')
+        let r=s:_r.bufvars[r].prevbuf
+    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)
+call s:_f.postresource('prevbuf',   s:F.prevbuf)
 "▶1
 call frawor#Lockvar(s:, '_pluginloaded,_r,commands')
 " vim: ft=vim ts=4 sts=4 et fmr=▶,▲

File plugin/aurum/file.vim

 "▶1 
 scriptencoding utf-8
 if !exists('s:_pluginloaded')
-    execute frawor#Setup('0.0', {'@aurum/cmdutils': '0.0',
+    execute frawor#Setup('0.0', {'@aurum/cmdutils': '1.0',
                 \                 '@aurum/bufvars': '0.0',
                 \               '@aurum/lineutils': '0.0',
                 \                 '@aurum/vimdiff': '0.0',
     if hasbuf
         let filetype=&filetype
     endif
-    let prevbuf=s:_r.cmdutils.prevbuf()
     call s:_r.run(get(a:opts, 'cmd', 'silent edit'), 'file', repo, rev, file)
     if exists('filetype') && &filetype isnot# filetype
         let &filetype=filetype
     endif
     if !has_key(a:opts, 'cmd')
-        let s:_r.bufvars[bufnr('%')].prevbuf=prevbuf
         setlocal bufhidden=wipe
     endif
     call s:_f.mapgroup.map('AuFile', bufnr('%'))

File plugin/aurum/log.vim

 scriptencoding utf-8
 if !exists('s:_pluginloaded')
     execute frawor#Setup('0.3', {'@/table': '0.1',
-                \        '@aurum/cmdutils': '0.0',
+                \        '@aurum/cmdutils': '1.0',
                 \   '@aurum/log/templates': '0.0',
                 \       '@aurum/lineutils': '0.0',
                 \         '@aurum/bufvars': '0.0',

File plugin/aurum/record.vim

                 \                    '@/commands': '0.0',
                 \                   '@/functions': '0.0',
                 \                 '@aurum/commit': '1.0',
-                \               '@aurum/cmdutils': '0.0',
+                \               '@aurum/cmdutils': '1.0',
                 \              '@aurum/lineutils': '0.0',
                 \                   '@aurum/repo': '3.0',
                 \                   '@aurum/edit': '1.0',

File plugin/aurum/status.vim

 scriptencoding utf-8
 if !exists('s:_pluginloaded')
     execute frawor#Setup('1.1', {'@/resources': '0.0',
-                \            '@aurum/cmdutils': '0.0',
+                \            '@aurum/cmdutils': '1.0',
                 \                      '@/fwc': '0.2',
                 \                '@aurum/repo': '3.0',
                 \                '@aurum/edit': '1.0',

File plugin/aurum/vimdiff.vim

 scriptencoding utf-8
 if !exists('s:_pluginloaded')
     execute frawor#Setup('0.2', {'@/os': '0.0',
-                \     '@aurum/cmdutils': '0.0',
-                \         '@aurum/edit': '1.0',
+                \     '@aurum/cmdutils': '1.0',
+                \         '@aurum/edit': '1.3',
                 \               '@/fwc': '0.0',
                 \          '@/mappings': '0.0',
                 \         '@/resources': '0.0',
     if (a:usewin==-1 ? s:_f.getoption('usewin') : a:usewin) && winnr('$')>1
         diffthis
         if s:F.findwindow()
-            let prevbuf=s:_r.cmdutils.prevbuf()
+            let prevbuf=s:_r.prevbuf()
             execute 'silent edit' fnameescape(a:difftarget)
             diffthis
         else
         let fbuf=bufnr('%')
     else
         let t:auvimdiff_prevbuffers={}
-        let prevbuf=s:_r.cmdutils.prevbuf()
+        let prevbuf=s:_r.prevbuf()
         if frev is 0
             execute 'silent edit' fnameescape(s:_r.os.path.join(a:repo.path,
                         \                     a:file))
             if !i && a:usewin && winnr('$')>1
                 diffthis
                 if s:F.findwindow()
-                    let prevbuf=s:_r.cmdutils.prevbuf()
+                    let prevbuf=s:_r.prevbuf()
                     execute 'silent edit' fnameescape(f)
                     diffthis
                     let t:auvimdiff_prevbuffers[bufnr('%')]=prevbuf