Commits

ZyX_I  committed da1fd49

@%aurum/record, @%aurum/commit:
Made commit buffer appear instead of the status buffer, not on top of it
Made closing commit buffer show up the status one. Fixes #69

  • Participants
  • Parent commits f32f46d

Comments (0)

Files changed (7)

File autoload/aurum/commit.vim

 "▶1 
 scriptencoding utf-8
-execute frawor#Setup('1.0', {'@/resources': '0.0',
+execute frawor#Setup('1.1', {'@/resources': '0.0',
             \                  '@/options': '0.0',
             \                     '@aurum': '1.0',
             \             '@%aurum/status': '1.0',
 let s:statmsgs.deleted=s:statmsgs.removed
 " TODO Investigate why closing commit buffer on windows consumes next character
 " XXX Do not change names of options used here, see :AuRecord
-function s:F.commit(repo, opts, files, status, types)
+function s:F.commit(repo, opts, files, status, types, ...)
     let user=''
     let date=''
     let message=''
     if !empty(a:files)
         call filter(revstatus, 'index(a:files, v:key)!=-1')
     endif
+    if empty(revstatus)
+        call s:_f.throw('nocom')
+    endif
     for key in filter(['user', 'date', 'message'], 'has_key(a:opts, v:val)')
         let l:{key}=a:opts[key]
     endfor
     endif
     "▲2
     if empty(message)
-        call s:_r.run('silent new', 'commit', a:repo, user, date, cb, a:files)
+        call s:_r.run(get(a:000, 0, 'silent new'),
+                    \ 'commit', a:repo, user, date, cb, a:files)
+        let bvar=s:_r.bufvars[bufnr('%')]
+        let bvar.revstatus=revstatus
         if exists('g:AuPreviousRepoPath') &&
                     \   g:AuPreviousRepoPath is# a:repo.path &&
                     \exists('g:AuPreviousTip') &&
     call a:bvar.repo.functions.commit(a:bvar.repo, message, a:bvar.files,
                 \                     a:bvar.user, a:bvar.date,
                 \                     a:bvar.closebranch)
+    call map(copy(s:_r.allcachekeys), 's:_r.cache.wipe(v:val)')
     let a:bvar.did_message=1
+    if has_key(a:bvar, 'sbvar')
+        call a:bvar.bwfunc(a:bvar)
+        let a:bvar.bwfunc=a:bvar.sbvar.bwfunc
+    endif
     call feedkeys("\<C-\>\<C-n>:bwipeout!\n")
 endfunction
 "▶1 commfunc

File autoload/aurum/record.vim

             \               '@/mappings': '0.0',
             \                   '@aurum': '1.0',
             \             '@aurum/cache': '2.1',
-            \           '@%aurum/commit': '1.0',
+            \           '@%aurum/commit': '1.1',
             \         '@%aurum/cmdutils': '4.0',
             \        '@%aurum/lineutils': '0.0',
             \             '@%aurum/edit': '1.0',
 "▶1 unload
 function s:F.unload(bvar)
     let sbvar=get(a:bvar, 'sbvar', a:bvar)
+    let sbuf=get(a:bvar, 'sbuf', -1)
+    if sbuf isnot 0 && bufexists(sbuf)
+        unlet sbvar.bwfunc
+        execute 'bwipeout!' sbuf
+    endif
     for [o, val] in items(sbvar.savedopts)
         execute 'let &g:'.o.'=val'
     endfor
         call s:_f.mapgroup.map('AuRecordLeft', bufnr('%'))
     endif
 endfunction
+"▶1 srestore
+function s:F.srestore(bvar)
+    let sbuf=get(a:bvar, 'sbuf', -1)
+    if !bufexists(sbuf)
+        return s:F.unload(get(a:bvar, sbuf, 0))
+    endif
+    let sbvar=a:bvar.sbvar
+    execute 'silent botright sbuffer' sbuf
+    execute 'resize' sbvar.swheight
+    let w:aurecid='AuRecordStatus'
+    setlocal bufhidden=wipe
+    return 1
+endfunction
 "▶1 runstatmap
 let s:statchars='-^+*'
 let s:ntypes={
             call s:_f.warn('recnof')
             return
         endif
-        aboveleft let r=s:_r.commit.commit(bvar.repo, bvar.recopts, files,
-                    \                      bvar.status, keys(s:ntypes))
+        setlocal bufhidden=hide
+        try
+            let r=s:_r.commit.commit(bvar.repo, bvar.recopts, files,
+                        \            bvar.status, keys(s:ntypes), 'silent edit')
+        finally
+            if bufwinnr(buf)!=-1
+                call setbufvar(buf, '&bufhidden', 'wipe')
+            endif
+        endtry
         if r
             call s:F.unload(bvar)
         else
             let w:aurecid='AuRecordCommitMessage'
             let cbvar=s:_r.bufvars[bufnr('%')]
             let cbvar.sbvar=bvar
-            let cbvar.bwfunc=s:F.unload
+            let cbvar.sbuf=buf
+            let cbvar.bwfunc=s:F.srestore
         endif
         return
     endif

File doc/aurum.txt

          respectively. Same for |aurum://status| “rev1” and “rev2” options.
 @%aurum/commit:
     1.0: Added fifth argument to _r.commit.commit().
+    1.1: Added sixth optional argument to _r.commit.commit()
 @%aurum/annotate:
     1.0: Removed one argument to _r.annotate.setannbuf().
 @%aurum/cmdutils:

File ftplugin/aurumcommit.vim

                     \                                      cnt)
         call append(0, split(bvar.recallcs.description, "\n", 1))
     endif
-    if has_key(bvar, 'sbvar')
-        call bvar.sbvar.recunload(bvar.sbvar)
-    endif
 endfunction
 "▶1 AuCommitMessage mapping group
 function s:F.mapwrapper(...)

File ftplugin/aurumlog.vim

                 \ 'crrestrict': 'files'})
     call s:_r.run('silent edit', 'log', a:bvar.repo, opts)
 endfunction
-"▶1 vimdiff
+"▶2 vimdiff
 function s:F.callbacks.vimdiff(file, bvar, hex, ...)
     let cs=a:bvar.repo.changesets[a:hex]
     call s:F.cwin(a:bvar)

File test/cmd-record.in

 :
 :
 :WT
+:W{{{1 edit-commit-discard-commit
+:R call writefile([''], '1')
+:R call writefile([''], '2')
+:R call writefile([''], '3')
+:R AuRecord
+Ai,XjAiAdded 1 and 2:silent write
+:
+:
+:WT
+:Run silent AuStatus
+:bwipeout!
+:
 :source addmessages.vim

File test/cmd-record.ok

 @  Changeset 31
 |  Tags: tip
 |  @ Mno
+{{{1 edit-commit-discard-commit
+@  Changeset 32
+|  Tags: tip
+|  @ Added 1 and 2
+? 3
 >>> Messages:
 
 
 Frawor:autoload/aurum/record:recnof:No files were selected for commiting
 Frawor:autoload/aurum/record:recnof:No files were selected for commiting
 Frawor:autoload/aurum/record:recnof:No files were selected for commiting
+
 <<< Messages^