Commits

ZyX_I committed 86a15d6

Added Track and Forget global and :AuStatus mappings
Made Diff/Rdiff :AuStatus mappings accept cound and visual selection
Made Track and Commit mappings be redirected to {record.vim}runstatmap
(that means, Track and Forget mappings are unaccessible inside :AuRecord
status buffer and commit is now done using `i' mapping, not `I'. Own
:AuRecord mappings were purged)
Replaced Revert global mapping {lhs}: s/R/O/ (due to conflict with Forget mapping)

Comments (0)

Files changed (7)

ftplugin/aurumstatus.vim

             \ 'revopen': ['added', 'ignored'],
             \    'diff': ['added', 'removed', 'deleted', 'unknown', 'ignored'],
             \'annotate': ['added', 'unknown', 'ignored'],
+            \   'track': ['added', 'clean'],
+            \  'commit': ['ignored', 'clean'],
+            \  'forget': ['removed'],
         \}
 let s:noacttypes.vimdiff    = s:noacttypes.diff
 let s:noacttypes.revdiff    = s:noacttypes.diff
 let s:noacttypes.revvimdiff = s:noacttypes.vimdiff
-function s:F.runmap(action)
+let s:noacttypes.vtrack     = s:noacttypes.track
+let s:noacttypes.vcommit    = s:noacttypes.commit
+let s:noacttypes.vforget    = s:noacttypes.forget
+function s:F.runmap(action, ...)
     let buf=bufnr('%')
     let bvar=s:_r.bufvars[buf]
     if empty(bvar.types)
         return ''
     endif
+    let visual=(a:0&&a:1)
+    let isrecord=get(bvar.opts, 'record', 0)
+    if isrecord
+        if a:action is# 'track'
+            return bvar.recrunmap(((visual)?('v'):('')).'add')
+        elseif a:action is# 'commit'
+            return bvar.recrunmap('commit')
+        elseif a:action is# 'forget'
+            return bvar.recrunmap(((visual)?('v'):('')).'remove')
+        endif
+    endif
     let rev1=get(bvar.opts, 'rev1')
     let rev2=get(bvar.opts, 'rev2')
     if rev1 is 0
     if empty(rev1) && empty(rev2)
         let rev1=bvar.repo.work_hex
     endif
-    let file=bvar.files[line('.')-1]
+    let curline=line('.')-1
+    let vline1=line("'<")
+    let vline2=line("'>")
+    let file=bvar.files[curline]
     let epath=escape(bvar.repo.path, ':\')
     if has_key(s:noacttypes, a:action) &&
-                \index(s:noacttypes[a:action], bvar.types[line('.')-1])!=-1
+                \index(s:noacttypes[a:action], bvar.types[curline])!=-1
         return ''
     endif
-    if a:action[-6:] isnot# 'commit'
-        if get(bvar.opts, 'record', 0)
+    if !(a:action is# 'commit' || a:action is# 'track' || a:action is# 'forget')
+        if isrecord
             let [lwnr, rwnr, swnr]=bvar.getwnrs()
             execute lwnr.'wincmd w'
         else
         execute 'silent e' fnameescape('aurum://diff:'.epath.':'.rev1.':'.rev2)
     elseif a:action is# 'fulldiff'
         execute 'silent edit' fnameescape('aurum://diff:'.epath.':'.rev1)
-    elseif a:action is# 'diff'
-        execute 'silent edit'
-                    \fnameescape('aurum://diff:'.epath.':'.rev1.'::'.
-                    \            escape(file, '\;:'))
-    elseif a:action is# 'revdiff'
-        execute 'silent edit'
-                    \fnameescape('aurum://diff:'.epath.':'.rev1.':'.rev2.':'.
-                    \            escape(file, '\;:'))
     elseif a:action is# 'revvimdiff' || a:action is# 'vimdiff'
         let file1=fnameescape('aurum://file:'.epath.':'.rev1.':'.file)
         if empty(rev2) || a:action is# 'vimdiff'
         execute 'silent edit' fnameescape('aurum://file:'.epath.':'.rev1.
                     \                                           ':'.file)
         AuAnnotate
-    elseif a:action[-6:] is# 'commit'
-        let visual=(a:action[0] is# 'v')
-        if visual
-            let files=map(range(line("'<"), line("'>"),
-                        \      ((line("'<")>line("'>")?(1):(-1)))),
-                        \ 'bvar.files[v:val-1]')
-        else
-            let files=bvar.files[line('.')-1:line('.')-1+v:count1-1]
-        endif
+    endif
+    if visual
+        let files=map(range(vline1, vline2, (((vline1>vline2)?(-1):(1)))),
+                    \ 'bvar.files[v:val-1]')
+    else
+        let files=bvar.files[(curline):(curline+v:count1-1)]
+    endif
+    if a:action is# 'commit'
         if s:_r.commit.commit(bvar.repo, bvar.opts, files, bvar.status)
             silent edit!
         else
                             \'endif'
             augroup END
         endif
+    elseif a:action is# 'track'
+        call map(copy(files), 'bvar.repo.functions.add(bvar.repo, v:val)')
+        silent edit!
+    elseif a:action is# 'forget'
+        call map(copy(files), 'bvar.repo.functions.forget(bvar.repo, v:val)')
+        silent edit!
+    elseif a:action is# 'diff'
+        execute 'silent edit'
+                    \fnameescape('aurum://diff:'.epath.':'.rev1.'::'.
+                    \            join(map(copy(files), 'escape(v:val, "\\;:")'),
+                    \                 ';'))
+    elseif a:action is# 'revdiff'
+        execute 'silent edit'
+                    \fnameescape('aurum://diff:'.epath.':'.rev1.':'.rev2.':'.
+                    \            join(map(copy(files), 'escape(v:val, "\\;:")'),
+                    \                 ';'))
     endif
 endfunction
 let s:_augroups+=['AuStatusCommit']
             \  'RFdiff': {'lhs': 'gd',   'rhs': s:F.getrhs(   'fulldiff')},
             \   'Fdiff': {'lhs': 'gc',   'rhs': s:F.getrhs('revfulldiff')},
             \    'Diff': {'lhs':  'd',   'rhs': s:F.getrhs(       'diff')},
+            \   'vDiff': {'lhs':  'd',   'rhs': s:F.getrhs(       'diff', 1),
+            \             'mode': 'v'},
             \   'Rdiff': {'lhs':  'c',   'rhs': s:F.getrhs(    'revdiff')},
+            \  'vRdiff': {'lhs':  'c',   'rhs': s:F.getrhs(    'revdiff', 1),
+            \             'mode': 'v'},
             \   'Vdiff': {'lhs':  'D',   'rhs': s:F.getrhs(    'vimdiff')},
             \  'RVdiff': {'lhs':  'C',   'rhs': s:F.getrhs( 'revvimdiff')},
             \'Annotate': {'lhs':  'a',   'rhs': s:F.getrhs(   'annotate')},
             \  'Commit': {'lhs':  'i',   'rhs': s:F.getrhs(     'commit')},
-            \ 'Vcommit': {'lhs':  'i',   'rhs': s:F.getrhs(    'vcommit'),
+            \ 'vCommit': {'lhs':  'i',   'rhs': s:F.getrhs(     'commit', 1),
+            \             'mode': 'v'},
+            \   'Track': {'lhs':  'A',   'rhs': s:F.getrhs(      'track')},
+            \  'vTrack': {'lhs':  'A',   'rhs': s:F.getrhs(      'track', 1),
+            \             'mode': 'v'},
+            \  'Forget': {'lhs':  'R',   'rhs': s:F.getrhs(     'forget')},
+            \ 'vForget': {'lhs':  'R',   'rhs': s:F.getrhs(     'forget', 1),
             \             'mode': 'v'},
             \}, {'func': s:F.runmap, 'silent': 1, 'mode': 'n'})
 "▶1
                 \'Commit':    {'lhs':  'i', 'rhs': ':<C-u>AuCommit<CR>'          },
                 \'CommitAll': {'lhs':  'I', 'rhs': ':<C-u>AuCommit**<CR>'        },
                 \'ROpen':     {'lhs':  'o', 'rhs': ':<C-u>AuFile<CR>'            },
-                \'Revert':    {'lhs':  'R', 'rhs': ':<C-u>AuFile . : replace<CR>'},
+                \'Revert':    {'lhs':  'O', 'rhs': ':<C-u>AuFile . : replace<CR>'},
                 \'Vdiff':     {'lhs':  'D', 'rhs': ':<C-u>AuVimDiff<CR>'         },
                 \'Diff':      {'lhs':  'd', 'rhs': ':<C-u>AuDiff :<CR>'          },
                 \'Fdiff':     {'lhs': 'gd', 'rhs': ':<C-u>AuDiff<CR>'            },
                 \'LogFile':   {'lhs':  'L', 'rhs': ':<C-u>AuLog : files :<CR>'   },
                 \'URL':       {'lhs':  'H', 'rhs': ':<C-u>AuHyperlink<CR>'       },
                 \'LineURL':   {'lhs':  'h', 'rhs': ':<C-u>AuHyperlink line 0<CR>'},
+                \'Track':     {'lhs':  'A', 'rhs': ':<C-u>AuTrack<CR>'           },
+                \'Forget':    {'lhs':  'R', 'rhs': ':<C-u>AuJunk forget :<CR>'   },
             \}, {'mode': 'n', 'silent': 1, 'leader': ',a'})
     "▲2
     finish

plugin/aurum/record.vim

     let bvar.oldbufs={}
     let bvar.bwfunc=s:F.unload
     let bvar.getwnrs=s:F.getwnrs
+    let bvar.recrunmap=s:F.runstatmap
     if !bvar.startundo
         setlocal undolevels=-1
     endif
                 \          '{})<CR>'
 endfunction
 call s:_f.mapgroup.add('AuRecord', {
-            \    'Add': {'lhs': 'A', 'rhs': s:F.gm('add')    },
-            \ 'Remove': {'lhs': 'R', 'rhs': s:F.gm('remove') },
-            \   'Edit': {'lhs': 'O', 'rhs': s:F.gm('edit')   },
-            \ 'Commit': {'lhs': 'I', 'rhs': s:F.gm('commit') },
-            \   'Undo': {'lhs': 'u', 'rhs': s:F.gm('undo')   },
-            \   'Vadd': {'lhs': 'A', 'rhs': s:F.gm('vadd'),    'mode': 'v'},
-            \'Vremove': {'lhs': 'R', 'rhs': s:F.gm('vremove'), 'mode': 'v'},
+            \   'Edit': {'lhs': 'O', 'rhs': s:F.gm('edit')  },
+            \   'Undo': {'lhs': 'u', 'rhs': s:F.gm('undo')  },
         \}, {'mode': 'n', 'silent': 1, 'dontmap': 1})
 call s:_f.mapgroup.add('AuRecordLeft', {
             \'Discard': {'lhs': 'x', 'rhs': s:F.gml('discard')   },
             \   'Exit': {'lhs': 'X', 'rhs': s:F.gml('discardall')},
-            \ 'Commit': {'lhs': 'I', 'rhs': s:F.gml('commit')    },
+            \ 'Commit': {'lhs': 'i', 'rhs': s:F.gml('commit')    },
             \ 'Remove': {'lhs': 'R', 'rhs': s:F.gml('remove')    },
         \}, {'mode': 'n', 'silent': 1, 'dontmap': 1, 'leader': ','})
 "▶1
-:W{{{1 I mapping
+:W{{{1 i mapping
 :R AuRecord
 /M
-AIAbc:silent write
+AiAbc:silent write
 :WT
 :W{{{1 BufWriteCmd event
 :R AuRecord
 A:silent write
 Def:silent write
 :WT
-:W{{{1 ARIX
+:W{{{1 ARiX
 :R AuRecord
-ARIX:WT
-:W{{{1 2A2RIX
+ARiX:WT
+:W{{{1 2A2RiX
 :R AuRecord
-2A2RIX:WT
+2A2RiX:WT
 :W{{{1 message, {count}A
 :R AuRecord message Ghi
-2AI:WT
+2Ai:WT
 :W{{{1 message, user, date
 :let date=strftime('%Y-%m-%d_%H:%M', 1200873600)
 :exe 'R AuRecord message Jkl user B\ <b@example.org> date '.date
-AI:WT!
+Ai:WT!
 :W{{{1 edit-discard
 :R silent edit nohglinesrev.lst
 :call append('$', 'This is a new text')
 :bwipeout!
 :R AuRecord message Mno
 OGdo:silent write
-,xIX:WT
+,xiX:WT
 :W{{{1 edit-discardall
 :R AuRecord message Mno
 OGdo:silent write
 :W{{{1 edit-edit-ignore
 :R AuRecord message Mno
 OGdo:silent write
-jOzRggdd,RIX:WT
+jOzRggdd,RiX:WT
 :W{{{1 edit-commit
 :R AuRecord message Mno
-OGdo,I:WT
+OGdo,i:WT
 :source addmessages.vim
-{{{1 I mapping
+{{{1 i mapping
 @  Changeset 23
 |  Tags: tip
 |  @ Abc
 @  Changeset 24
 |  Tags: tip
 |  @ Def
-{{{1 ARIX
+{{{1 ARiX
 @  Changeset 24
 |  Tags: tip
 |  @ Def
-{{{1 2A2RIX
+{{{1 2A2RiX
 @  Changeset 24
 |  Tags: tip
 |  @ Def
 GVidd02x:silent write
 :WT
 :call WriteFile(getline(1, '$'))
+:W{{{1 A
+:R for i in range(0, 9) | call writefile([i], i.'.num') | endfor
+:R AuStatus
+:0/\v^\?
+A:call WriteFile(getline(1, '$'))
+:W{{{1 2A
+:0/\v^\?
+2A:call WriteFile(getline(1, '$'))
+:W{{{1 VA
+:0/\v^\?
+V2jA:call WriteFile(getline(1, '$'))
+:W{{{1 R
+:0/\v^A
+R:call WriteFile(getline(1, '$'))
+:W{{{1 2R
+:0/\v^A
+2R:call WriteFile(getline(1, '$'))
+:W{{{1 VR
+:0/\v^A
+V2jR:call WriteFile(getline(1, '$'))
 :source addmessages.vim
 |  Tags: tip
 |  @ Removed hglines2.lst
 ? hglinesrev.lst
+{{{1 A
+A 0.num
+? 1.num
+? 2.num
+? 3.num
+? 4.num
+? 5.num
+? 6.num
+? 7.num
+? 8.num
+? 9.num
+? hglinesrev.lst
+{{{1 2A
+A 0.num
+A 1.num
+A 2.num
+? 3.num
+? 4.num
+? 5.num
+? 6.num
+? 7.num
+? 8.num
+? 9.num
+? hglinesrev.lst
+{{{1 VA
+A 0.num
+A 1.num
+A 2.num
+A 3.num
+A 4.num
+A 5.num
+? 6.num
+? 7.num
+? 8.num
+? 9.num
+? hglinesrev.lst
+{{{1 R
+A 1.num
+A 2.num
+A 3.num
+A 4.num
+A 5.num
+? 0.num
+? 6.num
+? 7.num
+? 8.num
+? 9.num
+? hglinesrev.lst
+{{{1 2R
+A 3.num
+A 4.num
+A 5.num
+? 0.num
+? 1.num
+? 2.num
+? 6.num
+? 7.num
+? 8.num
+? 9.num
+? hglinesrev.lst
+{{{1 VR
+? 0.num
+? 1.num
+? 2.num
+? 3.num
+? 4.num
+? 5.num
+? 6.num
+? 7.num
+? 8.num
+? 9.num
+? hglinesrev.lst
 >>> Messages: