Commits

ZyX_I  committed ce40ffb

@%aurum/commit: Added g:aurum_commitautoopendiff option (untested).
Ref #52 (still needs closing opened diff to mark it as fixed)

  • Participants
  • Parent commits b170035

Comments (0)

Files changed (3)

File autoload/aurum/commit.vim

 "▶1 
 scriptencoding utf-8
-execute frawor#Setup('1.2', {'@/resources': '0.0',
+execute frawor#Setup('1.3', {'@/resources': '0.0',
             \                  '@/options': '0.0',
             \                       '@/os': '0.0',
             \                     '@aurum': '1.0',
 let s:_options={
             \'remembermsg':         {'default': 1, 'filter': 'bool'},
             \'bufleaveremembermsg': {'default': 1, 'filter': 'bool'},
+            \'commitautoopendiff':  {'default': 0, 'filter': 'bool'},
             \'commitinfowincmd':    {
             \   'default': 'largest_adjacent',
             \   'checker': 'match /\v^%([jkhlwWtbpcvs]|'.
         endif
     endif
 endfunction
-"▶1 commit :: repo, opts, files, status, types → + repo
+"▶1 commit :: repo, opts, files, status, types[, cmd[, bvarpart]] → + repo
 let s:defdate=['strftime("%Y")',
             \  'strftime("%m")',
             \  'strftime("%d")',
     endif
     "▲2
     if empty(message)
-        call s:_r.run(get(a:000, 0, 'silent new'),
+        call s:_r.run(((a:0 && a:1 isnot 0)? a:1 : 'silent new'),
                     \ 'commit', a:repo, user, date, cb, a:files)
         let bvar=s:_r.bufvars[bufnr('%')]
+        if a:0>1 && a:2 isnot 0
+            call extend(bvar, a:2)
+        endif
         let bvar.revstatus=revstatus
+        "▶2 Add previous message
         if exists('g:AuPreviousRepoPath') &&
                     \   g:AuPreviousRepoPath is# a:repo.path &&
                     \exists('g:AuPreviousTip') &&
             call cursor(line('$'), col([line('$'), '$']))
             unlet g:AuPreviousRepoPath g:AuPreviousTip g:AuPreviousCommitMessage
         endif
+        "▶2 Add comment
         let fmessage=[]
         for [file, state] in items(revstatus)
             let fmessage+=['# '.s:statmsgs[state].' '.file]
         call sort(fmessage)
         call append('.', fmessage)
         startinsert!
+        "▶2 Open diff
+        if s:_f.getoption('commitautoopendiff')
+            call bvar.findwindow()
+            call s:_r.mrun('silent edit', 'diff', bvar.repo, 0, 0,
+                        \                         keys(revstatus), {})
+            silent! %foldopen!
+            wincmd p
+        endif
+        "▲2
         return 0
     else
         call a:repo.functions.commit(a:repo, message, a:files, user, date, cb)

File autoload/aurum/record.vim

             \               '@/mappings': '0.0',
             \                   '@aurum': '1.0',
             \             '@aurum/cache': '2.1',
-            \           '@%aurum/commit': '1.2',
+            \           '@%aurum/commit': '1.3',
             \         '@%aurum/cmdutils': '4.0',
             \        '@%aurum/lineutils': '0.0',
             \             '@%aurum/edit': '1.5',
     let winview=winsaveview()
     try
         let r=s:_r.commit.commit(a:bvar.repo, a:bvar.recopts, files,
-                    \            a:bvar.status, keys(s:ntypes), 'silent edit')
+                    \            a:bvar.status, keys(s:ntypes), 'silent edit',
+                    \            {'vimdiffcb':  s:F.commitvimdiffcb,
+                    \             'findwindow': s:F.commitfindwindow,
+                    \             'bwfunc':     s:F.srestore,
+                    \             'sbvar':      a:bvar,
+                    \             'sbuf':       a:buf,
+                    \             'winview':    winview,})
     finally
         if bufwinnr(a:buf)!=-1
             call setbufvar(a:buf, '&bufhidden', 'wipe')
         call s:F.unload(a:bvar)
     else
         let w:aurecid='AuRecordCommitMessage'
-        let cbvar=s:_r.bufvars[bufnr('%')]
-        let cbvar.sbvar=a:bvar
-        let cbvar.sbuf=a:buf
-        let cbvar.bwfunc=s:F.srestore
-        let cbvar.vimdiffcb=s:F.commitvimdiffcb
-        let cbvar.findwindow=s:F.commitfindwindow
-        let cbvar.winview=winview
     endif
     return 0
 endfunction

File doc/aurum.txt

     window out of vertical, horizontal or all four directions respectively. 
     The largest is determined by comparing |winwidth()|*|winheight()|, window 
     width in this formula is capped with 80 columns.
+    Ignored when commit is done from |aurum-record| mode, in this case diff 
+    always opens in left window.
+    Default: “largest_adjacent”.
+
+commitautoopendiff                                *g:aurum_commitautoopendiff*
+    Bool. Determines whether diff should be opened when commit window is 
+    created. Uses |g:aurum_commitinfowincmd| to determine where diff should be 
+    opened.
+    Default: 0.
 
 remembermsg                                              *g:aurum_remembermsg*
     Bool. Determines whether message typed in commit buffer should be saved 
     1.1: Added sixth optional argument to _r.commit.commit().
     1.2: Added vimdiffcb and findwindow functions to aurum://commit bvar, 
          added |g:aurum_commitinfowincmd| option
+    1.3: Added seventh optional argument to _r.commit.commit() and 
+         |g:aurum_commitautoopendiff| option.
 @%aurum/annotate:
     1.0: Removed one argument to _r.annotate.setannbuf().
 @%aurum/cmdutils: